コード例 #1
0
 def test_ids_for_address(self):
     ids = tztrout.tz_ids_for_address('US', state='California')
     self.assertEqual(ids, ['America/Los_Angeles'])
     ids = tztrout.tz_ids_for_address('US', state='CA')
     self.assertEqual(ids, ['America/Los_Angeles'])
     ids = tztrout.tz_ids_for_address('PL')
     self.assertEqual(ids, ['Europe/Warsaw'])
コード例 #2
0
ファイル: __init__.py プロジェクト: closeio/tz-trout
    def test_texas(self):
        """ Make sure TX is not counted as part of ET. """

        ids = tztrout.tz_ids_for_address('US', state='TX')
        ids2 = tztrout.tz_ids_for_address('US', state='Texas')
        ids3 = tztrout.tz_ids_for_phone('+12143334444')
        self.assertEqual(ids, ids2)
        self.assertEqual(ids, ids3)
        self.assertTrue(all(['Indiana' not in tz_id for tz_id in ids]))
        self.assert_only_one_us_tz(ids, 'CT')
コード例 #3
0
    def test_texas(self):
        """ Make sure TX is not counted as part of ET. """

        ids = tztrout.tz_ids_for_address('US', state='TX')
        ids2 = tztrout.tz_ids_for_address('US', state='Texas')
        ids3 = tztrout.tz_ids_for_phone('+12143334444')
        self.assertEqual(ids, ids2)
        self.assertEqual(ids, ids3)
        self.assertTrue(all(['Indiana' not in tz_id for tz_id in ids]))
        self.assert_only_one_us_tz(ids, 'CT')
コード例 #4
0
    def test_ids_for_address_with_zipcode(self):
        ids = tztrout.tz_ids_for_address('US',
                                         state='California',
                                         zipcode='94041')
        self.assertEqual(ids, ['America/Los_Angeles'])
        ids = tztrout.tz_ids_for_address('US', zipcode='94041')
        self.assertEqual(ids, ['America/Los_Angeles'])

        # make sure passing an int works, too
        ids = tztrout.tz_ids_for_address('US', zipcode=94041)
        self.assertEqual(ids, ['America/Los_Angeles'])

        # make sure passing an extended zipcode works as well
        ids = tztrout.tz_ids_for_address('US', zipcode='94041-1191')
        self.assertEqual(ids, ['America/Los_Angeles'])
コード例 #5
0
ファイル: __init__.py プロジェクト: closeio/tz-trout
    def test_ids_for_address_with_zipcode(self):
        ids = tztrout.tz_ids_for_address('US', state='California', zipcode='94041')
        self.assertEqual(ids, ['America/Los_Angeles'])
        ids = tztrout.tz_ids_for_address('US', zipcode='94041')
        self.assertEqual(ids, ['America/Los_Angeles'])

        # make sure passing an int works, too
        ids = tztrout.tz_ids_for_address('US', zipcode=94041)
        self.assertEqual(ids, ['America/Los_Angeles'])

        # make sure passing an extended zipcode works as well
        ids = tztrout.tz_ids_for_address('US', zipcode='94041-1191')
        self.assertEqual(ids, ['America/Los_Angeles'])

        # Invalid zipcode returns empty list
        ids = tztrout.tz_ids_for_address('US', zipcode='0000')
        self.assertEqual(ids, [])
コード例 #6
0
ファイル: __init__.py プロジェクト: closeio/tz-trout
 def test_australia_without_state_info(self):
     ids = tztrout.tz_ids_for_address('AU')
     expected_ids = ["Australia/Sydney", "Australia/Perth", "Australia/Darwin",
         "Australia/Adelaide", "Australia/Darwin", "Australia/Adelaide",
         "Australia/Hobart", "Australia/Melbourne", "Australia/Sydney",
         "Australia/Brisbane"
     ]
     for tz_id in expected_ids:
         self.assertTrue(tz_id in ids, tz_id + ' not present in the expected ids set')
コード例 #7
0
ファイル: __init__.py プロジェクト: closeio/tz-trout
 def test_canada_without_state_info(self):
     ids = tztrout.tz_ids_for_address('CA')
     expected_ids = [
         "America/Whitehorse", "America/Vancouver", "America/Yellowknife",
         "America/Edmonton", "America/Regina", "America/Winnipeg",
         "America/Iqaluit", "America/Toronto", #"America/Montreal", TODO re-add Montreal when pytz.country_timezones is fixed
         "America/Moncton", "America/Halifax", "America/St_Johns"
     ]
     for tz_id in expected_ids:
         self.assertTrue(tz_id in ids, tz_id + ' not present in the expected ids set')
コード例 #8
0
 def test_australia_without_state_info(self):
     ids = tztrout.tz_ids_for_address('AU')
     expected_ids = [
         "Australia/Sydney", "Australia/Perth", "Australia/Darwin",
         "Australia/Adelaide", "Australia/Darwin", "Australia/Adelaide",
         "Australia/Hobart", "Australia/Melbourne", "Australia/Sydney",
         "Australia/Brisbane"
     ]
     for tz_id in expected_ids:
         self.assertTrue(tz_id in ids,
                         tz_id + ' not present in the expected ids set')
コード例 #9
0
 def test_canada_without_state_info(self):
     ids = tztrout.tz_ids_for_address('CA')
     expected_ids = [
         "America/Whitehorse",
         "America/Vancouver",
         "America/Yellowknife",
         "America/Edmonton",
         "America/Regina",
         "America/Winnipeg",
         "America/Iqaluit",
         "America/Toronto",  #"America/Montreal", TODO re-add Montreal when pytz.country_timezones is fixed
         "America/Moncton",
         "America/Halifax",
         "America/St_Johns"
     ]
     for tz_id in expected_ids:
         self.assertTrue(tz_id in ids,
                         tz_id + ' not present in the expected ids set')
