commit 22465e0ae238a6584a8549796f4dfbae21db73dc Author: Arturo Filastò art@fuffa.org Date: Thu Aug 7 18:21:11 2014 +0200
Add unittests for geoip database version --- ooni/tests/test_geoip.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/ooni/tests/test_geoip.py b/ooni/tests/test_geoip.py index b801cff..da7e47f 100644 --- a/ooni/tests/test_geoip.py +++ b/ooni/tests/test_geoip.py @@ -1,10 +1,8 @@ -import os
from twisted.internet import defer from twisted.trial import unittest
from ooni.tests import is_internet_connected -from ooni.settings import config from ooni import geoip
@@ -24,3 +22,14 @@ class TestGeoIP(unittest.TestCase): probe_ip = geoip.ProbeIP() res = yield probe_ip.lookup() assert len(res.split('.')) == 4 + + def test_geoip_database_version(self): + version = geoip.database_version() + assert 'GeoIP' in version.keys() + assert 'GeoIPASNum' in version.keys() + assert 'GeoLiteCity' in version.keys() + + assert len(version['GeoIP']['sha256']) == 64 + assert isinstance(version['GeoIP']['timestamp'], float) + assert len(version['GeoIPASNum']['sha256']) == 64 + assert isinstance(version['GeoIPASNum']['timestamp'], float)