Skip to content

Commit

Permalink
Test GeoIP2 from tox as well
Browse files Browse the repository at this point in the history
  • Loading branch information
Bouke committed Apr 17, 2017
1 parent 0de0d30 commit dc76371
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
5 changes: 2 additions & 3 deletions Makefile
Expand Up @@ -37,6 +37,5 @@ tx-push:
cd user_sessions; django-admin.py makemessages -l en
tx push -s

geoip:
wget http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz
gunzip GeoLite2-City.mmdb.gz
download-geoip:
if [ ! -f GeoLite2-City.mmdb ]; then wget http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz; gunzip GeoLite2-City.mmdb.gz; fi
3 changes: 1 addition & 2 deletions tests/settings.py
Expand Up @@ -63,8 +63,7 @@
},
]

GEOIP_PATH = os.path.join(os.path.dirname(BASE_DIR),
'example', 'GeoLiteCity.dat')
GEOIP_PATH = os.path.join(os.path.dirname(BASE_DIR), 'GeoLite2-City.mmdb')
SESSION_ENGINE = 'user_sessions.backends.db'

LOGIN_URL = '/admin/'
Expand Down
15 changes: 10 additions & 5 deletions tests/tests.py
Expand Up @@ -36,12 +36,17 @@
from unittest import skipUnless

try:
from django.contrib.gis.geoip import GeoIP
geoip = GeoIP()
from django.contrib.gis.geoip2 import GeoIP2
geoip = GeoIP2()
geoip_msg = None
except Exception as e:
geoip = None
geoip_msg = str(e)
except Exception as error_geoip2:
try:
from django.contrib.gis.geoip import GeoIP
geoip = GeoIP()
geoip_msg = None
except Exception as error_geoip:
geoip = None
geoip_msg = str(error_geoip2) + " and " + str(error_geoip)


class MiddlewareTest(TestCase):
Expand Down
6 changes: 4 additions & 2 deletions tox.ini
Expand Up @@ -13,15 +13,17 @@ unignore_outcomes = True
[travis:env]
DJANGO =
1.8: dj18
1.9: dj19
1.10: dj110
1.11: dj111
master: djmaster

[testenv]
commands = make coverage
commands =
make download-geoip
make coverage
deps =
coverage
geoip2
py27: mock
dj18: Django<1.9
dj110: Django<1.11
Expand Down

0 comments on commit dc76371

Please sign in to comment.