Add country tests
This commit is contained in:
parent
d62cee341c
commit
6b3558e3ac
|
|
@ -27,6 +27,35 @@ class BaseTestCase(APITestCase):
|
||||||
'refresh_token': tokkens.get('refresh_token')})
|
'refresh_token': tokkens.get('refresh_token')})
|
||||||
|
|
||||||
|
|
||||||
|
class CountryTests(BaseTestCase):
|
||||||
|
|
||||||
|
def test_country_CRUD(self):
|
||||||
|
response = self.client.get('/api/back/location/countries/', format='json')
|
||||||
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
|
|
||||||
|
data = {
|
||||||
|
'name': 'Test country',
|
||||||
|
'code': 'test'
|
||||||
|
}
|
||||||
|
|
||||||
|
response = self.client.post('/api/back/location/countries/', data=data, format='json')
|
||||||
|
response_data = response.json()
|
||||||
|
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
|
||||||
|
|
||||||
|
response = self.client.get(f'/api/back/location/countries/{response_data["id"]}/', format='json')
|
||||||
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
|
|
||||||
|
update_data = {
|
||||||
|
'name': json.dumps({"en-GB": "Test new country"})
|
||||||
|
}
|
||||||
|
|
||||||
|
response = self.client.patch(f'/api/back/location/countries/{response_data["id"]}/', data=update_data)
|
||||||
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
|
|
||||||
|
response = self.client.delete(f'/api/back/location/countries/{response_data["id"]}/', format='json')
|
||||||
|
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
|
||||||
|
|
||||||
|
|
||||||
class AddressTests(BaseTestCase):
|
class AddressTests(BaseTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|
@ -65,18 +94,18 @@ class AddressTests(BaseTestCase):
|
||||||
}
|
}
|
||||||
|
|
||||||
response = self.client.post('/api/back/location/addresses/', data=data, format='json')
|
response = self.client.post('/api/back/location/addresses/', data=data, format='json')
|
||||||
print(f"=========RESPONSE: {response.json()}")
|
response_data = response.json()
|
||||||
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
|
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
|
||||||
|
|
||||||
response = self.client.get('/api/back/location/addresses/1/', format='json')
|
response = self.client.get(f'/api/back/location/addresses/{response_data["id"]}/', format='json')
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
|
|
||||||
update_data = {
|
update_data = {
|
||||||
'number': '+79999991'
|
'number': '+79999991'
|
||||||
}
|
}
|
||||||
|
|
||||||
response = self.client.patch('/api/back/location/addresses/1/', data=update_data)
|
response = self.client.patch(f'/api/back/location/addresses/{response_data["id"]}/', 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('/api/back/location/addresses/1/', format='json')
|
response = self.client.delete(f'/api/back/location/addresses/{response_data["id"]}/', format='json')
|
||||||
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
|
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user