def __init__(self, location, country, zone, comments=None): """Initialise a new ``Zone`` object. :param str location: Primary location in ISO 6709 format :param str country: Location's ISO 3166 country code :param str zone: Location's zone name as used in zoneinfo database :param list comments: Location's alternate names """ latitude, longitude = utils.from_iso6709(location + "/")[:2] super(Zone, self).__init__(latitude, longitude) self.country = country self.zone = zone self.comments = comments
def __init__(self, location, country, zone, comments=None): """Initialise a new ``Zone`` object >>> Zone("+513030-0000731", 'GB', "Europe/London") Zone('+513030-0000730', 'GB', 'Europe/London', None) :type location: ``str`` :param location: Primary location in ISO 6709 format :type country: ``str`` :param country: Location's ISO 3166 country code :type zone: ``str`` :param zone: Location's zone name as used in zoneinfo databse :type comments: ``list`` :param comments: Location's alternate names """ latitude, longitude = utils.from_iso6709(location + "/")[:2] super(Zone, self).__init__(latitude, longitude) self.country = country self.zone = zone self.comments = comments
def test_from_iso6709_location_page(): # The following tests are from the Latitude, Longitude and Altitude format # for geospatial information page # (http://www.w3.org/2005/Incubator/geo/Wiki/LatitudeLongitudeAltitude) # Mount Everest expect(from_iso6709('+27.5916+086.5640+8850/')) == \ (27.5916, 86.564, 8850.0) # South Pole expect(from_iso6709('-90+000+2800/')) == (-90.0, 0.0, 2800.0) # New York City expect(from_iso6709('+40.75-074.00/')) == (40.75, -74.0, None) # Mount Fuji expect(from_iso6709('+352139+1384339+3776/')) == \ (35.36083333333333, 138.7275, 3776.0) # Tokyo Tower expect(from_iso6709('+35.658632+139.745411/')) == \ (35.658632, 139.745411, None) with expect.raises(ValueError, "Incorrect format for longitude '+1'"): from_iso6709('+35.658632+1/')
def test_from_iso6709_error(): with raises(ValueError, message="Incorrect format for longitude '+1'"): from_iso6709('+35.658632+1/')
def test_from_iso6709_location_page(string, result): # These tests are from the Latitude, Longitude and Altitude format for # geospatial information page # (http://www.w3.org/2005/Incubator/geo/Wiki/LatitudeLongitudeAltitude) assert from_iso6709(string) == result
def test_from_iso6709_wiki_page(string, result): # These tests are from the examples contained in the wikipedia ISO 6709 # page(http://en.wikipedia.org/wiki/ISO_6709) assert from_iso6709(string) == result
def test_from_iso6709_wiki_page(): # The following tests are from the examples contained in the wikipedia # ISO 6709 page(http://en.wikipedia.org/wiki/ISO_6709) # Atlantic Ocean expect(from_iso6709('+00-025/')) == (0.0, -25.0, None) # France expect(from_iso6709('+46+002/')) == (46.0, 2.0, None) # Paris expect(from_iso6709('+4852+00220/')) == \ (48.86666666666667, 2.3333333333333335, None) # Eiffel Tower expect(from_iso6709('+48.8577+002.295/')) == (48.8577, 2.295, None) # Mount Everest expect(from_iso6709('+27.5916+086.5640+8850/')) == \ (27.5916, 86.564, 8850.0) # North Pole expect(from_iso6709('+90+000/')) == (90.0, 0.0, None) # Pacific Ocean expect(from_iso6709('+00-160/')) == (0.0, -160.0, None) # South Pole expect(from_iso6709('-90+000+2800/')) == (-90.0, 0.0, 2800.0) # United States expect(from_iso6709('+38-097/')) == (38.0, -97.0, None) # New York City expect(from_iso6709('+40.75-074.00/')) == (40.75, -74.0, None) # Statue of Liberty expect(from_iso6709('+40.6894-074.0447/')) == (40.6894, -74.0447, None)