コード例 #10
0
    def test_major_cities_australia(self):

        # NSW - New South Wales
        # WA - Western Australia
        # NT - Northern Territory
        # SA - South Australia
        # TAS - Tasmania
        # VIC - Victoria
        # ACT - Australian Capital Territory
        # QLD - Queensland

        # Sydney, NSW
        ids = tztrout.tz_ids_for_address('AU', state='NSW', city='Sydney')
        ids2 = tztrout.tz_ids_for_phone('+61 27 333 4444')
        ids3 = tztrout.tz_ids_for_phone('+61 28 333 4444')
        ids4 = tztrout.tz_ids_for_phone('+61 29 333 4444')
        self.assertEqual(ids, ids2)
        self.assertEqual(ids, ids3)
        self.assertEqual(ids, ids4)
        self.assert_only_one_au_tz(ids, 'AET')

        # Perth, WA
        ids = tztrout.tz_ids_for_address('AU', state='WA', city='Perth')
        ids2 = tztrout.tz_ids_for_phone('+61 852 22 4444')
        ids3 = tztrout.tz_ids_for_phone('+61 853 22 4444')
        ids4 = tztrout.tz_ids_for_phone('+61 854 22 4444')
        ids5 = tztrout.tz_ids_for_phone('+61 861 22 4444')
        ids6 = tztrout.tz_ids_for_phone('+61 862 22 4444')
        ids7 = tztrout.tz_ids_for_phone('+61 863 22 4444')
        ids8 = tztrout.tz_ids_for_phone('+61 864 22 4444')
        ids9 = tztrout.tz_ids_for_phone('+61 865 22 4444')
        self.assertEqual(ids, ids2)
        self.assertEqual(ids, ids3)
        self.assertEqual(ids, ids4)
        self.assertEqual(ids, ids5)
        self.assertEqual(ids, ids6)
        self.assertEqual(ids, ids7)
        self.assertEqual(ids, ids8)
        self.assertEqual(ids, ids9)
        self.assert_only_one_au_tz(ids, 'AWT')

        # Darwin, NT
        ids = tztrout.tz_ids_for_address('AU', state='NT', city='Darwin')
        ids2 = tztrout.tz_ids_for_phone('+61 879 22 4444')
        ids3 = tztrout.tz_ids_for_phone('+61 889 22 4444')
        self.assertEqual(ids, ids2)
        self.assertEqual(ids, ids3)
        self.assert_only_one_au_tz(ids, 'ACT')

        # Eucla, WA - ignore for now
        # "Eucla and the surrounding area, notably Mundrabilla and Madura, use
        # the Central Western Time Zone of UTC+8:45. Although it has no official
        # sanction, it is universally observed in this area, stopping just to
        # the east of Caiguna.

        # Adelaide, SA
        ids = tztrout.tz_ids_for_address('AU', state='SA', city='Adelaide')
        ids2 = tztrout.tz_ids_for_phone('+61 870 22 4444')
        ids3 = tztrout.tz_ids_for_phone('+61 871 22 4444')
        ids4 = tztrout.tz_ids_for_phone('+61 872 22 4444')
        ids5 = tztrout.tz_ids_for_phone('+61 873 22 4444')
        ids6 = tztrout.tz_ids_for_phone('+61 874 22 4444')
        ids7 = tztrout.tz_ids_for_phone('+61 881 22 4444')
        ids8 = tztrout.tz_ids_for_phone('+61 882 22 4444')
        ids9 = tztrout.tz_ids_for_phone('+61 883 22 4444')
        ids10 = tztrout.tz_ids_for_phone('+61 884 22 4444')
        self.assertEqual(ids, ids2)
        self.assertEqual(ids, ids3)
        self.assertEqual(ids, ids4)
        self.assertEqual(ids, ids5)
        self.assertEqual(ids, ids6)
        self.assertEqual(ids, ids7)
        self.assertEqual(ids, ids8)
        self.assertEqual(ids, ids9)
        self.assertEqual(ids, ids10)
        self.assert_only_one_au_tz(ids, 'ACT')

        # Hobart, TAS
        ids = tztrout.tz_ids_for_address('AU', state='TAS', city='Hobart')
        ids2 = tztrout.tz_ids_for_phone('+61 361 22 4444')
        ids3 = tztrout.tz_ids_for_phone('+61 362 22 4444')
        self.assertEqual(ids, ids2)
        self.assertEqual(ids, ids3)
        self.assert_only_one_au_tz(ids, 'AET')

        # Melbourne, VIC
        ids = tztrout.tz_ids_for_address('AU', state='VIC', city='Melbourne')
        ids2 = tztrout.tz_ids_for_phone('+61 37 333 4444')
        ids3 = tztrout.tz_ids_for_phone('+61 38 333 4444')
        ids4 = tztrout.tz_ids_for_phone('+61 39 333 4444')
        self.assertEqual(ids, ids2)
        self.assertEqual(ids, ids3)
        self.assertEqual(ids, ids4)
        self.assert_only_one_au_tz(ids, 'AET')

        # Canberra, ACT
        ids = tztrout.tz_ids_for_address('AU', state='ACT', city='Canberra')
        ids2 = tztrout.tz_ids_for_phone('+61 251 22 4444')
        ids3 = tztrout.tz_ids_for_phone('+61 252 22 4444')
        ids4 = tztrout.tz_ids_for_phone('+61 261 22 4444')
        ids5 = tztrout.tz_ids_for_phone('+61 262 22 4444')
        self.assertEqual(ids, ids2)
        self.assertEqual(ids, ids3)
        self.assertEqual(ids, ids4)
        self.assertEqual(ids, ids5)
        self.assert_only_one_au_tz(ids, 'AET')

        # Brisbane, QLD
        ids = tztrout.tz_ids_for_address('AU', state='QLD', city='Brisbane')
        ids2 = tztrout.tz_ids_for_phone('+61 72 333 4444')
        ids3 = tztrout.tz_ids_for_phone('+61 73 333 4444')
        self.assertEqual(ids, ids2)
        self.assertEqual(ids, ids3)
        self.assert_only_one_au_tz(ids, 'AET')

        # Townsville, QLD
        ids = tztrout.tz_ids_for_address('AU', state='QLD', city='Brisbane')
        ids2 = tztrout.tz_ids_for_phone('+61 744 22 4444')
        ids3 = tztrout.tz_ids_for_phone('+61 745 22 4444')
        ids4 = tztrout.tz_ids_for_phone('+61 777 22 4444')
        self.assertEqual(ids, ids2)
        self.assertEqual(ids, ids3)
        self.assertEqual(ids, ids4)
        self.assert_only_one_au_tz(ids, 'AET')
