예제 #1
0
def test_quirks():
    geodata = pysyge.GeoLocator(DATABASE_CITY_FILE, pysyge.MODE_MEMORY)
    result = geodata.get_location('49.206.213.75', detailed=True)
    assert result['city'] == ''
    assert result['country_iso'] == 'US'
    assert result['tz'] == ''
    assert result['info']['country']['name_en'] == 'United States'
예제 #2
0
    def test_location_detailed(self):
        geodata = pysyge.GeoLocator(DATABASE_CITY_FILE)
        location = geodata.get_location(BASE_IP, detailed=True)
        assert_location(location, detailed=True)

        locations = geodata.get_locations(BASE_IP)
        assert locations[0]['country_iso'] == 'RU'
예제 #3
0
파일: tests.py 프로젝트: yakovlevvs/pysyge
    def test_location_detailed(self):
        geodata = pysyge.GeoLocator(DATABASE_CITY_FILE)

        location = geodata.get_location(BASE_IP, detailed=True)
        self.assertIn('city', location)
        self.assertIn('country_id', location)
        self.assertIn('country_iso', location)
        self.assertIn('lon', location)
        self.assertIn('lat', location)
        self.assertIn('fips', location)
        self.assertIn('region_id', location)

        self.assertIn('region', location)
        self.assertIn('tz', location)

        self.assertEqual(location['city'], u'Москва')
        self.assertEqual(location['country_id'], 185)
        self.assertEqual(location['country_iso'], 'RU')
        self.assertEqual(location['lon'], 37.61556)
        self.assertEqual(location['lat'], 55.75222)
        self.assertEqual(location['fips'], '0')
        self.assertEqual(location['region_id'], 524894)

        self.assertEqual(location['region'], u'Москва')
        self.assertEqual(location['tz'], 'Europe/Moscow')
예제 #4
0
파일: tests.py 프로젝트: yakovlevvs/pysyge
    def test_location_basic(self):
        geodata = pysyge.GeoLocator(DATABASE_CITY_FILE, pysyge.MODE_MEMORY)

        location = geodata.get_location(BASE_IP)
        self.assertIn('city', location)
        self.assertIn('country_id', location)
        self.assertIn('country_iso', location)
        self.assertIn('lon', location)
        self.assertIn('lat', location)
        self.assertIn('fips', location)
        self.assertIn('region_id', location)

        self.assertNotIn('region', location)
        self.assertNotIn('tz', location)

        self.assertEqual(location['city'], u'Москва')
        self.assertEqual(location['country_id'], 185)
        self.assertEqual(location['country_iso'], 'RU')
        self.assertEqual(location['lon'], 37.61556)
        self.assertEqual(location['lat'], 55.75222)
        self.assertEqual(location['fips'], '0')
        self.assertEqual(location['region_id'], 0)
예제 #5
0
 def test_location_detailed(self):
     geodata = pysyge.GeoLocator(DATABASE_CITY_FILE, pysyge.MODE_BATCH)
     location = geodata.get_location(BASE_IP, detailed=True)
     assert_location(location, detailed=True)
예제 #6
0
 def test_location_basic(self):
     geodata = pysyge.GeoLocator(DATABASE_CITY_FILE, pysyge.MODE_BATCH)
     location = geodata.get_location(BASE_IP)
     assert_location(location)
예제 #7
0
 def test_localhost(self):
     geodata = pysyge.GeoLocator(DATABASE_CITY_FILE)
     assert geodata.get_location('127.0.0.1') is False
예제 #8
0
 def test_db_date(self):
     geodata = pysyge.GeoLocator(DATABASE_CITY_FILE)
     assert isinstance(geodata.get_db_date(), datetime.datetime)
예제 #9
0
 def test_db_version(self):
     geodata = pysyge.GeoLocator(DATABASE_CITY_FILE)
     assert geodata.get_db_version() >= 21
예제 #10
0
    def test_wrong_file(self):

        with pytest.raises(pysyge.GeoLocatorException):
            pysyge.GeoLocator('tests/test_module.py')
예제 #11
0
    def test_file_not_found(self):

        with pytest.raises(IOError):
            pysyge.GeoLocator('nosuchfile.dat')
예제 #12
0
 def test_invalid_ips(self):
     geodata = pysyge.GeoLocator(DATABASE_CITY_FILE)
     assert geodata.get_location('127.0.0.1') == {}
     assert geodata.get_location('80.8qeqw') == {}
예제 #13
0
    def test_wrong_file(self):

        with pytest.raises(pysyge.GeoLocatorException):
            pysyge.GeoLocator(path.join(DIR_CURRENT, 'test_module.py'))
예제 #14
0
파일: tests.py 프로젝트: yakovlevvs/pysyge
 def test_localhost(self):
     geodata = pysyge.GeoLocator(DATABASE_CITY_FILE)
     self.assertEqual(geodata.get_location('127.0.0.1'), False)
예제 #15
0
파일: tests.py 프로젝트: yakovlevvs/pysyge
 def test_db_version(self):
     geodata = pysyge.GeoLocator(DATABASE_CITY_FILE)
     self.assertGreaterEqual(geodata.get_db_version(), 21)