Corrections for tests
This commit is contained in:
parent
a81f3f079a
commit
4202eb679b
|
|
@ -410,21 +410,21 @@ class EstablishmentWebTagTests(BaseTestCase):
|
||||||
class EstablishmentWebSlugTests(ChildTestCase):
|
class EstablishmentWebSlugTests(ChildTestCase):
|
||||||
|
|
||||||
def test_slug_Read(self):
|
def test_slug_Read(self):
|
||||||
response = self.client.get(f'/api/web/establishments/{self.establishment.id}/', format='json')
|
response = self.client.get(f'/api/web/establishments/slug/{self.establishment.slug}/', format='json')
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
|
|
||||||
|
|
||||||
class EstablishmentWebSimilarTests(ChildTestCase):
|
class EstablishmentWebSimilarTests(ChildTestCase):
|
||||||
|
|
||||||
def test_similar_Read(self):
|
def test_similar_Read(self):
|
||||||
response = self.client.get(f'/api/web/establishments/{self.establishment.id}/similar/', format='json')
|
response = self.client.get(f'/api/web/establishments/slug/{self.establishment.slug}/similar/', format='json')
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
|
|
||||||
|
|
||||||
class EstablishmentWebCommentsTests(ChildTestCase):
|
class EstablishmentWebCommentsTests(ChildTestCase):
|
||||||
|
|
||||||
def test_comments_CRUD(self):
|
def test_comments_CRUD(self):
|
||||||
response = self.client.get(f'/api/web/establishments/{self.establishment.id}/comments/', format='json')
|
response = self.client.get(f'/api/web/establishments/slug/{self.establishment.slug}/comments/', format='json')
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
|
|
@ -433,13 +433,13 @@ class EstablishmentWebCommentsTests(ChildTestCase):
|
||||||
'mark': 4
|
'mark': 4
|
||||||
}
|
}
|
||||||
|
|
||||||
response = self.client.post(f'/api/web/establishments/{self.establishment.id}/comments/create/',
|
response = self.client.post(f'/api/web/establishments/slug/{self.establishment.slug}/comments/create/',
|
||||||
data=data)
|
data=data)
|
||||||
|
|
||||||
comment = response.json()
|
comment = response.json()
|
||||||
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
|
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
|
||||||
|
|
||||||
response = self.client.get(f'/api/web/establishments/{self.establishment.id}/comments/{comment["id"]}/',
|
response = self.client.get(f'/api/web/establishments/slug/{self.establishment.slug}/comments/{comment["id"]}/',
|
||||||
format='json')
|
format='json')
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
|
|
||||||
|
|
@ -448,12 +448,12 @@ class EstablishmentWebCommentsTests(ChildTestCase):
|
||||||
}
|
}
|
||||||
|
|
||||||
response = self.client.patch(
|
response = self.client.patch(
|
||||||
f'/api/web/establishments/{self.establishment.id}/comments/{comment["id"]}/',
|
f'/api/web/establishments/slug/{self.establishment.slug}/comments/{comment["id"]}/',
|
||||||
data=update_data)
|
data=update_data)
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
|
|
||||||
response = self.client.delete(
|
response = self.client.delete(
|
||||||
f'/api/web/establishments/{self.establishment.id}/comments/{comment["id"]}/',
|
f'/api/web/establishments/slug/{self.establishment.slug}/comments/{comment["id"]}/',
|
||||||
format='json')
|
format='json')
|
||||||
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
|
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
|
||||||
|
|
||||||
|
|
@ -466,13 +466,13 @@ class EstablishmentWebFavoriteTests(ChildTestCase):
|
||||||
"object_id": self.establishment.id
|
"object_id": self.establishment.id
|
||||||
}
|
}
|
||||||
|
|
||||||
response = self.client.post(f'/api/web/establishments/{self.establishment.id}/favorites/',
|
response = self.client.post(f'/api/web/establishments/slug/{self.establishment.slug}/favorites/',
|
||||||
data=data)
|
data=data)
|
||||||
|
|
||||||
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
|
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
|
||||||
|
|
||||||
response = self.client.delete(
|
response = self.client.delete(
|
||||||
f'/api/web/establishments/{self.establishment.id}/favorites/',
|
f'/api/web/establishments/slug/{self.establishment.slug}/favorites/',
|
||||||
format='json')
|
format='json')
|
||||||
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
|
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -142,6 +142,7 @@ class EstablishmentFavoritesCreateDestroyView(FavoritesCreateDestroyMixinView):
|
||||||
class EstablishmentCarouselCreateDestroyView(CarouselCreateDestroyMixinView):
|
class EstablishmentCarouselCreateDestroyView(CarouselCreateDestroyMixinView):
|
||||||
"""View for create/destroy establishment from carousel."""
|
"""View for create/destroy establishment from carousel."""
|
||||||
|
|
||||||
|
lookup_field = 'slug'
|
||||||
_model = models.Establishment
|
_model = models.Establishment
|
||||||
serializer_class = serializers.EstablishmentCarouselCreateSerializer
|
serializer_class = serializers.EstablishmentCarouselCreateSerializer
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ class TagBackOfficeSerializer(TagBaseSerializer):
|
||||||
'category'
|
'category'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class TagCategoryProductSerializer(serializers.ModelSerializer):
|
class TagCategoryProductSerializer(serializers.ModelSerializer):
|
||||||
"""SHORT Serializer for TagCategory"""
|
"""SHORT Serializer for TagCategory"""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -158,10 +158,10 @@ class CarouselCreateDestroyMixinView(BaseCreateDestroyMixinView):
|
||||||
lookup_field = 'id'
|
lookup_field = 'id'
|
||||||
|
|
||||||
def get_base_object(self):
|
def get_base_object(self):
|
||||||
search_kwargs = {
|
establishment_pk = self.kwargs.get('pk')
|
||||||
'id': self.kwargs.get('pk'),
|
establishment_slug = self.kwargs.get('slug')
|
||||||
'slug': self.kwargs.get('slug'),
|
|
||||||
}
|
search_kwargs = {'id': establishment_pk} if establishment_pk else {'slug': establishment_slug}
|
||||||
return get_object_or_404(self._model, **search_kwargs)
|
return get_object_or_404(self._model, **search_kwargs)
|
||||||
|
|
||||||
def get_object(self):
|
def get_object(self):
|
||||||
|
|
@ -175,6 +175,9 @@ class CarouselCreateDestroyMixinView(BaseCreateDestroyMixinView):
|
||||||
# self.check_object_permissions(self.request, carousels)
|
# self.check_object_permissions(self.request, carousels)
|
||||||
return carousels
|
return carousels
|
||||||
|
|
||||||
|
def perform_destroy(self, instance):
|
||||||
|
instance.delete()
|
||||||
|
self.es_update_base_object()
|
||||||
|
|
||||||
# BackOffice user`s views & viewsets
|
# BackOffice user`s views & viewsets
|
||||||
class BindObjectMixin:
|
class BindObjectMixin:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user