コード例 #11
0
    def test_major_cities_canada(self):
        """ Make sure all the major cities match the right time zone (and the
        right time zone only). """

        # Toronto, Ontario
        ids = tztrout.tz_ids_for_address('CA', state='ON', city='Toronto')
        ids2 = tztrout.tz_ids_for_phone('+14163334444')
        self.assert_only_one_us_tz(ids, 'ET')
        self.assert_only_one_us_tz(ids2, 'ET')

        # Montreal, Quebec
        ids = tztrout.tz_ids_for_address('CA', state='QC', city='Montreal')
        ids2 = tztrout.tz_ids_for_phone('+15143334444')
        self.assert_only_one_us_tz(ids, 'ET')
        self.assert_only_one_us_tz(ids2, 'ET')

        # Calgary, Alberta
        ids = tztrout.tz_ids_for_address('CA', state='AB', city='Calgary')
        ids2 = tztrout.tz_ids_for_phone('+14033334444')
        self.assert_only_one_us_tz(ids, 'MT')
        self.assert_only_one_us_tz(ids2, 'MT')

        # Ottawa, Ontario
        ids = tztrout.tz_ids_for_address('CA', state='ON', city='Ottawa')
        ids2 = tztrout.tz_ids_for_phone('+13433334444')
        ids3 = tztrout.tz_ids_for_phone('+16133334444')
        self.assert_only_one_us_tz(ids, 'ET')
        self.assert_only_one_us_tz(ids2, 'ET')
        self.assert_only_one_us_tz(ids3, 'ET')

        # Edmonton, Alberta
        ids = tztrout.tz_ids_for_address('CA', state='AB', city='Edmonton')
        ids2 = tztrout.tz_ids_for_phone('+17803334444')
        self.assert_only_one_us_tz(ids, 'MT')
        self.assert_only_one_us_tz(ids2, 'MT')

        # Mississauga, Ontario
        ids = tztrout.tz_ids_for_address('CA', state='ON', city='Mississauga')
        ids2 = tztrout.tz_ids_for_phone('+12893334444')
        self.assert_only_one_us_tz(ids, 'ET')
        self.assert_only_one_us_tz(ids2, 'ET')

        # Winnipeg, Manitoba
        ids = tztrout.tz_ids_for_address('CA', state='MB', city='Winnipeg')
        ids2 = tztrout.tz_ids_for_phone('+14313334444')
        self.assert_only_one_us_tz(ids, 'CT')
        self.assert_only_one_us_tz(ids2, 'CT')

        # Vancouver, British Columbia
        ids = tztrout.tz_ids_for_address('CA', state='BC', city='Vancouver')
        ids2 = tztrout.tz_ids_for_phone('+16043334444')
        self.assert_only_one_us_tz(ids, 'PT')
        self.assert_only_one_us_tz(ids2, 'PT')

        # Halifax, Nova Scotia
        ids = tztrout.tz_ids_for_address('CA', state='NS', city='Halifax')
        ids2 = tztrout.tz_ids_for_phone('+19023334444')
        self.assert_only_one_us_tz(ids, 'AT')
        self.assert_only_one_us_tz(ids2, 'AT')

        # Saskatoon, Saskatchewan - CT that doesn't observe DST
        ids = tztrout.tz_ids_for_address('CA', state='SK', city='Saskatoon')
        ids2 = tztrout.tz_ids_for_phone('+13063334444')
        self.assert_only_one_us_tz(ids, 'CT')
        self.assert_only_one_us_tz(ids2, 'CT')
