Skip to content

Commit 719808b

Browse files
committed
Update docs/test for accuracy radius in City
1 parent fb775b9 commit 719808b

File tree

5 files changed

+38
-31
lines changed

5 files changed

+38
-31
lines changed

HISTORY.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
History
44
-------
55

6+
2.3.1 (2016-XX-XX)
7+
++++++++++++++++++
8+
9+
* Updated documentation to reflect that the accuracy radius is now included
10+
in City.
11+
612
2.3.0 (2016-04-15)
713
++++++++++++++++++
814

geoip2/records.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -251,35 +251,31 @@ class Location(Record):
251251
252252
.. attribute:: average_income
253253
254-
The average income in US dollars associated with the requested IP address
255-
This attribute is only available from the Insights end point.
254+
The average income in US dollars associated with the requested IP
255+
address. This attribute is only available from the Insights end point.
256256
257257
:type: int
258258
259259
.. attribute:: accuracy_radius
260260
261-
The radius in kilometers around the
262-
specified location where the IP address is likely to be. This attribute
263-
is only available from the Insights end point and the GeoIP2 Enterprise
264-
database.
261+
The radius in kilometers around the specified location where the IP
262+
address is likely to be.
265263
266264
:type: int
267265
268266
.. attribute:: latitude
269267
270268
The approximate latitude of the location associated with the IP
271269
address. This value is not precise and should not be used to identify a
272-
particular address or household. This attribute is returned by all end
273-
points and location databases except Country.
270+
particular address or household.
274271
275272
:type: float
276273
277274
.. attribute:: longitude
278275
279276
The approximate longitude of the location associated with the IP
280277
address. This value is not precise and should not be used to identify a
281-
particular address or household. This attribute is returned by all end
282-
points and location databases except Country.
278+
particular address or household.
283279
284280
:type: float
285281
@@ -301,9 +297,9 @@ class Location(Record):
301297
302298
.. attribute:: time_zone
303299
304-
The time zone associated with location, as
305-
specified by the `IANA Time Zone Database
306-
<http://www.iana.org/time-zones>`_, e.g., "America/New_York".
300+
The time zone associated with location, as specified by the `IANA Time
301+
Zone Database <http://www.iana.org/time-zones>`_, e.g.,
302+
"America/New_York".
307303
308304
:type: unicode
309305

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
requests>=2.4
2-
maxminddb>=1.1.0
1+
requests>=2.9
2+
maxminddb>=1.2.0

tests/database_test.py

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,6 @@
2626

2727
class BaseTestReader(object):
2828

29-
def test_default_locale(self):
30-
reader = geoip2.database.Reader(
31-
'tests/data/test-data/GeoIP2-City-Test.mmdb')
32-
record = reader.city('81.2.69.160')
33-
34-
self.assertEqual(record.country.name, 'United Kingdom')
35-
reader.close()
36-
3729
def test_language_list(self):
3830
reader = geoip2.database.Reader(
3931
'tests/data/test-data/GeoIP2-Country-Test.mmdb',
@@ -43,13 +35,6 @@ def test_language_list(self):
4335
self.assertEqual(record.country.name, 'Великобритания')
4436
reader.close()
4537

46-
def test_has_ip_address(self):
47-
reader = geoip2.database.Reader(
48-
'tests/data/test-data/GeoIP2-Country-Test.mmdb')
49-
record = reader.country('81.2.69.160')
50-
self.assertEqual(record.traits.ip_address, '81.2.69.160')
51-
reader.close()
52-
5338
def test_unknown_address(self):
5439
reader = geoip2.database.Reader(
5540
'tests/data/test-data/GeoIP2-City-Test.mmdb')
@@ -91,6 +76,18 @@ def test_anonymous_ip(self):
9176
self.assertEqual(record.ip_address, ip_address)
9277
reader.close()
9378

79+
def test_city(self):
80+
reader = geoip2.database.Reader(
81+
'tests/data/test-data/GeoIP2-City-Test.mmdb')
82+
record = reader.city('81.2.69.160')
83+
84+
self.assertEqual(record.country.name, 'United Kingdom',
85+
'The default locale is en')
86+
87+
self.assertEqual(record.location.accuracy_radius, 100,
88+
'The accuracy_radius is populated')
89+
reader.close()
90+
9491
def test_connection_type(self):
9592
reader = geoip2.database.Reader(
9693
'tests/data/test-data/GeoIP2-Connection-Type-Test.mmdb')
@@ -109,6 +106,14 @@ def test_connection_type(self):
109106

110107
reader.close()
111108

109+
def test_country(self):
110+
reader = geoip2.database.Reader(
111+
'tests/data/test-data/GeoIP2-Country-Test.mmdb')
112+
record = reader.country('81.2.69.160')
113+
self.assertEqual(record.traits.ip_address, '81.2.69.160',
114+
'IP address is added to model')
115+
reader.close()
116+
112117
def test_domain(self):
113118
reader = geoip2.database.Reader(
114119
'tests/data/test-data/GeoIP2-Domain-Test.mmdb')

0 commit comments

Comments
 (0)