Example #1
0
 def test_get_country_time_zones(self, country_code, expected_time_zones):
     """Verify that list of common country time zones dictionaries is returned"""
     expected_dict = [{
         'time_zone': time_zone,
         'description': get_display_time_zone(time_zone)
     } for time_zone in expected_time_zones]
     country_time_zones_dicts = get_country_time_zones(country_code)[:10]
     self.assertEqual(country_time_zones_dicts, expected_dict)
Example #2
0
 def test_get_country_time_zones(self, country_code, expected_time_zones):
     """Verify that list of common country time zones dictionaries is returned"""
     expected_dict = [
         {"time_zone": time_zone, "description": get_display_time_zone(time_zone)}
         for time_zone in expected_time_zones
     ]
     country_time_zones_dicts = get_country_time_zones(country_code)[:10]
     self.assertEqual(country_time_zones_dicts, expected_dict)
    def _display_time_zone_helper(self, time_zone_string):
        """
        Helper function to return all info from get_display_time_zone()
        """
        tz_str = get_display_time_zone(time_zone_string)
        time_zone = timezone(time_zone_string)
        tz_abbr = get_time_zone_abbr(time_zone)
        tz_offset = get_time_zone_offset(time_zone)

        return {'str': tz_str, 'abbr': tz_abbr, 'offset': tz_offset}
    def _display_time_zone_helper(self, time_zone_string):
        """
        Helper function to return all info from get_display_time_zone()
        """
        tz_str = get_display_time_zone(time_zone_string)
        time_zone = timezone(time_zone_string)
        tz_abbr = get_time_zone_abbr(time_zone)
        tz_offset = get_time_zone_offset(time_zone)

        return {'str': tz_str, 'abbr': tz_abbr, 'offset': tz_offset}
Example #5
0
 def test_get_country_time_zones(self, country_code, expected_time_zones):
     """
     Verify that list of common country time zones dictionaries is returned
     An unrecognized country code (e.g. AA) will return the list of common timezones
     """
     expected_dict = [{
         'time_zone': time_zone,
         'description': get_display_time_zone(time_zone)
     } for time_zone in expected_time_zones]
     country_time_zones_dicts = get_country_time_zones(country_code)[:10]
     assert country_time_zones_dicts == expected_dict
Example #6
0
def _get_time_zone_dictionary(time_zone_name):
    """
    Returns a dictionary of time zone information:

        * time_zone: Name of pytz time zone
        * description: Display version of time zone [e.g. US/Pacific (PST, UTC-0800)]

    :param time_zone_name (str): Name of pytz time zone
    """
    return {
        'time_zone': time_zone_name,
        'description': get_display_time_zone(time_zone_name),
    }
Example #7
0
def _get_time_zone_dictionary(time_zone_name):
    """
    Returns a dictionary of time zone information:

        * time_zone: Name of pytz time zone
        * description: Display version of time zone [e.g. US/Pacific (PST, UTC-0800)]

    :param time_zone_name (str): Name of pytz time zone
    """
    return {
        'time_zone': time_zone_name,
        'description': get_display_time_zone(time_zone_name),
    }
Example #8
0
 def test_get_country_time_zones(self, country_code, expected_time_zones):
     """
     Verify that list of common country time zones dictionaries is returned
     An unrecognized country code (e.g. AA) will return the list of common timezones
     """
     expected_dict = [
         {
             'time_zone': time_zone,
             'description': get_display_time_zone(time_zone)
         }
         for time_zone in expected_time_zones
     ]
     country_time_zones_dicts = get_country_time_zones(country_code)[:10]
     self.assertEqual(country_time_zones_dicts, expected_dict)
Example #9
0
 def _assert_time_zone_is_valid(self, time_zone_info):
     """ Asserts that the time zone is a valid pytz time zone """
     time_zone_name = time_zone_info['time_zone']
     self.assertIn(time_zone_name, common_timezones_set)
     self.assertEqual(time_zone_info['description'], get_display_time_zone(time_zone_name))
Example #10
0
 def _assert_time_zone_is_valid(self, time_zone_info):
     """ Asserts that the time zone is a valid pytz time zone """
     time_zone_name = time_zone_info['time_zone']
     assert time_zone_name in common_timezones_set
     assert time_zone_info['description'] == get_display_time_zone(
         time_zone_name)
Example #11
0
 def get_description(self, time_zone_name):
     """
     Returns the display version of time zone [e.g. US/Pacific (PST, UTC-0800)]
     """
     return get_display_time_zone(time_zone_name)
Example #12
0
 def get_description(self, time_zone_name):
     """
     Returns the display version of time zone [e.g. US/Pacific (PST, UTC-0800)]
     """
     return get_display_time_zone(time_zone_name)