コード例 #12
0
ファイル: __init__.py プロジェクト: closeio/tz-trout
    def test_major_cities_us(self):
        """ Make sure all the major cities match the right time zone (and the
        right time zone only). """

        # New York
        ids = tztrout.tz_ids_for_address('US', state='NY', city='New York')
        ids2 = tztrout.tz_ids_for_phone('+12123334444')
        ids3 = tztrout.tz_ids_for_phone('+16463334444')
        self.assertEqual(ids, ids2)
        self.assertEqual(ids, ids3)
        self.assert_only_one_us_tz(ids, 'ET')

        # Los Angeles
        ids = tztrout.tz_ids_for_address('US', state='CA', city='Los Angeles')
        ids2 = tztrout.tz_ids_for_phone('+18183334444')
        self.assertEqual(ids, ids2)
        self.assert_only_one_us_tz(ids, 'PT')

        # Chicago
        ids = tztrout.tz_ids_for_address('US', state='IL', city='Chicago')
        ids2 = tztrout.tz_ids_for_phone('+16303334444')
        self.assertEqual(ids, ids2)
        self.assert_only_one_us_tz(ids, 'CT')

        # Houston
        ids = tztrout.tz_ids_for_address('US', state='TX', city='Houston')
        ids2 = tztrout.tz_ids_for_phone('+17133334444')
        self.assertEqual(ids, ids2)
        self.assert_only_one_us_tz(ids, 'CT')

        # Philadelphia
        ids = tztrout.tz_ids_for_address('US', state='PA', city='Philadelphia')
        ids2 = tztrout.tz_ids_for_phone('+12153334444')
        self.assertEqual(ids, ids2)
        self.assert_only_one_us_tz(ids, 'ET')

        # Phoenix
        ids = tztrout.tz_ids_for_address('US', state='AZ', city='Phoenix')
        ids2 = tztrout.tz_ids_for_phone('+16023334444')
        self.assertEqual(ids, ids2)
        self.assert_only_one_us_tz(ids, 'MT')

        # San Antonio
        ids = tztrout.tz_ids_for_address('US', state='TX', city='San Antonio')
        ids2 = tztrout.tz_ids_for_phone('+12103334444')
        self.assertEqual(ids, ids2)
        self.assert_only_one_us_tz(ids, 'CT')

        # San Diego
        ids = tztrout.tz_ids_for_address('US', state='CA', city='San Diego')
        ids2 = tztrout.tz_ids_for_phone('+16193334444')
        self.assertEqual(ids, ids2)
        self.assert_only_one_us_tz(ids, 'PT')

        # Dallas
        ids = tztrout.tz_ids_for_address('US', state='TX', city='Dallas')
        ids2 = tztrout.tz_ids_for_phone('+12143334444')
        self.assertEqual(ids, ids2)
        self.assert_only_one_us_tz(ids, 'CT')

        # San Jose
        ids = tztrout.tz_ids_for_address('US', state='CA', city='San Jose')
        ids2 = tztrout.tz_ids_for_phone('+14083334444')
        self.assertEqual(ids, ids2)
        self.assert_only_one_us_tz(ids, 'PT')

        # Austin
        ids = tztrout.tz_ids_for_address('US', state='TX', city='Austin')
        ids2 = tztrout.tz_ids_for_phone('+15123334444')
        self.assertEqual(ids, ids2)
        self.assert_only_one_us_tz(ids, 'CT')

        # Indianapolis
        ids = tztrout.tz_ids_for_address('US', state='IN', city='Indianapolis')
        ids2 = tztrout.tz_ids_for_phone('+13173334444')
        self.assertEqual(ids, ids2)
        self.assert_only_one_us_tz(ids, 'ET')

        # Jacksonville
        ids = tztrout.tz_ids_for_address('US', state='FL', city='Jacksonville')
        ids2 = tztrout.tz_ids_for_phone('+19043334444')
        self.assertEqual(ids, ids2)
        self.assert_only_one_us_tz(ids, 'ET')

        # San Francisco
        ids = tztrout.tz_ids_for_address('US', state='CA', city='San Francisco')
        ids2 = tztrout.tz_ids_for_phone('+14153334444')
        self.assertEqual(ids, ids2)
        self.assert_only_one_us_tz(ids, 'PT')

        # Columbus
        ids = tztrout.tz_ids_for_address('US', state='OH', city='Columbus')
        ids2 = tztrout.tz_ids_for_phone('+16143334444')
        self.assertEqual(ids, ids2)
        self.assert_only_one_us_tz(ids, 'ET')

        # Charlotte
        ids = tztrout.tz_ids_for_address('US', state='NC', city='Charlotte')
        ids2 = tztrout.tz_ids_for_phone('+17043334444')
        self.assertEqual(ids, ids2)
        self.assert_only_one_us_tz(ids, 'ET')

        # Fort Worth
        ids = tztrout.tz_ids_for_address('US', state='TX', city='Fort Worth')
        ids2 = tztrout.tz_ids_for_phone('+16823334444')
        self.assertEqual(ids, ids2)
        self.assert_only_one_us_tz(ids, 'CT')

        # Detroit
        ids = tztrout.tz_ids_for_address('US', state='MI', city='Detroit')
        ids2 = tztrout.tz_ids_for_phone('+13133334444')
        self.assertEqual(ids, ids2)
        self.assert_only_one_us_tz(ids, 'ET')

        # El Paso
        ids = tztrout.tz_ids_for_address('US', state='TX', city='El Paso')
        ids2 = tztrout.tz_ids_for_phone('+19153334444')
        self.assert_only_one_us_tz(ids, 'MT')
        self.assert_only_one_us_tz(ids2, 'MT')

        # Memphis
        ids = tztrout.tz_ids_for_address('US', state='TN', city='Memphis')
        ids2 = tztrout.tz_ids_for_phone('+19013334444')
        self.assert_only_one_us_tz(ids, 'CT')
        self.assert_only_one_us_tz(ids2, 'CT')

        # Denver
        ids = tztrout.tz_ids_for_address('US', state='CO', city='Denver')
        ids2 = tztrout.tz_ids_for_phone('+13033334444')
        self.assertEqual(ids, ids2)
        self.assert_only_one_us_tz(ids, 'MT')

        # Washington
        ids = tztrout.tz_ids_for_address('US', state='DC', city='Washington')
        ids2 = tztrout.tz_ids_for_phone('+12023334444')
        self.assert_only_one_us_tz(ids, 'ET')
        self.assert_only_one_us_tz(ids2, 'ET')
