MCPcopy
hub / github.com/django/django / test_city

Method test_city

tests/gis_tests/test_geoip2.py:152–177  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

150 )
151
152 def test_city(self):
153 g = GeoIP2(country="<invalid>")
154 self.assertIs(g.is_city, True)
155 self.assertIs(g.is_country, False)
156 for query in self.query_values:
157 with self.subTest(query=query):
158 self.assertEqual(g.city(query), self.expected_city)
159
160 geom = g.geos(query)
161 self.assertIsInstance(geom, GEOSGeometry)
162 self.assertEqual(geom.srid, 4326)
163
164 expected_lat = self.expected_city["latitude"]
165 expected_lon = self.expected_city["longitude"]
166 self.assertEqual(geom.tuple, (expected_lon, expected_lat))
167 self.assertEqual(g.lat_lon(query), (expected_lat, expected_lon))
168 self.assertEqual(g.lon_lat(query), (expected_lon, expected_lat))
169
170 # Country queries should still work.
171 self.assertEqual(g.country(query), self.expected_country)
172 self.assertEqual(
173 g.country_code(query), self.expected_country["country_code"]
174 )
175 self.assertEqual(
176 g.country_name(query), self.expected_country["country_name"]
177 )
178
179 def test_not_found(self):
180 g1 = GeoIP2(city="<invalid>")

Callers

nothing calls this directly

Calls 8

cityMethod · 0.95
geosMethod · 0.95
lat_lonMethod · 0.95
lon_latMethod · 0.95
countryMethod · 0.95
country_codeMethod · 0.95
country_nameMethod · 0.95
GeoIP2Class · 0.90

Tested by

no test coverage detected