def test_field_hour_is_integer(self, hour, expected): response = UserPayload().blend()\ .set_hour(hour)\ .post(code=expected) if expected == 422: response.assertRaiseJsonApiError('/data/attributes/hour') else: user = safe_query(self, User, 'id', response.id, 'id') self.assertEqual(user.hour, int(hour))
def test_home_longitude_as_decimal_degrees(self, longitude, expected): response = UserPayload().blend()\ .set_longitude(longitude)\ .post(code=expected) if expected == 422: response.assertRaiseJsonApiError('/data/attributes/longitude') else: user = safe_query(self, User, 'id', response.id, 'id') self.assertEqual(user.longitude, Decimal(longitude))
def test_countries_are_checked_against_static_list(self, country, expected): response = UserPayload().blend()\ .set_country(country)\ .post(code=expected) if expected == 422: response.assertRaiseJsonApiError('/data/attributes/country') else: response.assertHasAttribute('country', country)
def test_languages_are_checked_against_static_list(self, language, expected): response = UserPayload().blend()\ .set_language(language)\ .post(code=expected) if expected == 422: response.assertRaiseJsonApiError('/data/attributes/language') else: response.assertHasAttribute('language', language)
def test_field_observation_radius_is_integer(self, radius, expected): response = UserPayload().blend()\ .set_observation_radius(radius)\ .post(code=expected) if expected == 422: response.assertRaiseJsonApiError( '/data/attributes/observation-radius') else: user = safe_query(self, User, 'id', response.id, 'id') self.assertEqual(user.observation_radius, int(radius))
def test_field_daily_mails_is_boolean(self, value, expected_code, expected=False): response = UserPayload().blend()\ .set_daily_mails(value)\ .post(code=expected_code) if expected_code == 422: response.assertRaiseJsonApiError('/data/attributes/daily-mails') else: user = safe_query(self, User, 'id', response.id, 'id') self.assertEqual(user.daily_mails, expected)