コード例 #13
0
ファイル: __init__.py プロジェクト: closeio/tz-trout
    def test_ids_for_address(self):
        ids = tztrout.tz_ids_for_address('US', state='California')
        self.assertEqual(ids, ['America/Los_Angeles'])
        ids = tztrout.tz_ids_for_address('US', state='CA')
        self.assertEqual(ids, ['America/Los_Angeles'])
        ids = tztrout.tz_ids_for_address('US', state='CA', city='')
        self.assertEqual(ids, ['America/Los_Angeles'])
        ids = tztrout.tz_ids_for_address('US', state='CA', city='Palo Alto')
        self.assertEqual(ids, ['America/Los_Angeles'])
        ids = tztrout.tz_ids_for_address('US', state='', city='Palo Alto')
        self.assertEqual(ids, ['America/Los_Angeles'])
        ids = tztrout.tz_ids_for_address('US', city='Palo Alto')
        self.assertEqual(ids, ['America/Los_Angeles'])

        ids = tztrout.tz_ids_for_address('US', state='', city='')
        self.assertTrue('America/Los_Angeles' in ids)
        self.assertTrue('America/New_York' in ids)

        ids = tztrout.tz_ids_for_address('US')
        self.assertTrue('America/Los_Angeles' in ids)
        self.assertTrue('America/New_York' in ids)

        ids = tztrout.tz_ids_for_address('PL')
        self.assertEqual(ids, ['Europe/Warsaw'])

        # Invalid state, assume any US tz
        ids = tztrout.tz_ids_for_address('US', state='XX')
        self.assertTrue('America/Los_Angeles' in ids)
        self.assertTrue('America/New_York' in ids)
        ids = tztrout.tz_ids_for_address('US', state='XX', city='')
        self.assertTrue('America/Los_Angeles' in ids)
        self.assertTrue('America/New_York' in ids)

        # Invalid city with state, ignore city
        ids = tztrout.tz_ids_for_address('US', state='CA', city='XX')
        self.assertEqual(ids, ['America/Los_Angeles'])

        # Invalid city without state, assume any US tz
        ids = tztrout.tz_ids_for_address('US', state='', city='XX')
        self.assertTrue('America/Los_Angeles' in ids)
        self.assertTrue('America/New_York' in ids)
        ids = tztrout.tz_ids_for_address('US', city='XX')
        self.assertTrue('America/Los_Angeles' in ids)
        self.assertTrue('America/New_York' in ids)
