[Python-modules-commits] [python-geoip2] 01/06: Import python-geoip2_2.7.0+dfsg1.orig.tar.gz
Ondrej Koblizek
kobla-guest at moszumanska.debian.org
Fri Feb 2 12:35:48 UTC 2018
This is an automated email from the git hooks/post-receive script.
kobla-guest pushed a commit to branch master
in repository python-geoip2.
commit 81229475958f3d94c51f54bb0d4159a4e3257d8f
Author: Ondřej Kobližek <ondrej.koblizek at firma.seznam.cz>
Date: Fri Feb 2 11:36:21 2018 +0100
Import python-geoip2_2.7.0+dfsg1.orig.tar.gz
---
HISTORY.rst | 10 +++-
PKG-INFO | 4 +-
geoip2.egg-info/PKG-INFO | 4 +-
geoip2.egg-info/SOURCES.txt | 1 +
geoip2/__init__.py | 4 +-
geoip2/mixins.py | 4 +-
geoip2/records.py | 27 ++++++++-
geoip2/webservice.py | 64 ++++++++++-----------
setup.cfg | 1 -
setup.py | 1 +
tests/data/test-data/GeoIP2-Anonymous-IP-Test.mmdb | Bin 4024 -> 4192 bytes
.../GeoIP2-City-Test-Broken-Double-Format.mmdb | Bin 19041 -> 20470 bytes
.../GeoIP2-City-Test-Invalid-Node-Count.mmdb | Bin 19423 -> 20851 bytes
tests/data/test-data/GeoIP2-City-Test.mmdb | Bin 19403 -> 20831 bytes
.../test-data/GeoIP2-Connection-Type-Test.mmdb | Bin 2463 -> 3779 bytes
tests/data/test-data/GeoIP2-Country-Test.mmdb | Bin 16189 -> 18058 bytes
.../data/test-data/GeoIP2-DensityIncome-Test.mmdb | Bin 1650 -> 3065 bytes
tests/data/test-data/GeoIP2-Domain-Test.mmdb | Bin 4947 -> 6326 bytes
tests/data/test-data/GeoIP2-Enterprise-Test.mmdb | Bin 6545 -> 7930 bytes
tests/data/test-data/GeoIP2-ISP-Test.mmdb | Bin 75113 -> 76177 bytes
.../GeoIP2-Precision-Enterprise-Test.mmdb | Bin 8625 -> 12888 bytes
tests/data/test-data/GeoIP2-User-Count-Test.mmdb | Bin 0 -> 3858 bytes
tests/data/test-data/GeoLite2-ASN-Test.mmdb | Bin 1753 -> 3168 bytes
.../test-data/MaxMind-DB-no-ipv4-search-tree.mmdb | Bin 1614 -> 618 bytes
.../test-data/MaxMind-DB-string-value-entries.mmdb | Bin 579 -> 1341 bytes
.../MaxMind-DB-test-broken-pointers-24.mmdb | Bin 527 -> 1289 bytes
.../MaxMind-DB-test-broken-search-tree-24.mmdb | Bin 551 -> 1298 bytes
tests/data/test-data/MaxMind-DB-test-decoder.mmdb | Bin 2732 -> 2933 bytes
tests/data/test-data/MaxMind-DB-test-ipv4-24.mmdb | Bin 536 -> 1298 bytes
tests/data/test-data/MaxMind-DB-test-ipv4-28.mmdb | Bin 573 -> 1462 bytes
tests/data/test-data/MaxMind-DB-test-ipv4-32.mmdb | Bin 610 -> 1626 bytes
tests/data/test-data/MaxMind-DB-test-ipv6-24.mmdb | Bin 1545 -> 2806 bytes
tests/data/test-data/MaxMind-DB-test-ipv6-28.mmdb | Bin 1751 -> 3222 bytes
tests/data/test-data/MaxMind-DB-test-ipv6-32.mmdb | Bin 1957 -> 3638 bytes
.../MaxMind-DB-test-metadata-pointers.mmdb | Bin 2198 -> 2198 bytes
tests/data/test-data/MaxMind-DB-test-mixed-24.mmdb | Bin 1847 -> 3066 bytes
tests/data/test-data/MaxMind-DB-test-mixed-28.mmdb | Bin 2089 -> 3511 bytes
tests/data/test-data/MaxMind-DB-test-mixed-32.mmdb | Bin 2331 -> 3956 bytes
tests/data/test-data/MaxMind-DB-test-nested.mmdb | Bin 2590 -> 3802 bytes
tests/database_test.py | 19 +++---
tests/models_test.py | 26 +++++----
tests/webservice_test.py | 60 +++++++++++++++----
42 files changed, 150 insertions(+), 75 deletions(-)
diff --git a/HISTORY.rst b/HISTORY.rst
index 1a211f0..d082c16 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -3,6 +3,14 @@
History
-------
+2.7.0 (2018-01-18)
+++++++++++++++++++
+
+* The ``is_in_european_union`` attribute was added to
+ ``geoip2.record.Country`` and ``geoip2.record.RepresentedCountry``. This
+ attribute is ``True`` if the country is a member state of the European
+ Union.
+
2.6.0 (2017-10-27)
++++++++++++++++++
@@ -55,7 +63,7 @@ History
2.2.0 (2015-06-29)
++++++++++++++++++
-* The ``geoip2.records.Location` class has been updated to add attributes for
+* The ``geoip2.records.Location`` class has been updated to add attributes for
the ``average_income`` and ``population_density`` fields provided by the
Insights web service.
* The ``is_anonymous_proxy`` and ``is_satellite_provider`` properties on
diff --git a/PKG-INFO b/PKG-INFO
index e9fb23e..8d45ce2 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,11 +1,12 @@
Metadata-Version: 1.1
Name: geoip2
-Version: 2.6.0
+Version: 2.7.0
Summary: MaxMind GeoIP2 API
Home-page: http://www.maxmind.com/
Author: Gregory Oschwald
Author-email: goschwald at maxmind.com
License: Apache License, Version 2.0
+Description-Content-Type: UNKNOWN
Description: =========================
MaxMind GeoIP2 Python API
=========================
@@ -426,6 +427,7 @@ Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python
Classifier: Topic :: Internet :: Proxy Servers
Classifier: Topic :: Internet
diff --git a/geoip2.egg-info/PKG-INFO b/geoip2.egg-info/PKG-INFO
index e9fb23e..8d45ce2 100644
--- a/geoip2.egg-info/PKG-INFO
+++ b/geoip2.egg-info/PKG-INFO
@@ -1,11 +1,12 @@
Metadata-Version: 1.1
Name: geoip2
-Version: 2.6.0
+Version: 2.7.0
Summary: MaxMind GeoIP2 API
Home-page: http://www.maxmind.com/
Author: Gregory Oschwald
Author-email: goschwald at maxmind.com
License: Apache License, Version 2.0
+Description-Content-Type: UNKNOWN
Description: =========================
MaxMind GeoIP2 Python API
=========================
@@ -426,6 +427,7 @@ Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python
Classifier: Topic :: Internet :: Proxy Servers
Classifier: Topic :: Internet
diff --git a/geoip2.egg-info/SOURCES.txt b/geoip2.egg-info/SOURCES.txt
index c3ecf06..f27cbe0 100644
--- a/geoip2.egg-info/SOURCES.txt
+++ b/geoip2.egg-info/SOURCES.txt
@@ -66,6 +66,7 @@ tests/data/test-data/GeoIP2-Domain-Test.mmdb
tests/data/test-data/GeoIP2-Enterprise-Test.mmdb
tests/data/test-data/GeoIP2-ISP-Test.mmdb
tests/data/test-data/GeoIP2-Precision-Enterprise-Test.mmdb
+tests/data/test-data/GeoIP2-User-Count-Test.mmdb
tests/data/test-data/GeoLite2-ASN-Test.mmdb
tests/data/test-data/MaxMind-DB-no-ipv4-search-tree.mmdb
tests/data/test-data/MaxMind-DB-string-value-entries.mmdb
diff --git a/geoip2/__init__.py b/geoip2/__init__.py
index f7f9854..b9830ee 100644
--- a/geoip2/__init__.py
+++ b/geoip2/__init__.py
@@ -1,7 +1,7 @@
# pylint:disable=C0111
__title__ = 'geoip2'
-__version__ = '2.6.0'
+__version__ = '2.7.0'
__author__ = 'Gregory Oschwald'
__license__ = 'Apache License, Version 2.0'
-__copyright__ = 'Copyright (c) 2013-2017 Maxmind, Inc.'
+__copyright__ = 'Copyright (c) 2013-2018 Maxmind, Inc.'
diff --git a/geoip2/mixins.py b/geoip2/mixins.py
index 7fb4c27..4afc5a0 100644
--- a/geoip2/mixins.py
+++ b/geoip2/mixins.py
@@ -9,8 +9,8 @@ class SimpleEquality(object):
__metaclass__ = ABCMeta
def __eq__(self, other):
- return (isinstance(other, self.__class__) and
- self.__dict__ == other.__dict__)
+ return (isinstance(other, self.__class__)
+ and self.__dict__ == other.__dict__)
def __ne__(self, other):
return not self.__eq__(other)
diff --git a/geoip2/records.py b/geoip2/records.py
index 50b82dc..9e04960 100644
--- a/geoip2/records.py
+++ b/geoip2/records.py
@@ -159,6 +159,12 @@ class Country(PlaceRecord):
:type: int
+ .. attribute:: is_in_european_union
+
+ This is true if the country is a member state of the European Union.
+
+ :type: bool
+
.. attribute:: iso_code
The two-character `ISO 3166-1
@@ -183,7 +189,14 @@ class Country(PlaceRecord):
"""
- _valid_attributes = set(['confidence', 'geoname_id', 'iso_code', 'names'])
+ _valid_attributes = set([
+ 'confidence', 'geoname_id', 'is_in_european_union', 'iso_code', 'names'
+ ])
+
+ def __init__(self, locales=None, **kwargs):
+ if 'is_in_european_union' not in kwargs:
+ kwargs['is_in_european_union'] = False
+ super(Country, self).__init__(locales, **kwargs)
class RepresentedCountry(Country):
@@ -210,6 +223,12 @@ class RepresentedCountry(Country):
:type: int
+ .. attribute:: is_in_european_union
+
+ This is true if the country is a member state of the European Union.
+
+ :type: bool
+
.. attribute:: iso_code
The two-character `ISO 3166-1
@@ -242,8 +261,10 @@ class RepresentedCountry(Country):
"""
- _valid_attributes = set(
- ['confidence', 'geoname_id', 'iso_code', 'names', 'type'])
+ _valid_attributes = set([
+ 'confidence', 'geoname_id', 'is_in_european_union', 'iso_code',
+ 'names', 'type'
+ ])
class Location(Record):
diff --git a/geoip2/webservice.py b/geoip2/webservice.py
index fa6981f..80c2015 100644
--- a/geoip2/webservice.py
+++ b/geoip2/webservice.py
@@ -149,11 +149,10 @@ class Client(object):
'User-Agent': self._user_agent()
},
timeout=self._timeout)
- if response.status_code == 200:
- body = self._handle_success(response, uri)
- return model_class(body, locales=self._locales)
- else:
- self._handle_error(response, uri)
+ if response.status_code != 200:
+ raise self._exception_for_error(response, uri)
+ body = self._handle_success(response, uri)
+ return model_class(body, locales=self._locales)
def _user_agent(self):
return 'GeoIP2 Python Client v%s (%s)' % (geoip2.__version__,
@@ -168,57 +167,54 @@ class Client(object):
'JSON: ' % locals() + ', '.join(ex.args), 200,
uri)
- def _handle_error(self, response, uri):
+ def _exception_for_error(self, response, uri):
status = response.status_code
if 400 <= status < 500:
- self._handle_4xx_status(response, status, uri)
+ return self._exception_for_4xx_status(response, status, uri)
elif 500 <= status < 600:
- self._handle_5xx_status(status, uri)
- else:
- self._handle_non_200_status(status, uri)
+ return self._exception_for_5xx_status(status, uri)
+ return self._exception_for_non_200_status(status, uri)
- def _handle_4xx_status(self, response, status, uri):
+ def _exception_for_4xx_status(self, response, status, uri):
if not response.content:
- raise HTTPError('Received a %(status)i error for %(uri)s '
- 'with no body.' % locals(), status, uri)
+ return HTTPError('Received a %(status)i error for %(uri)s '
+ 'with no body.' % locals(), status, uri)
elif response.headers['Content-Type'].find('json') == -1:
- raise HTTPError('Received a %i for %s with the following '
- 'body: %s' % (status, uri, response.content),
- status, uri)
+ return HTTPError('Received a %i for %s with the following '
+ 'body: %s' % (status, uri, response.content),
+ status, uri)
try:
body = response.json()
except ValueError as ex:
- raise HTTPError(
+ return HTTPError(
'Received a %(status)i error for %(uri)s but it did'
' not include the expected JSON body: ' % locals() +
', '.join(ex.args), status, uri)
else:
if 'code' in body and 'error' in body:
- self._handle_web_service_error(
+ return self._exception_for_web_service_error(
body.get('error'), body.get('code'), status, uri)
- else:
- raise HTTPError(
- 'Response contains JSON but it does not specify '
- 'code or error keys', status, uri)
+ return HTTPError('Response contains JSON but it does not specify '
+ 'code or error keys', status, uri)
- def _handle_web_service_error(self, message, code, status, uri):
+ def _exception_for_web_service_error(self, message, code, status, uri):
if code in ('IP_ADDRESS_NOT_FOUND', 'IP_ADDRESS_RESERVED'):
- raise AddressNotFoundError(message)
+ return AddressNotFoundError(message)
elif code in ('AUTHORIZATION_INVALID', 'LICENSE_KEY_REQUIRED',
'USER_ID_REQUIRED', 'USER_ID_UNKNOWN'):
- raise AuthenticationError(message)
+ return AuthenticationError(message)
elif code in ('INSUFFICIENT_FUNDS', 'OUT_OF_QUERIES'):
- raise OutOfQueriesError(message)
+ return OutOfQueriesError(message)
elif code == 'PERMISSION_REQUIRED':
- raise PermissionRequiredError(message)
+ return PermissionRequiredError(message)
- raise InvalidRequestError(message, code, status, uri)
+ return InvalidRequestError(message, code, status, uri)
- def _handle_5xx_status(self, status, uri):
- raise HTTPError('Received a server error (%(status)i) for '
- '%(uri)s' % locals(), status, uri)
+ def _exception_for_5xx_status(self, status, uri):
+ return HTTPError('Received a server error (%(status)i) for '
+ '%(uri)s' % locals(), status, uri)
- def _handle_non_200_status(self, status, uri):
- raise HTTPError('Received a very surprising HTTP status '
- '(%(status)i) for %(uri)s' % locals(), status, uri)
+ def _exception_for_non_200_status(self, status, uri):
+ return HTTPError('Received a very surprising HTTP status '
+ '(%(status)i) for %(uri)s' % locals(), status, uri)
diff --git a/setup.cfg b/setup.cfg
index 0d92335..7f2f5e5 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -9,5 +9,4 @@ universal = 1
[egg_info]
tag_build =
tag_date = 0
-tag_svn_revision = 0
diff --git a/setup.py b/setup.py
index 0b67cba..1517cdf 100644
--- a/setup.py
+++ b/setup.py
@@ -43,6 +43,7 @@ setup(
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
+ 'Programming Language :: Python :: 3.6',
'Programming Language :: Python',
'Topic :: Internet :: Proxy Servers',
'Topic :: Internet',
diff --git a/tests/data/test-data/GeoIP2-Anonymous-IP-Test.mmdb b/tests/data/test-data/GeoIP2-Anonymous-IP-Test.mmdb
index 3bfd806..2622303 100644
Binary files a/tests/data/test-data/GeoIP2-Anonymous-IP-Test.mmdb and b/tests/data/test-data/GeoIP2-Anonymous-IP-Test.mmdb differ
diff --git a/tests/data/test-data/GeoIP2-City-Test-Broken-Double-Format.mmdb b/tests/data/test-data/GeoIP2-City-Test-Broken-Double-Format.mmdb
index eb18c5b..142770d 100644
Binary files a/tests/data/test-data/GeoIP2-City-Test-Broken-Double-Format.mmdb and b/tests/data/test-data/GeoIP2-City-Test-Broken-Double-Format.mmdb differ
diff --git a/tests/data/test-data/GeoIP2-City-Test-Invalid-Node-Count.mmdb b/tests/data/test-data/GeoIP2-City-Test-Invalid-Node-Count.mmdb
index 78eeaad..6b8b257 100644
Binary files a/tests/data/test-data/GeoIP2-City-Test-Invalid-Node-Count.mmdb and b/tests/data/test-data/GeoIP2-City-Test-Invalid-Node-Count.mmdb differ
diff --git a/tests/data/test-data/GeoIP2-City-Test.mmdb b/tests/data/test-data/GeoIP2-City-Test.mmdb
index ab8b82d..979bcc0 100644
Binary files a/tests/data/test-data/GeoIP2-City-Test.mmdb and b/tests/data/test-data/GeoIP2-City-Test.mmdb differ
diff --git a/tests/data/test-data/GeoIP2-Connection-Type-Test.mmdb b/tests/data/test-data/GeoIP2-Connection-Type-Test.mmdb
index ab73a05..ef0c278 100644
Binary files a/tests/data/test-data/GeoIP2-Connection-Type-Test.mmdb and b/tests/data/test-data/GeoIP2-Connection-Type-Test.mmdb differ
diff --git a/tests/data/test-data/GeoIP2-Country-Test.mmdb b/tests/data/test-data/GeoIP2-Country-Test.mmdb
index 9faf299..56b2198 100644
Binary files a/tests/data/test-data/GeoIP2-Country-Test.mmdb and b/tests/data/test-data/GeoIP2-Country-Test.mmdb differ
diff --git a/tests/data/test-data/GeoIP2-DensityIncome-Test.mmdb b/tests/data/test-data/GeoIP2-DensityIncome-Test.mmdb
index be978fd..11c5fa5 100644
Binary files a/tests/data/test-data/GeoIP2-DensityIncome-Test.mmdb and b/tests/data/test-data/GeoIP2-DensityIncome-Test.mmdb differ
diff --git a/tests/data/test-data/GeoIP2-Domain-Test.mmdb b/tests/data/test-data/GeoIP2-Domain-Test.mmdb
index 4c37c34..0d355c0 100644
Binary files a/tests/data/test-data/GeoIP2-Domain-Test.mmdb and b/tests/data/test-data/GeoIP2-Domain-Test.mmdb differ
diff --git a/tests/data/test-data/GeoIP2-Enterprise-Test.mmdb b/tests/data/test-data/GeoIP2-Enterprise-Test.mmdb
index 7e853d0..ed3e8b5 100644
Binary files a/tests/data/test-data/GeoIP2-Enterprise-Test.mmdb and b/tests/data/test-data/GeoIP2-Enterprise-Test.mmdb differ
diff --git a/tests/data/test-data/GeoIP2-ISP-Test.mmdb b/tests/data/test-data/GeoIP2-ISP-Test.mmdb
index 24e9e1e..c600b9d 100644
Binary files a/tests/data/test-data/GeoIP2-ISP-Test.mmdb and b/tests/data/test-data/GeoIP2-ISP-Test.mmdb differ
diff --git a/tests/data/test-data/GeoIP2-Precision-Enterprise-Test.mmdb b/tests/data/test-data/GeoIP2-Precision-Enterprise-Test.mmdb
index 13178a3..ca0cf40 100644
Binary files a/tests/data/test-data/GeoIP2-Precision-Enterprise-Test.mmdb and b/tests/data/test-data/GeoIP2-Precision-Enterprise-Test.mmdb differ
diff --git a/tests/data/test-data/GeoIP2-User-Count-Test.mmdb b/tests/data/test-data/GeoIP2-User-Count-Test.mmdb
new file mode 100644
index 0000000..e30f035
Binary files /dev/null and b/tests/data/test-data/GeoIP2-User-Count-Test.mmdb differ
diff --git a/tests/data/test-data/GeoLite2-ASN-Test.mmdb b/tests/data/test-data/GeoLite2-ASN-Test.mmdb
index 6a02e60..677c692 100644
Binary files a/tests/data/test-data/GeoLite2-ASN-Test.mmdb and b/tests/data/test-data/GeoLite2-ASN-Test.mmdb differ
diff --git a/tests/data/test-data/MaxMind-DB-no-ipv4-search-tree.mmdb b/tests/data/test-data/MaxMind-DB-no-ipv4-search-tree.mmdb
index 5ee0e6d..58c2ea9 100644
Binary files a/tests/data/test-data/MaxMind-DB-no-ipv4-search-tree.mmdb and b/tests/data/test-data/MaxMind-DB-no-ipv4-search-tree.mmdb differ
diff --git a/tests/data/test-data/MaxMind-DB-string-value-entries.mmdb b/tests/data/test-data/MaxMind-DB-string-value-entries.mmdb
index c645cb1..b5c23d1 100644
Binary files a/tests/data/test-data/MaxMind-DB-string-value-entries.mmdb and b/tests/data/test-data/MaxMind-DB-string-value-entries.mmdb differ
diff --git a/tests/data/test-data/MaxMind-DB-test-broken-pointers-24.mmdb b/tests/data/test-data/MaxMind-DB-test-broken-pointers-24.mmdb
index c354274..2ac4b50 100644
Binary files a/tests/data/test-data/MaxMind-DB-test-broken-pointers-24.mmdb and b/tests/data/test-data/MaxMind-DB-test-broken-pointers-24.mmdb differ
diff --git a/tests/data/test-data/MaxMind-DB-test-broken-search-tree-24.mmdb b/tests/data/test-data/MaxMind-DB-test-broken-search-tree-24.mmdb
index c62f5c8..55cc1aa 100644
Binary files a/tests/data/test-data/MaxMind-DB-test-broken-search-tree-24.mmdb and b/tests/data/test-data/MaxMind-DB-test-broken-search-tree-24.mmdb differ
diff --git a/tests/data/test-data/MaxMind-DB-test-decoder.mmdb b/tests/data/test-data/MaxMind-DB-test-decoder.mmdb
index 50caae1..1726140 100644
Binary files a/tests/data/test-data/MaxMind-DB-test-decoder.mmdb and b/tests/data/test-data/MaxMind-DB-test-decoder.mmdb differ
diff --git a/tests/data/test-data/MaxMind-DB-test-ipv4-24.mmdb b/tests/data/test-data/MaxMind-DB-test-ipv4-24.mmdb
index 1530ca5..f7f750f 100644
Binary files a/tests/data/test-data/MaxMind-DB-test-ipv4-24.mmdb and b/tests/data/test-data/MaxMind-DB-test-ipv4-24.mmdb differ
diff --git a/tests/data/test-data/MaxMind-DB-test-ipv4-28.mmdb b/tests/data/test-data/MaxMind-DB-test-ipv4-28.mmdb
index 24908b8..f6981d0 100644
Binary files a/tests/data/test-data/MaxMind-DB-test-ipv4-28.mmdb and b/tests/data/test-data/MaxMind-DB-test-ipv4-28.mmdb differ
diff --git a/tests/data/test-data/MaxMind-DB-test-ipv4-32.mmdb b/tests/data/test-data/MaxMind-DB-test-ipv4-32.mmdb
index c38eaf1..9cdd714 100644
Binary files a/tests/data/test-data/MaxMind-DB-test-ipv4-32.mmdb and b/tests/data/test-data/MaxMind-DB-test-ipv4-32.mmdb differ
diff --git a/tests/data/test-data/MaxMind-DB-test-ipv6-24.mmdb b/tests/data/test-data/MaxMind-DB-test-ipv6-24.mmdb
index 8ba7bab..dd25be8 100644
Binary files a/tests/data/test-data/MaxMind-DB-test-ipv6-24.mmdb and b/tests/data/test-data/MaxMind-DB-test-ipv6-24.mmdb differ
diff --git a/tests/data/test-data/MaxMind-DB-test-ipv6-28.mmdb b/tests/data/test-data/MaxMind-DB-test-ipv6-28.mmdb
index 1082f85..80e0c5a 100644
Binary files a/tests/data/test-data/MaxMind-DB-test-ipv6-28.mmdb and b/tests/data/test-data/MaxMind-DB-test-ipv6-28.mmdb differ
diff --git a/tests/data/test-data/MaxMind-DB-test-ipv6-32.mmdb b/tests/data/test-data/MaxMind-DB-test-ipv6-32.mmdb
index f28f359..7d16999 100644
Binary files a/tests/data/test-data/MaxMind-DB-test-ipv6-32.mmdb and b/tests/data/test-data/MaxMind-DB-test-ipv6-32.mmdb differ
diff --git a/tests/data/test-data/MaxMind-DB-test-metadata-pointers.mmdb b/tests/data/test-data/MaxMind-DB-test-metadata-pointers.mmdb
index 533439d..50d0dda 100644
Binary files a/tests/data/test-data/MaxMind-DB-test-metadata-pointers.mmdb and b/tests/data/test-data/MaxMind-DB-test-metadata-pointers.mmdb differ
diff --git a/tests/data/test-data/MaxMind-DB-test-mixed-24.mmdb b/tests/data/test-data/MaxMind-DB-test-mixed-24.mmdb
index a16a00e..267aeb7 100644
Binary files a/tests/data/test-data/MaxMind-DB-test-mixed-24.mmdb and b/tests/data/test-data/MaxMind-DB-test-mixed-24.mmdb differ
diff --git a/tests/data/test-data/MaxMind-DB-test-mixed-28.mmdb b/tests/data/test-data/MaxMind-DB-test-mixed-28.mmdb
index e6bdfd3..1c911b5 100644
Binary files a/tests/data/test-data/MaxMind-DB-test-mixed-28.mmdb and b/tests/data/test-data/MaxMind-DB-test-mixed-28.mmdb differ
diff --git a/tests/data/test-data/MaxMind-DB-test-mixed-32.mmdb b/tests/data/test-data/MaxMind-DB-test-mixed-32.mmdb
index 8bb88e8..71eb765 100644
Binary files a/tests/data/test-data/MaxMind-DB-test-mixed-32.mmdb and b/tests/data/test-data/MaxMind-DB-test-mixed-32.mmdb differ
diff --git a/tests/data/test-data/MaxMind-DB-test-nested.mmdb b/tests/data/test-data/MaxMind-DB-test-nested.mmdb
index 891d065..f2dddf9 100644
Binary files a/tests/data/test-data/MaxMind-DB-test-nested.mmdb and b/tests/data/test-data/MaxMind-DB-test-nested.mmdb differ
diff --git a/tests/database_test.py b/tests/database_test.py
index 21c622d..52887b3 100644
--- a/tests/database_test.py
+++ b/tests/database_test.py
@@ -87,8 +87,7 @@ class BaseTestReader(object):
self.assertEqual(record.ip_address, ip_address)
self.assertRegex(
- str(record),
- r'geoip2.models.ASN\(.*1\.128\.0\.0.*\)',
+ str(record), r'geoip2.models.ASN\(.*1\.128\.0\.0.*\)',
'str representation is correct')
self.assertEqual(record, eval(repr(record)), "ASN repr can be eval'd")
@@ -102,9 +101,11 @@ class BaseTestReader(object):
self.assertEqual(record.country.name, 'United Kingdom',
'The default locale is en')
-
+ self.assertEqual(record.country.is_in_european_union, True)
self.assertEqual(record.location.accuracy_radius, 100,
'The accuracy_radius is populated')
+ self.assertEqual(record.registered_country.is_in_european_union, False)
+
reader.close()
def test_connection_type(self):
@@ -120,8 +121,7 @@ class BaseTestReader(object):
str(record), r'ConnectionType\(\{.*Cable/DSL.*\}\)',
'ConnectionType str representation is reasonable')
- self.assertEqual(record,
- eval(repr(record)),
+ self.assertEqual(record, eval(repr(record)),
"ConnectionType repr can be eval'd")
reader.close()
@@ -132,6 +132,8 @@ class BaseTestReader(object):
record = reader.country('81.2.69.160')
self.assertEqual(record.traits.ip_address, '81.2.69.160',
'IP address is added to model')
+ self.assertEqual(record.country.is_in_european_union, True)
+ self.assertEqual(record.registered_country.is_in_european_union, False)
reader.close()
def test_domain(self):
@@ -147,8 +149,8 @@ class BaseTestReader(object):
str(record), r'Domain\(\{.*maxmind.com.*\}\)',
'Domain str representation is reasonable')
- self.assertEqual(record,
- eval(repr(record)), "Domain repr can be eval'd")
+ self.assertEqual(record, eval(repr(record)),
+ "Domain repr can be eval'd")
reader.close()
@@ -160,7 +162,10 @@ class BaseTestReader(object):
self.assertEqual(record.city.confidence, 11)
self.assertEqual(record.country.confidence, 99)
self.assertEqual(record.country.geoname_id, 6252001)
+ self.assertEqual(record.country.is_in_european_union, False)
self.assertEqual(record.location.accuracy_radius, 27)
+ self.assertEqual(record.registered_country.is_in_european_union,
+ False)
self.assertEqual(record.traits.connection_type, 'Cable/DSL')
self.assertTrue(record.traits.is_legitimate_proxy)
self.assertEqual(record.traits.ip_address, ip_address)
diff --git a/tests/models_test.py b/tests/models_test.py
index 5a84c4b..48a0e79 100644
--- a/tests/models_test.py
+++ b/tests/models_test.py
@@ -79,6 +79,7 @@ class TestModels(unittest.TestCase):
},
'represented_country': {
'geoname_id': 3,
+ 'is_in_european_union': True,
'iso_code': 'GB',
'names': {
'en': 'United Kingdom'
@@ -163,24 +164,27 @@ class TestModels(unittest.TestCase):
r'^geoip2.models.Insights\(\{.*geoname_id.*\}, \[.*en.*\]\)',
'Insights str representation looks reasonable')
- self.assertEqual(model,
- eval(repr(model)), "Insights repr can be eval'd")
+ self.assertEqual(model, eval(repr(model)),
+ "Insights repr can be eval'd")
self.assertRegex(
str(model.location), r'^geoip2.records.Location\(.*longitude=.*\)',
'Location str representation is reasonable')
- self.assertEqual(model.location,
- eval(repr(model.location)),
+ self.assertEqual(model.location, eval(repr(model.location)),
"Location repr can be eval'd")
- self.assertTrue(model.traits.is_anonymous)
- self.assertTrue(model.traits.is_anonymous_proxy)
- self.assertTrue(model.traits.is_anonymous_vpn)
- self.assertTrue(model.traits.is_hosting_provider)
- self.assertTrue(model.traits.is_public_proxy)
- self.assertTrue(model.traits.is_satellite_provider)
- self.assertTrue(model.traits.is_tor_exit_node)
+ self.assertIs(model.country.is_in_european_union, False)
+ self.assertIs(model.registered_country.is_in_european_union, False)
+ self.assertIs(model.represented_country.is_in_european_union, True)
+
+ self.assertIs(model.traits.is_anonymous, True)
+ self.assertIs(model.traits.is_anonymous_proxy, True)
+ self.assertIs(model.traits.is_anonymous_vpn, True)
+ self.assertIs(model.traits.is_hosting_provider, True)
+ self.assertIs(model.traits.is_public_proxy, True)
+ self.assertIs(model.traits.is_satellite_provider, True)
+ self.assertIs(model.traits.is_tor_exit_node, True)
def test_insights_min(self):
model = geoip2.models.Insights({'traits': {'ip_address': '5.6.7.8'}})
diff --git a/tests/webservice_test.py b/tests/webservice_test.py
index 95e9851..c333f27 100644
--- a/tests/webservice_test.py
+++ b/tests/webservice_test.py
@@ -44,6 +44,14 @@ class TestClient(unittest.TestCase):
'maxmind': {
'queries_remaining': 11
},
+ 'registered_country': {
+ 'geoname_id': 2,
+ 'is_in_european_union': True,
+ 'iso_code': 'DE',
+ 'names': {
+ 'en': 'Germany'
+ }
+ },
'traits': {
'ip_address': '1.2.3.4'
},
@@ -59,7 +67,9 @@ class TestClient(unittest.TestCase):
self.base_uri + 'country/1.2.3.4',
json=self.country,
status_code=200,
- headers={'Content-Type': self._content_type('country')})
+ headers={
+ 'Content-Type': self._content_type('country')
+ })
country = self.client.country('1.2.3.4')
self.assertEqual(
type(country), geoip2.models.Country,
@@ -71,6 +81,8 @@ class TestClient(unittest.TestCase):
'continent name is North America')
self.assertEqual(country.country.geoname_id, 1,
'country geoname_id is 1')
+ self.assertIs(country.country.is_in_european_union, False,
+ 'country is_in_european_union is False')
self.assertEqual(country.country.iso_code, 'US',
'country iso_code is US')
self.assertEqual(country.country.names,
@@ -79,6 +91,8 @@ class TestClient(unittest.TestCase):
'country name is United States of America')
self.assertEqual(country.maxmind.queries_remaining, 11,
'queries_remaining is 11')
+ self.assertIs(country.registered_country.is_in_european_union, True,
+ 'registered_country is_in_european_union is True')
self.assertEqual(country.raw, self.country, 'raw response is correct')
@requests_mock.mock()
@@ -87,7 +101,9 @@ class TestClient(unittest.TestCase):
self.base_uri + 'country/me',
json=self.country,
status_code=200,
- headers={'Content-Type': self._content_type('country')})
+ headers={
+ 'Content-Type': self._content_type('country')
+ })
implicit_me = self.client.country()
self.assertEqual(
type(implicit_me), geoip2.models.Country,
@@ -102,7 +118,9 @@ class TestClient(unittest.TestCase):
mock.get(
self.base_uri + 'country/1.1.1.1',
status_code=200,
- headers={'Content-Type': self._content_type('country')})
+ headers={
+ 'Content-Type': self._content_type('country')
+ })
with self.assertRaisesRegex(GeoIP2Error,
'could not decode the response as JSON'):
self.client.country('1.1.1.1')
@@ -119,7 +137,9 @@ class TestClient(unittest.TestCase):
self.base_uri + 'country/' + '1.2.3.7',
text='',
status_code=400,
- headers={'Content-Type': self._content_type('country')})
+ headers={
+ 'Content-Type': self._content_type('country')
+ })
with self.assertRaisesRegex(
HTTPError, 'Received a 400 error for .* with no body'):
self.client.country('1.2.3.7')
@@ -130,7 +150,9 @@ class TestClient(unittest.TestCase):
self.base_uri + 'country/' + '1.2.3.8',
text='{"wierd": 42}',
status_code=400,
- headers={'Content-Type': self._content_type('country')})
+ headers={
+ 'Content-Type': self._content_type('country')
+ })
with self.assertRaisesRegex(HTTPError,
'Response contains JSON but it does not '
'specify code or error keys'):
@@ -142,7 +164,9 @@ class TestClient(unittest.TestCase):
self.base_uri + 'country/' + '1.2.3.9',
text='bad body',
status_code=400,
- headers={'Content-Type': self._content_type('country')})
+ headers={
+ 'Content-Type': self._content_type('country')
+ })
with self.assertRaisesRegex(
HTTPError, 'it did not include the expected JSON body'):
self.client.country('1.2.3.9')
@@ -159,7 +183,9 @@ class TestClient(unittest.TestCase):
mock.get(
self.base_uri + 'country/' + '1.2.3.11',
status_code=300,
- headers={'Content-Type': self._content_type('country')})
+ headers={
+ 'Content-Type': self._content_type('country')
+ })
with self.assertRaisesRegex(HTTPError,
'Received a very surprising HTTP status '
'\(300\) for'):
@@ -214,7 +240,9 @@ class TestClient(unittest.TestCase):
self.base_uri + 'country/1.2.3.18',
json=body,
status_code=status,
- headers={'Content-Type': self._content_type('country')})
+ headers={
+ 'Content-Type': self._content_type('country')
+ })
with self.assertRaisesRegex(error_class, msg):
self.client.country('1.2.3.18')
@@ -227,7 +255,9 @@ class TestClient(unittest.TestCase):
self.base_uri + 'country/' + ip,
json=body,
status_code=400,
- headers={'Content-Type': self._content_type('country')})
+ headers={
+ 'Content-Type': self._content_type('country')
+ })
with self.assertRaisesRegex(InvalidRequestError, msg):
self.client.country(ip)
@@ -237,7 +267,9 @@ class TestClient(unittest.TestCase):
self.base_uri + 'country/' + '1.2.3.4',
json=self.country,
status_code=200,
- headers={'Content-Type': self._content_type('country')})
+ headers={
+ 'Content-Type': self._content_type('country')
+ })
self.client.country('1.2.3.4')
request = mock.request_history[-1]
@@ -256,7 +288,9 @@ class TestClient(unittest.TestCase):
self.base_uri + 'city/' + '1.2.3.4',
json=self.country,
status_code=200,
- headers={'Content-Type': self._content_type('city')})
+ headers={
+ 'Content-Type': self._content_type('city')
+ })
city = self.client.city('1.2.3.4')
self.assertEqual(
type(city), geoip2.models.City, 'return value of client.city')
@@ -267,7 +301,9 @@ class TestClient(unittest.TestCase):
self.base_uri + 'insights/1.2.3.4',
json=self.country,
status_code=200,
- headers={'Content-Type': self._content_type('country')})
+ headers={
+ 'Content-Type': self._content_type('country')
+ })
insights = self.client.insights('1.2.3.4')
self.assertEqual(
type(insights), geoip2.models.Insights,
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-geoip2.git
More information about the Python-modules-commits
mailing list