Add update tests
This commit is contained in:
parent
85fef10eb3
commit
0d7b26bbb2
|
|
@ -28,7 +28,7 @@ class BaseTestCase(APITestCase):
|
|||
|
||||
|
||||
class EstablishmentTests(BaseTestCase):
|
||||
def test_establishment_CRD(self):
|
||||
def test_establishment_CRUD(self):
|
||||
response = self.client.get('/api/back/establishments/', format='json')
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
||||
|
|
@ -46,12 +46,19 @@ class EstablishmentTests(BaseTestCase):
|
|||
response = self.client.get(f'/api/back/establishments/{establishment["id"]}/', format='json')
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
||||
update_data = {
|
||||
'name': 'Test new establishment'
|
||||
}
|
||||
|
||||
response = self.client.patch(f'/api/back/establishments/{establishment["id"]}/', data=update_data)
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
||||
response = self.client.delete(f'/api/back/establishments/{establishment["id"]}/', format='json')
|
||||
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
|
||||
|
||||
|
||||
class EmployeeTests(BaseTestCase):
|
||||
def test_employee_CRD(self):
|
||||
def test_employee_CRUD(self):
|
||||
response = self.client.get('/api/back/establishments/employees/', format='json')
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
||||
|
|
@ -66,6 +73,13 @@ class EmployeeTests(BaseTestCase):
|
|||
response = self.client.get('/api/back/establishments/employees/1/', format='json')
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
||||
update_data = {
|
||||
'name': 'Test new name'
|
||||
}
|
||||
|
||||
response = self.client.patch('/api/back/establishments/employees/1/', data=update_data)
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
||||
response = self.client.delete('/api/back/establishments/employees/1/', format='json')
|
||||
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
|
||||
|
||||
|
|
@ -83,7 +97,7 @@ class ChildTestCase(BaseTestCase):
|
|||
|
||||
# Test childs
|
||||
class EmailTests(ChildTestCase):
|
||||
def test_email_CRD(self):
|
||||
def test_email_CRUD(self):
|
||||
response = self.client.get('/api/back/establishments/emails/', format='json')
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
||||
|
|
@ -98,12 +112,19 @@ class EmailTests(ChildTestCase):
|
|||
response = self.client.get('/api/back/establishments/emails/1/', format='json')
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
||||
update_data = {
|
||||
'email': 'testnew@test.com'
|
||||
}
|
||||
|
||||
response = self.client.patch('/api/back/establishments/emails/1/', data=update_data)
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
||||
response = self.client.delete('/api/back/establishments/emails/1/')
|
||||
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
|
||||
|
||||
|
||||
class PhoneTests(ChildTestCase):
|
||||
def test_phone_CRD(self):
|
||||
def test_phone_CRUD(self):
|
||||
response = self.client.get('/api/back/establishments/phones/', format='json')
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
||||
|
|
@ -118,12 +139,20 @@ class PhoneTests(ChildTestCase):
|
|||
response = self.client.get('/api/back/establishments/phones/1/', format='json')
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
||||
update_data = {
|
||||
'phone': '+79999999998'
|
||||
}
|
||||
|
||||
response = self.client.patch('/api/back/establishments/phones/1/', data=update_data)
|
||||
print(f"PHONE: {response.json()}")
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
||||
response = self.client.delete('/api/back/establishments/phones/1/')
|
||||
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
|
||||
|
||||
|
||||
class SocialTests(ChildTestCase):
|
||||
def test_social_CRD(self):
|
||||
def test_social_CRUD(self):
|
||||
response = self.client.get('/api/back/establishments/socials/', format='json')
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
||||
|
|
@ -139,6 +168,13 @@ class SocialTests(ChildTestCase):
|
|||
response = self.client.get('/api/back/establishments/socials/1/', format='json')
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
||||
update_data = {
|
||||
'title': 'Test new social'
|
||||
}
|
||||
|
||||
response = self.client.patch('/api/back/establishments/socials/1/', data=update_data)
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
||||
response = self.client.delete('/api/back/establishments/socials/1/')
|
||||
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
|
||||
|
||||
|
|
@ -180,7 +216,7 @@ class PlateTests(ChildTestCase):
|
|||
|
||||
|
||||
class MenuTests(ChildTestCase):
|
||||
def test_menu_CRD(self):
|
||||
def test_menu_CRUD(self):
|
||||
response = self.client.get('/api/back/establishments/menus/', format='json')
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
||||
|
|
@ -195,12 +231,19 @@ class MenuTests(ChildTestCase):
|
|||
response = self.client.get('/api/back/establishments/menus/1/', format='json')
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
||||
update_data = {
|
||||
'category': json.dumps({"en-GB": "Test new category"})
|
||||
}
|
||||
|
||||
response = self.client.patch('/api/back/establishments/menus/1/', data=update_data)
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
||||
response = self.client.delete('/api/back/establishments/menus/1/')
|
||||
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
|
||||
|
||||
|
||||
class EstablishShedulerTests(ChildTestCase):
|
||||
def test_shedule_CRD(self):
|
||||
def test_shedule_CRUD(self):
|
||||
data = {
|
||||
'weekday': 1
|
||||
}
|
||||
|
|
@ -210,5 +253,12 @@ class EstablishShedulerTests(ChildTestCase):
|
|||
response = self.client.get(f'/api/back/establishments/{self.establishment.id}/schedule/1/')
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
||||
update_data = {
|
||||
'weekday': 2
|
||||
}
|
||||
|
||||
response = self.client.patch(f'/api/back/establishments/{self.establishment.id}/schedule/1/', data=update_data)
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
||||
response = self.client.delete(f'/api/back/establishments/{self.establishment.id}/schedule/1/')
|
||||
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user