コード例 #14
0
    def test_major_cities_us(self):
        """ Make sure all the major cities match the right time zone (and the
        right time zone only). """

        # New York
        ids = tztrout.tz_ids_for_address('US', state='NY', city='New York')
        ids2 = tztrout.tz_ids_for_phone('+12123334444')
        ids3 = tztrout.tz_ids_for_phone('+16463334444')
        self.assertEqual(ids, ids2)
        self.assertEqual(ids, ids3)
        self.assert_only_one_us_tz(ids, 'ET')

        # Los Angeles
        ids = tztrout.tz_ids_for_address('US', state='CA', city='Los Angeles')
        ids2 = tztrout.tz_ids_for_phone('+18183334444')
        self.assertEqual(ids, ids2)
        self.assert_only_one_us_tz(ids, 'PT')

        # Chicago
        ids = tztrout.tz_ids_for_address('US', state='IL', city='Chicago')
        ids2 = tztrout.tz_ids_for_phone('+16303334444')
        self.assertEqual(ids, ids2)
        self.assert_only_one_us_tz(ids, 'CT')

        # Houston
        ids = tztrout.tz_ids_for_address('US', state='TX', city='Houston')
        ids2 = tztrout.tz_ids_for_phone('+17133334444')
        self.assertEqual(ids, ids2)
        self.assert_only_one_us_tz(ids, 'CT')

        # Philadelphia
        ids = tztrout.tz_ids_for_address('US', state='PA', city='Philadelphia')
        ids2 = tztrout.tz_ids_for_phone('+12153334444')
        self.assertEqual(ids, ids2)
        self.assert_only_one_us_tz(ids, 'ET')

        # Phoenix
        ids = tztrout.tz_ids_for_address('US', state='AZ', city='Phoenix')
        ids2 = tztrout.tz_ids_for_phone('+16023334444')
        self.assertEqual(ids, ids2)
        self.assert_only_one_us_tz(ids, 'MT')

        # San Antonio
        ids = tztrout.tz_ids_for_address('US', state='TX', city='San Antonio')
        ids2 = tztrout.tz_ids_for_phone('+12103334444')
        self.assertEqual(ids, ids2)
        self.assert_only_one_us_tz(ids, 'CT')

        # San Diego
        ids = tztrout.tz_ids_for_address('US', state='CA', city='San Diego')
        ids2 = tztrout.tz_ids_for_phone('+16193334444')
        self.assertEqual(ids, ids2)
        self.assert_only_one_us_tz(ids, 'PT')

        # Dallas
        ids = tztrout.tz_ids_for_address('US', state='TX', city='Dallas')
        ids2 = tztrout.tz_ids_for_phone('+12143334444')
        self.assertEqual(ids, ids2)
        self.assert_only_one_us_tz(ids, 'CT')

        # San Jose
        ids = tztrout.tz_ids_for_address('US', state='CA', city='San Jose')
        ids2 = tztrout.tz_ids_for_phone('+14083334444')
        self.assertEqual(ids, ids2)
        self.assert_only_one_us_tz(ids, 'PT')

        # Austin
        ids = tztrout.tz_ids_for_address('US', state='TX', city='Austin')
        ids2 = tztrout.tz_ids_for_phone('+15123334444')
        self.assertEqual(ids, ids2)
        self.assert_only_one_us_tz(ids, 'CT')

        # Indianapolis
        ids = tztrout.tz_ids_for_address('US', state='IN', city='Indianapolis')
        ids2 = tztrout.tz_ids_for_phone('+13173334444')
        self.assertEqual(ids, ids2)
        self.assert_only_one_us_tz(ids, 'ET')

        # Jacksonville
        ids = tztrout.tz_ids_for_address('US', state='FL', city='Jacksonville')
        ids2 = tztrout.tz_ids_for_phone('+19043334444')
        self.assertEqual(ids, ids2)
        self.assert_only_one_us_tz(ids, 'ET')

        # San Francisco
        ids = tztrout.tz_ids_for_address('US',
                                         state='CA',
                                         city='San Francisco')
        ids2 = tztrout.tz_ids_for_phone('+14153334444')
        self.assertEqual(ids, ids2)
        self.assert_only_one_us_tz(ids, 'PT')

        # Columbus
        ids = tztrout.tz_ids_for_address('US', state='OH', city='Columbus')
        ids2 = tztrout.tz_ids_for_phone('+16143334444')
        self.assertEqual(ids, ids2)
        self.assert_only_one_us_tz(ids, 'ET')

        # Charlotte
        ids = tztrout.tz_ids_for_address('US', state='NC', city='Charlotte')
        ids2 = tztrout.tz_ids_for_phone('+17043334444')
        self.assertEqual(ids, ids2)
        self.assert_only_one_us_tz(ids, 'ET')

        # Fort Worth
        ids = tztrout.tz_ids_for_address('US', state='TX', city='Fort Worth')
        ids2 = tztrout.tz_ids_for_phone('+16823334444')
        self.assertEqual(ids, ids2)
        self.assert_only_one_us_tz(ids, 'CT')

        # Detroit
        ids = tztrout.tz_ids_for_address('US', state='MI', city='Detroit')
        ids2 = tztrout.tz_ids_for_phone('+13133334444')
        self.assertEqual(ids, ids2)
        self.assert_only_one_us_tz(ids, 'ET')

        # El Paso
        ids = tztrout.tz_ids_for_address('US', state='TX', city='El Paso')
        ids2 = tztrout.tz_ids_for_phone('+19153334444')
        self.assert_only_one_us_tz(ids, 'MT')
        self.assert_only_one_us_tz(ids2, 'MT')

        # Memphis
        ids = tztrout.tz_ids_for_address('US', state='TN', city='Memphis')
        ids2 = tztrout.tz_ids_for_phone('+19013334444')
        self.assert_only_one_us_tz(ids, 'CT')
        self.assert_only_one_us_tz(ids2, 'CT')

        # Denver
        ids = tztrout.tz_ids_for_address('US', state='CO', city='Denver')
        ids2 = tztrout.tz_ids_for_phone('+13033334444')
        self.assertEqual(ids, ids2)
        self.assert_only_one_us_tz(ids, 'MT')

        # Washington
        ids = tztrout.tz_ids_for_address('US', state='DC', city='Washington')
        ids2 = tztrout.tz_ids_for_phone('+12023334444')
        self.assert_only_one_us_tz(ids, 'ET')
        self.assert_only_one_us_tz(ids2, 'ET')
コード例 #15
0
ファイル: __init__.py プロジェクト: closeio/tz-trout
    def test_major_cities_canada(self):
        """ Make sure all the major cities match the right time zone (and the
        right time zone only). """

        # Toronto, Ontario
        ids = tztrout.tz_ids_for_address('CA', state='ON', city='Toronto')
        ids2 = tztrout.tz_ids_for_phone('+14163334444')
        self.assert_only_one_us_tz(ids, 'ET')
        self.assert_only_one_us_tz(ids2, 'ET')

        # Montreal, Quebec
        ids = tztrout.tz_ids_for_address('CA', state='QC', city='Montreal')
        ids2 = tztrout.tz_ids_for_phone('+15143334444')
        self.assert_only_one_us_tz(ids, 'ET')
        self.assert_only_one_us_tz(ids2, 'ET')

        # Calgary, Alberta
        ids = tztrout.tz_ids_for_address('CA', state='AB', city='Calgary')
        ids2 = tztrout.tz_ids_for_phone('+14033334444')
        self.assert_only_one_us_tz(ids, 'MT')
        self.assert_only_one_us_tz(ids2, 'MT')

        # Ottawa, Ontario
        ids = tztrout.tz_ids_for_address('CA', state='ON', city='Ottawa')
        ids2 = tztrout.tz_ids_for_phone('+13433334444')
        ids3 = tztrout.tz_ids_for_phone('+16133334444')
        self.assert_only_one_us_tz(ids, 'ET')
        self.assert_only_one_us_tz(ids2, 'ET')
        self.assert_only_one_us_tz(ids3, 'ET')

        # Edmonton, Alberta
        ids = tztrout.tz_ids_for_address('CA', state='AB', city='Edmonton')
        ids2 = tztrout.tz_ids_for_phone('+17803334444')
        self.assert_only_one_us_tz(ids, 'MT')
        self.assert_only_one_us_tz(ids2, 'MT')

        # Mississauga, Ontario
        ids = tztrout.tz_ids_for_address('CA', state='ON', city='Mississauga')
        ids2 = tztrout.tz_ids_for_phone('+12893334444')
        self.assert_only_one_us_tz(ids, 'ET')
        self.assert_only_one_us_tz(ids2, 'ET')

        # Winnipeg, Manitoba
        ids = tztrout.tz_ids_for_address('CA', state='MB', city='Winnipeg')
        ids2 = tztrout.tz_ids_for_phone('+14313334444')
        self.assert_only_one_us_tz(ids, 'CT')
        self.assert_only_one_us_tz(ids2, 'CT')

        # Vancouver, British Columbia
        ids = tztrout.tz_ids_for_address('CA', state='BC', city='Vancouver')
        ids2 = tztrout.tz_ids_for_phone('+16043334444')
        self.assert_only_one_us_tz(ids, 'PT')
        self.assert_only_one_us_tz(ids2, 'PT')

        # Halifax, Nova Scotia
        ids = tztrout.tz_ids_for_address('CA', state='NS', city='Halifax')
        ids2 = tztrout.tz_ids_for_phone('+19023334444')
        self.assert_only_one_us_tz(ids, 'AT')
        self.assert_only_one_us_tz(ids2, 'AT')

        # Saskatoon, Saskatchewan - CT that doesn't observe DST
        ids = tztrout.tz_ids_for_address('CA', state='SK', city='Saskatoon')
        ids2 = tztrout.tz_ids_for_phone('+13063334444')
        self.assert_only_one_us_tz(ids, 'CT')
        self.assert_only_one_us_tz(ids2, 'CT')
