Exemplo n.º 1
0
 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))
Exemplo n.º 2
0
 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))
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
 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)
Exemplo n.º 5
0
 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))
Exemplo n.º 6
0
 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)