def test_hemisphere_errors(self): """We don't validate the input, but we expect lat and lng to be floats rather than eg strings. It's not exactly intentional, but this test is documenting that behaviour. """ lat = '37°S' lng = '144°E' loc = location.Location(lat, lng) with pytest.raises(TypeError): _hemisphere = loc.hemisphere
def get_form(self, step=None, data=None, files=None): form = super(EventWizard, self).get_form(step, data, files) # determine the step if not given if step is None: step = self.steps.current if step == '1': latlng = self.get_cleaned_data_for_step('0')['location'] calendars = seasons.get_valid_calendars(location.Location(*latlng)) choices = [(c.name, c.name) for c in calendars] form.fields['calendar'] = forms.ChoiceField( choices=choices, widget=forms.RadioSelect) return form
def test_hemisphere(self, placename, expected): lat, lng = places[placename] loc = location.Location(lat, lng) assert loc.hemisphere == expected
def test_country_indonesia(self): lat, lng = 'pontianak' loc = location.Location(lat, lng) assert loc.country == 'Indonesia'
def test_country_australia(self): lat, lng = places['melbourne'] loc = location.Location(lat, lng) assert loc.country == 'Australia'
def test_country_argentina(self): lat, lng = places['buenos aires'] loc = location.Location(lat, lng) assert loc.country == 'Argentina'
def test_country_russia(self): lat, lng = places['murmansk'] loc = location.Location(lat, lng) assert loc.country == 'Russian Federation'
def test_country_uk(self): lat, lng = places['london'] loc = location.Location(lat, lng) assert loc.country == 'UK'
def test_hemisphere_melbourne(self): lat, lng = places['melbourne'] loc = location.Location(lat, lng) assert loc.hemisphere == 'northern'
def test_country_india(self): lat, lng = places['delhi'] loc = location.Location(lat, lng) assert loc.country == 'India'