Add comment tests
Add favorite tests
This commit is contained in:
parent
07a0f8e295
commit
cabee12fab
|
|
@ -298,18 +298,55 @@ class EstablishmentWebSimilarTests(ChildTestCase):
|
||||||
|
|
||||||
class EstablishmentWebCommentsTests(ChildTestCase):
|
class EstablishmentWebCommentsTests(ChildTestCase):
|
||||||
|
|
||||||
def test_comments_Read(self):
|
def test_comments_CRUD(self):
|
||||||
|
|
||||||
response = self.client.get(f'/api/web/establishments/slug/{self.establishment.slug}/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 = {
|
||||||
|
'text': 'test',
|
||||||
|
'user': self.user.id,
|
||||||
|
'mark': 4
|
||||||
|
}
|
||||||
|
|
||||||
|
response = self.client.post(f'/api/web/establishments/slug/{self.establishment.slug}/comments/create/',
|
||||||
|
data=data)
|
||||||
|
|
||||||
|
comment = response.json()
|
||||||
|
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
|
||||||
|
|
||||||
|
response = self.client.get(f'/api/web/establishments/slug/{self.establishment.slug}/comments/{comment["id"]}/',
|
||||||
|
format='json')
|
||||||
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
|
|
||||||
|
update_data = {
|
||||||
|
'text': 'Test new establishment'
|
||||||
|
}
|
||||||
|
|
||||||
|
response = self.client.patch(f'/api/web/establishments/slug/{self.establishment.slug}/comments/{comment["id"]}/',
|
||||||
|
data=update_data)
|
||||||
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
|
|
||||||
|
response = self.client.delete(
|
||||||
|
f'/api/web/establishments/slug/{self.establishment.slug}/comments/{comment["id"]}/',
|
||||||
|
format='json')
|
||||||
|
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
|
||||||
|
|
||||||
|
|
||||||
|
class EstablishmentWebFavoriteTests(ChildTestCase):
|
||||||
|
|
||||||
|
def test_favorite_cd(self):
|
||||||
|
data = {
|
||||||
|
"user": self.user.id,
|
||||||
|
"object_id": self.establishment.id
|
||||||
|
}
|
||||||
|
|
||||||
|
response = self.client.post(f'/api/web/establishments/slug/{self.establishment.slug}/favorites/',
|
||||||
|
data=data)
|
||||||
|
print(f"================================RESPONSE: {response.json()}")
|
||||||
|
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
|
||||||
|
|
||||||
|
response = self.client.delete(
|
||||||
# class EstablishmentWebFavoriteTests(ChildTestCase):
|
f'/api/web/establishments/slug/{self.establishment.slug}/favorites/',
|
||||||
#
|
format='json')
|
||||||
# def test_comments_Read(self):
|
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
|
||||||
# response = self.client.get(f'/api/web/establishments/slug/{self.establishment.slug}/favorites/', format='json')
|
|
||||||
# self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user