Add city tests
This commit is contained in:
parent
7455d2c856
commit
c50bdc8637
|
|
@ -66,7 +66,7 @@ class RegionTests(BaseTestCase):
|
|||
)
|
||||
|
||||
def test_region_CRUD(self):
|
||||
response = self.client.get('/api/back/location/countries/', format='json')
|
||||
response = self.client.get('/api/back/location/regions/', format='json')
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
||||
data = {
|
||||
|
|
@ -93,6 +93,46 @@ class RegionTests(BaseTestCase):
|
|||
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
|
||||
|
||||
|
||||
class CityTests(RegionTests):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
self.region = Region.objects.create(
|
||||
name="Test region",
|
||||
code="812",
|
||||
country=self.country
|
||||
)
|
||||
|
||||
def test_city_CRUD(self):
|
||||
response = self.client.get('/api/back/location/cities/', format='json')
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
||||
data = {
|
||||
'name': 'Test country',
|
||||
'code': 'test',
|
||||
'country_id': self.country.id,
|
||||
'region_id': self.region.id
|
||||
}
|
||||
|
||||
response = self.client.post('/api/back/location/cities/', 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/cities/{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/cities/{response_data["id"]}/', data=update_data)
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
||||
response = self.client.delete(f'/api/back/location/cities/{response_data["id"]}/', format='json')
|
||||
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
|
||||
|
||||
|
||||
class AddressTests(BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user