def create_city(self, country_name='Uganda', city_name='kampala'): country = self.create_country(country_name) country_id = country['country']['id'] query_string = create_city_string.format(country_id=country_id, city_name=city_name) res = self.query_with_token(self.access_token_master, query_string) response = res['data']['createCity']['city'] return response
def test_create_city_country_does_not_exist(self): country_id = 300 query_string = create_city_string.format( country_id=country_id, city_name='kampala' ) response = self.query_with_token( self.access_token_master, query_string ) self.assertEqual( OUTLET_ERROR_RESPONSES["invalid_country_id"].format(country_id), response['errors'][0]['message'])
def test_create_city_already_exists(self): self.create_city() country_id = Country.objects.get(name='Uganda').id query_string = create_city_string.format( country_id=country_id, city_name='kampala' ) response = self.query_with_token( self.access_token_master, query_string ) self.assertEqual(OUTLET_ERROR_RESPONSES[ "city_double_creation_error"].format("City Kampala"), response['errors'][0]['message'])
def test_create_city_empty_city_name(self): country = self.create_country() country_id = country['country']['id'] query_string = create_city_string.format( country_id=country_id, city_name='' ) response = self.query_with_token( self.access_token_master, query_string ) self.assertEqual( OUTLET_ERROR_RESPONSES[ "invalid_city_or_country_name"].format("city"), response['errors'][0]['message'])