コード例 #16
0
ファイル: __init__.py プロジェクト: closeio/tz-trout
    def test_major_cities_australia(self):

        # NSW - New South Wales
        # WA - Western Australia
        # NT - Northern Territory
        # SA - South Australia
        # TAS - Tasmania
        # VIC - Victoria
        # ACT - Australian Capital Territory
        # QLD - Queensland

        # Sydney, NSW
        ids = tztrout.tz_ids_for_address('AU', state='NSW', city='Sydney')
        ids2 = tztrout.tz_ids_for_phone('+61 27 333 4444')
        ids3 = tztrout.tz_ids_for_phone('+61 28 333 4444')
        ids4 = tztrout.tz_ids_for_phone('+61 29 333 4444')
        self.assertEqual(ids, ids2)
        self.assertEqual(ids, ids3)
        self.assertEqual(ids, ids4)
        self.assert_only_one_au_tz(ids, 'AET')

        # Perth, WA
        ids = tztrout.tz_ids_for_address('AU', state='WA', city='Perth')
        ids2 = tztrout.tz_ids_for_phone('+61 852 22 4444')
        ids3 = tztrout.tz_ids_for_phone('+61 853 22 4444')
        ids4 = tztrout.tz_ids_for_phone('+61 854 22 4444')
        ids5 = tztrout.tz_ids_for_phone('+61 861 22 4444')
        ids6 = tztrout.tz_ids_for_phone('+61 862 22 4444')
        ids7 = tztrout.tz_ids_for_phone('+61 863 22 4444')
        ids8 = tztrout.tz_ids_for_phone('+61 864 22 4444')
        ids9 = tztrout.tz_ids_for_phone('+61 865 22 4444')
        self.assertEqual(ids, ids2)
        self.assertEqual(ids, ids3)
        self.assertEqual(ids, ids4)
        self.assertEqual(ids, ids5)
        self.assertEqual(ids, ids6)
        self.assertEqual(ids, ids7)
        self.assertEqual(ids, ids8)
        self.assertEqual(ids, ids9)
        self.assert_only_one_au_tz(ids, 'AWT')

        # Darwin, NT
        ids = tztrout.tz_ids_for_address('AU', state='NT', city='Darwin')
        ids2 = tztrout.tz_ids_for_phone('+61 879 22 4444')
        ids3 = tztrout.tz_ids_for_phone('+61 889 22 4444')
        self.assertEqual(ids, ids2)
        self.assertEqual(ids, ids3)
        self.assert_only_one_au_tz(ids, 'ACT')

        # Eucla, WA - ignore for now
        # "Eucla and the surrounding area, notably Mundrabilla and Madura, use
        # the Central Western Time Zone of UTC+8:45. Although it has no official
        # sanction, it is universally observed in this area, stopping just to
        # the east of Caiguna.

        # Adelaide, SA
        ids = tztrout.tz_ids_for_address('AU', state='SA', city='Adelaide')
        ids2 = tztrout.tz_ids_for_phone('+61 870 22 4444')
        ids3 = tztrout.tz_ids_for_phone('+61 871 22 4444')
        ids4 = tztrout.tz_ids_for_phone('+61 872 22 4444')
        ids5 = tztrout.tz_ids_for_phone('+61 873 22 4444')
        ids6 = tztrout.tz_ids_for_phone('+61 874 22 4444')
        ids7 = tztrout.tz_ids_for_phone('+61 881 22 4444')
        ids8 = tztrout.tz_ids_for_phone('+61 882 22 4444')
        ids9 = tztrout.tz_ids_for_phone('+61 883 22 4444')
        ids10 = tztrout.tz_ids_for_phone('+61 884 22 4444')
        self.assertEqual(ids, ids2)
        self.assertEqual(ids, ids3)
        self.assertEqual(ids, ids4)
        self.assertEqual(ids, ids5)
        self.assertEqual(ids, ids6)
        self.assertEqual(ids, ids7)
        self.assertEqual(ids, ids8)
        self.assertEqual(ids, ids9)
        self.assertEqual(ids, ids10)
        self.assert_only_one_au_tz(ids, 'ACT')

        # Hobart, TAS
        ids = tztrout.tz_ids_for_address('AU', state='TAS', city='Hobart')
        ids2 = tztrout.tz_ids_for_phone('+61 361 22 4444')
        ids3 = tztrout.tz_ids_for_phone('+61 362 22 4444')
        self.assertEqual(ids, ids2)
        self.assertEqual(ids, ids3)
        self.assert_only_one_au_tz(ids, 'AET')

        # Melbourne, VIC
        ids = tztrout.tz_ids_for_address('AU', state='VIC', city='Melbourne')
        ids2 = tztrout.tz_ids_for_phone('+61 37 333 4444')
        ids3 = tztrout.tz_ids_for_phone('+61 38 333 4444')
        ids4 = tztrout.tz_ids_for_phone('+61 39 333 4444')
        self.assertEqual(ids, ids2)
        self.assertEqual(ids, ids3)
        self.assertEqual(ids, ids4)
        self.assert_only_one_au_tz(ids, 'AET')

        # Canberra, ACT
        ids = tztrout.tz_ids_for_address('AU', state='ACT', city='Canberra')
        ids2 = tztrout.tz_ids_for_phone('+61 251 22 4444')
        ids3 = tztrout.tz_ids_for_phone('+61 252 22 4444')
        ids4 = tztrout.tz_ids_for_phone('+61 261 22 4444')
        ids5 = tztrout.tz_ids_for_phone('+61 262 22 4444')
        self.assertEqual(ids, ids2)
        self.assertEqual(ids, ids3)
        self.assertEqual(ids, ids4)
        self.assertEqual(ids, ids5)
        self.assert_only_one_au_tz(ids, 'AET')

        # Brisbane, QLD
        ids = tztrout.tz_ids_for_address('AU', state='QLD', city='Brisbane')
        ids2 = tztrout.tz_ids_for_phone('+61 72 333 4444')
        ids3 = tztrout.tz_ids_for_phone('+61 73 333 4444')
        self.assertEqual(ids, ids2)
        self.assertEqual(ids, ids3)
        self.assert_only_one_au_tz(ids, 'AET')

        # Townsville, QLD
        ids = tztrout.tz_ids_for_address('AU', state='QLD', city='Brisbane')
        ids2 = tztrout.tz_ids_for_phone('+61 744 22 4444')
        ids3 = tztrout.tz_ids_for_phone('+61 745 22 4444')
        ids4 = tztrout.tz_ids_for_phone('+61 777 22 4444')
        self.assertEqual(ids, ids2)
        self.assertEqual(ids, ids3)
        self.assertEqual(ids, ids4)
        self.assert_only_one_au_tz(ids, 'AET')
