Skip to content

Commit 695bcc7

Browse files
committed
Doc and tests updates
1 parent ac88a39 commit 695bcc7

File tree

2 files changed

+49
-8
lines changed

2 files changed

+49
-8
lines changed

geoip2/models.py

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,18 @@ class Country(object):
2121
2222
:ivar continent: :py:class:`geoip2.records.Continent` object
2323
representing continent data for the requested IP address.
24-
:ivar country: :py:class:`geoip2.recordsCountry` object representing
24+
:ivar country: :py:class:`geoip2.records.Country` object representing
2525
country data for the requested IP address. This record represents the
2626
country where MaxMind believes the IP is located in.
27-
:ivar registered_country: :py:class:`geoip2.recordsCountry` object
27+
:ivar registered_country: :py:class:`geoip2.records.Country` object
2828
representing the registered country data for the requested IP address.
2929
This record represents the country where the ISP has registered a given
3030
IP block in and may differ from the user's country.
31+
:ivar represented_country: :py:class:`geoip2.records.RepresentedCountry`
32+
object containing details about the country represented by the users
33+
of the IP address when that country is different than the country in
34+
``county``. For instance, the country represented by an
35+
overseas military base or embassy.
3136
:ivar traits: :py:class:`geoip2.records.Traits` object representing
3237
the traits for the request IP address.
3338
@@ -45,6 +50,11 @@ def __init__(self, raw_response, languages=None):
4550
geoip2.records.Country(languages,
4651
**raw_response.get('registered_country',
4752
{}))
53+
self.represented_country = \
54+
geoip2.records.RepresentedCountry(languages,
55+
**raw_response.get('represented_country',
56+
{}))
57+
4858
self.traits = geoip2.records.Traits(**raw_response.get('traits', {}))
4959
self.raw = raw_response
5060

@@ -56,17 +66,22 @@ class City(Country):
5666
country data for the requested IP address.
5767
:ivar continent: :py:class:`geoip2.records.Continent` object
5868
representing continent data for the requested IP address.
59-
:ivar country: :py:class:`geoip2.recordsCountry` object representing
69+
:ivar country: :py:class:`geoip2.records.Country` object representing
6070
country data for the requested IP address. This record represents the
6171
country where MaxMind believes the IP is located in.
6272
:ivar location: :py:class:`geoip2.records.Location` object
6373
representing country data for the requested IP address.
6474
:ivar region: :py:class:`geoip2.records.Region` object representing
6575
country data for the requested IP address.
66-
:ivar registered_country: :py:class:`geoip2.recordsCountry` object
76+
:ivar registered_country: :py:class:`geoip2.records.Country` object
6777
representing the registered country data for the requested IP address.
6878
This record represents the country where the ISP has registered a given
6979
IP block in and may differ from the user's country.
80+
:ivar represented_country: :py:class:`geoip2.records.RepresentedCountry`
81+
object containing details about the country represented by the users
82+
of the IP address when that country is different than the country in
83+
``county``. For instance, the country represented by an
84+
overseas military base or embassy.
7085
:ivar traits: :py:class:`geoip2.records.Traits` object representing
7186
the traits for the request IP address.
7287
@@ -91,17 +106,22 @@ class CityISPOrg(City):
91106
country data for the requested IP address.
92107
:ivar continent: :py:class:`geoip2.records.Continent` object
93108
representing continent data for the requested IP address.
94-
:ivar country: :py:class:`geoip2.recordsCountry` object representing
109+
:ivar country: :py:class:`geoip2.records.Country` object representing
95110
country data for the requested IP address. This record represents the
96111
country where MaxMind believes the IP is located in.
97112
:ivar location: :py:class:`geoip2.records.Location` object
98113
representing country data for the requested IP address.
99114
:ivar region: :py:class:`geoip2.records.Region` object representing
100115
country data for the requested IP address.
101-
:ivar registered_country: :py:class`geoip2.recordsCountry` object
116+
:ivar registered_country: :py:class`geoip2.records.Country` object
102117
representing the registered country data for the requested IP address.
103118
This record represents the country where the ISP has registered a given
104119
IP block in and may differ from the user's country.
120+
:ivar represented_country: :py:class:`geoip2.records.RepresentedCountry`
121+
object containing details about the country represented by the users
122+
of the IP address when that country is different than the country in
123+
``county``. For instance, the country represented by an
124+
overseas military base or embassy.
105125
:ivar traits: :py:class:`geoip2.records.Traits` object representing
106126
the traits for the request IP address.
107127
@@ -115,17 +135,22 @@ class Omni(CityISPOrg):
115135
country data for the requested IP address.
116136
:ivar continent: :py:class:`geoip2.records.Continent` object
117137
representing continent data for the requested IP address.
118-
:ivar country: :py:class:`geoip2.recordsCountry` object representing
138+
:ivar country: :py:class:`geoip2.records.Country` object representing
119139
country data for the requested IP address. This record represents the
120140
country where MaxMind believes the IP is located in.
121141
:ivar location: :py:class:`geoip2.records.Location` object
122142
representing country data for the requested IP address.
123143
:ivar region: :py:class:`geoip2.records.Region` object representing
124144
country data for the requested IP address.
125-
:ivar registered_country: :py:class:`geoip2.recordsCountry` object
145+
:ivar registered_country: :py:class:`geoip2.records.Country` object
126146
representing the registered country data for the requested IP address.
127147
This record represents the country where the ISP has registered a given
128148
IP block in and may differ from the user's country.
149+
:ivar represented_country: :py:class:`geoip2.records.RepresentedCountry`
150+
object containing details about the country represented by the users
151+
of the IP address when that country is different than the country in
152+
``county``. For instance, the country represented by an
153+
overseas military base or embassy.
129154
:ivar traits: :py:class:`geoip2.records.Traits` object representing
130155
the traits for the request IP address.
131156

tests/models_test.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ def test_omni_full(self):
6565
'iso_code': 'CA',
6666
'names': {'en': 'Canada'},
6767
},
68+
'represented_country': {
69+
'geoname_id': 3,
70+
'iso_code': 'GB',
71+
'names': {'en': 'United Kingdom'},
72+
'type': 'military',
73+
},
6874
'traits': {
6975
'autonomous_system_number': 1234,
7076
'autonomous_system_organization': 'AS Organization',
@@ -91,6 +97,9 @@ def test_omni_full(self):
9197
self.assertEqual(type(model.registered_country),
9298
geoip2.records.Country,
9399
'geoip2.records.Country object')
100+
self.assertEqual(type(model.represented_country),
101+
geoip2.records.RepresentedCountry,
102+
'geoip2.records.RepresentedCountry object')
94103
self.assertEqual(type(model.location), geoip2.records.Location,
95104
'geoip2.records.Location object')
96105
self.assertEqual(type(model.subdivisions[0]),
@@ -111,6 +120,13 @@ def test_omni_full(self):
111120
'div 2 has correct name')
112121
self.assertEqual(model.subdivisions.most_specific.iso_code, 'HP',
113122
'subdivisions.most_specific returns HP')
123+
self.assertEqual(model.represented_country.name,
124+
'United Kingdom',
125+
'represented_country name is correct')
126+
self.assertEqual(model.represented_country.type,
127+
'military',
128+
'represented_country type is correct')
129+
114130

115131
def test_omni_min(self):
116132
model = geoip2.models.Omni({'traits': {'ip_address': '5.6.7.8'}})

0 commit comments

Comments
 (0)