commit 3748ca57efcf7e1b084fcde0e03d979177257e7a Author: Arturo Filastò art@fuffa.org Date: Thu Jan 30 19:01:54 2014 +0100
Add tests for geoip --- ooni/tests/test_geoip.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
diff --git a/ooni/tests/test_geoip.py b/ooni/tests/test_geoip.py new file mode 100644 index 0000000..ac18a2e --- /dev/null +++ b/ooni/tests/test_geoip.py @@ -0,0 +1,22 @@ +from twisted.internet import defer +from twisted.trial import unittest + +from ooni.settings import config +from ooni import geoip + +class TestGeoIP(unittest.TestCase): + def setUp(self): + config.set_paths() + config.read_config_file() + + def test_ip_to_location(self): + location = geoip.IPToLocation('8.8.8.8') + assert location['countrycode'] == 'US' + assert location['asn'] == 'AS15169' + assert 'city' in location + + @defer.inlineCallbacks + def test_probe_ip(self): + probe_ip = geoip.ProbeIP() + res = yield probe_ip.lookup() + assert len(res.split('.')) == 4