File: test_tz.py

package info (click to toggle)
pygeoip 0.3.2-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 240 kB
  • sloc: python: 1,835; makefile: 3
file content (25 lines) | stat: -rwxr-xr-x 762 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# -*- coding: utf-8 -*-
import unittest

import pygeoip
import pygeoip.timezone
from tests.config import CITY_DB_PATH


class TestGeoIPTimeZoneFunctions(unittest.TestCase):
    def setUp(self):
        self.gi = pygeoip.GeoIP(CITY_DB_PATH)

    def testTimeZoneInternals(self):
        tz = pygeoip.timezone.time_zone_by_country_and_region('XX')
        self.assertEquals(tz, None)

        tz = pygeoip.timezone.time_zone_by_country_and_region('US', 'NY')
        self.assertEquals(tz, 'America/New_York')

        tz = pygeoip.timezone.time_zone_by_country_and_region('US', 'XX')
        self.assertEquals(tz, None)

    def testTimeZoneByAddr(self):
        tz = self.gi.time_zone_by_addr('64.17.254.216')
        self.assertEquals(tz, 'America/Los_Angeles')