Skip to content

Commit 90b205a

Browse files
committed
Merge pull request #25 from maxmind/markf/demographics
Version 2.2.0
2 parents 1ab8542 + cda1672 commit 90b205a

File tree

4 files changed

+31
-5
lines changed

4 files changed

+31
-5
lines changed

HISTORY.rst

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

6+
2.2.0 (2015-06-29)
7+
++++++++++++++++++
8+
9+
* The ``geoip2.records.Location` class has been updated to add attributes for
10+
the ``average_income`` and ``population_density`` fields provided by the
11+
Insights web service.
12+
613
2.1.0 (2014-12-09)
714
++++++++++++++++++
815

geoip2/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# pylint:disable=C0111
22

33
__title__ = 'geoip2'
4-
__version__ = '2.1.0'
4+
__version__ = '2.2.0'
55
__author__ = 'Gregory Oschwald'
66
__license__ = 'Apache License, Version 2.0'
77
__copyright__ = 'Copyright 2014 Maxmind, Inc.'

geoip2/records.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,13 @@ class Location(Record):
255255
256256
Attributes:
257257
258+
.. attribute:: average_income
259+
260+
The average income in US dollars associated with the requested IP address
261+
This attribute is only available from the Insights end point.
262+
263+
:type: int
264+
258265
.. attribute:: accuracy_radius
259266
260267
The radius in kilometers around the
@@ -269,7 +276,6 @@ class Location(Record):
269276
270277
:type: float
271278
272-
273279
.. attribute:: longitude
274280
275281
The longitude of the location as a
@@ -286,6 +292,13 @@ class Location(Record):
286292
287293
:type: int
288294
295+
.. attribute:: population_density
296+
297+
The estimated population per square kilometer associated with the IP
298+
address. This attribute is only available from the Insights end point.
299+
300+
:type: int
301+
289302
.. attribute:: time_zone
290303
291304
The time zone associated with location, as
@@ -295,9 +308,9 @@ class Location(Record):
295308
:type: unicode
296309
297310
"""
298-
_valid_attributes = set(['accuracy_radius', 'latitude', 'longitude',
299-
'metro_code', 'postal_code', 'postal_confidence',
300-
'time_zone'])
311+
_valid_attributes = set(['average_income', 'accuracy_radius', 'latitude',
312+
'longitude', 'metro_code', 'population_density',
313+
'postal_code', 'postal_confidence', 'time_zone'])
301314

302315

303316
class MaxMind(Record):

tests/models_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@ def test_insights_full(self):
3939
'names': {'en': 'United States of America'},
4040
},
4141
'location': {
42+
'average_income': 24626,
4243
'accuracy_radius': 1500,
4344
'latitude': 44.98,
4445
'longitude': 93.2636,
4546
'metro_code': 765,
47+
'population_density': 1341,
4648
'time_zone': 'America/Chicago',
4749
},
4850
'postal': {
@@ -127,12 +129,16 @@ def test_insights_full(self):
127129
self.assertEqual(model.represented_country.type,
128130
'military',
129131
'represented_country type is correct')
132+
self.assertEqual(model.location.average_income, 24626,
133+
'correct average_income')
130134
self.assertEqual(model.location.latitude, 44.98,
131135
'correct latitude')
132136
self.assertEqual(model.location.longitude, 93.2636,
133137
'correct longitude')
134138
self.assertEqual(model.location.metro_code, 765,
135139
'correct metro_code')
140+
self.assertEqual(model.location.population_density, 1341,
141+
'correct population_density')
136142

137143
self.assertRegex(
138144
str(

0 commit comments

Comments
 (0)