コード例 #17
0
 def test_city_empty_string(self):
     ids = tztrout.tz_ids_for_address('US', state='California', city='')
     self.assertEqual(ids, ['America/Los_Angeles'])
コード例 #18
0
ファイル: __init__.py プロジェクト: closeio/tz-trout
 def test_city_empty_string(self):
     ids = tztrout.tz_ids_for_address('US', state='California', city='')
     self.assertEqual(ids, ['America/Los_Angeles'])
コード例 #19
0
    def test_ids_for_address(self):
        ids = tztrout.tz_ids_for_address('US', state='California')
        self.assertEqual(ids, ['America/Los_Angeles'])
        ids = tztrout.tz_ids_for_address('US', state='CA')
        self.assertEqual(ids, ['America/Los_Angeles'])
        ids = tztrout.tz_ids_for_address('US', state='CA', city='')
        self.assertEqual(ids, ['America/Los_Angeles'])
        ids = tztrout.tz_ids_for_address('US', state='CA', city='Palo Alto')
        self.assertEqual(ids, ['America/Los_Angeles'])
        ids = tztrout.tz_ids_for_address('US', state='', city='Palo Alto')
        self.assertEqual(ids, ['America/Los_Angeles'])
        ids = tztrout.tz_ids_for_address('US', city='Palo Alto')
        self.assertEqual(ids, ['America/Los_Angeles'])

        ids = tztrout.tz_ids_for_address('US', state='', city='')
        self.assertTrue('America/Los_Angeles' in ids)
        self.assertTrue('America/New_York' in ids)

        ids = tztrout.tz_ids_for_address('US')
        self.assertTrue('America/Los_Angeles' in ids)
        self.assertTrue('America/New_York' in ids)

        ids = tztrout.tz_ids_for_address('PL')
        self.assertEqual(ids, ['Europe/Warsaw'])

        # Invalid state, assume any US tz
        ids = tztrout.tz_ids_for_address('US', state='XX')
        self.assertTrue('America/Los_Angeles' in ids)
        self.assertTrue('America/New_York' in ids)
        ids = tztrout.tz_ids_for_address('US', state='XX', city='')
        self.assertTrue('America/Los_Angeles' in ids)
        self.assertTrue('America/New_York' in ids)

        # Invalid city with state, ignore city
        ids = tztrout.tz_ids_for_address('US', state='CA', city='XX')
        self.assertEqual(ids, ['America/Los_Angeles'])

        # Invalid city without state, assume any US tz
        ids = tztrout.tz_ids_for_address('US', state='', city='XX')
        self.assertTrue('America/Los_Angeles' in ids)
        self.assertTrue('America/New_York' in ids)
        ids = tztrout.tz_ids_for_address('US', city='XX')
        self.assertTrue('America/Los_Angeles' in ids)
        self.assertTrue('America/New_York' in ids)