Skip to content

Commit

Permalink
Update namespace of url (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
meomancer authored Jul 12, 2024
1 parent cefa237 commit d41fd41
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
18 changes: 9 additions & 9 deletions django_project/cloud_native_gis/tests/api/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def setUp(self):

def test_list_api(self):
"""Test List API."""
url = reverse('cloud-native-gis-layer-view-set-list')
url = reverse('cloud-native-gis-layer-list')
response = self.assertRequestGetView(url, 200, user=self.user)
self.assertEqual(len(response.json()['results']), 2)

Expand All @@ -45,13 +45,13 @@ def test_list_api_by_filter(self):
'name__contains': 'Layer 2'
}
)
url = reverse('cloud-native-gis-layer-view-set-list') + '?' + params
url = reverse('cloud-native-gis-layer-list') + '?' + params
response = self.assertRequestGetView(url, 200, user=self.user)
self.assertEqual(len(response.json()['results']), 1)

def test_create_api(self):
"""Test POST API."""
url = reverse('cloud-native-gis-layer-view-set-list')
url = reverse('cloud-native-gis-layer-list')
response = self.assertRequestPostView(
url, 201,
user=self.user,
Expand All @@ -69,11 +69,11 @@ def test_create_api(self):

def test_detail_api(self):
"""Test GET detail api."""
url = reverse('cloud-native-gis-layer-view-set-list', args=[0])
url = reverse('cloud-native-gis-layer-list', args=[0])
self.assertRequestGetView(url, 404)

url = reverse(
'cloud-native-gis-layer-view-set-detail',
'cloud-native-gis-layer-detail',
kwargs={'id': self.layer_1.id}
)
response = self.assertRequestGetView(url, 200, user=self.user).json()
Expand All @@ -86,11 +86,11 @@ def test_detail_api(self):

def test_update_api(self):
"""Test PUT API."""
url = reverse('cloud-native-gis-layer-view-set-list', args=[0])
url = reverse('cloud-native-gis-layer-list', args=[0])
self.assertRequestPutView(url, 404, data={})

url = reverse(
'cloud-native-gis-layer-view-set-detail',
'cloud-native-gis-layer-detail',
kwargs={'id': self.layer_1.id}
)
self.assertRequestPutView(url, 403, data={})
Expand Down Expand Up @@ -118,10 +118,10 @@ def test_update_api(self):
def test_delete_api(self):
"""Test DELETE API."""
_id = self.layer_1.id
url = reverse('cloud-native-gis-layer-view-set-detail', args=[0])
url = reverse('cloud-native-gis-layer-detail', args=[0])
self.assertRequestDeleteView(url, 404)
url = reverse(
'cloud-native-gis-layer-view-set-detail', kwargs={'id': _id}
'cloud-native-gis-layer-detail', kwargs={'id': _id}
)
self.assertRequestDeleteView(url, 403)
self.assertRequestDeleteView(url, 403, user=self.user_1)
Expand Down
4 changes: 2 additions & 2 deletions django_project/cloud_native_gis/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@

router = DefaultRouter()
router.register(
r'layer', LayerViewSet, basename='cloud-native-gis-layer-view-set'
r'layer', LayerViewSet, basename='cloud-native-gis-layer'
)
layer_router = NestedSimpleRouter(
router, r'layer', lookup='layer'
)
layer_router.register(
'style', LayerStyleViewSet,
basename='cloud-native-gis-style-view-set'
basename='cloud-native-gis-style'
)

urlpatterns = [
Expand Down
4 changes: 2 additions & 2 deletions django_project/cloud_native_gis/utils/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def layer_style_url(layer: Layer, style: Style, request) -> str:
if not style:
return None
return request.build_absolute_uri('/')[:-1] + reverse(
'cloud-native-gis-style-view-set-detail',
'cloud-native-gis-style-detail',
kwargs={
'layer_id': layer.id,
'id': style.id
Expand All @@ -36,7 +36,7 @@ def layer_style_url(layer: Layer, style: Style, request) -> str:
def layer_api_url(layer: Layer, request) -> str:
"""Return layer api url."""
return request.build_absolute_uri('/')[:-1] + reverse(
'cloud-native-gis-layer-view-set-detail',
'cloud-native-gis-layer-detail',
kwargs={
'id': layer.id
}
Expand Down

0 comments on commit d41fd41

Please sign in to comment.