def test_for_valid_id_humanized_synonym(self, app): # Given user = User(email="*****@*****.**", publicName="bar") # When ApiHandler.save(user) # Then user_dict = as_dict(user) humanized_id = humanize(user.user_id) assert user_dict['id'] == humanized_id
def test_for_valid_synonym(self, app): # Given job = "foo" user = User(email="*****@*****.**", job=job, publicName="bar") # When ApiHandler.save(user) # Then assert user.metier == job assert user.job == job
def test_for_valid_many_to_many_relationship(self, app): # Given offerer = Offerer(name="foo", type="bar") user = User(email="*****@*****.**", publicName="bar") ApiHandler.save(user, offerer) user_offerer = UserOfferer(offerer=offerer, user=user) # When ApiHandler.save(user_offerer) # Then assert user_offerer.offererId == offerer.id assert user_offerer.userId == user.id
def test_save_user(self, app): # given user = User(firstName="Marx", email="*****@*****.**", lastName="Foo", publicName="Marx Foo") # when ApiHandler.save(user) # then saved_user = User.query.first() assert saved_user.firstName == "Marx"
def test_simple_dictify(self, app): # given user_fields_dict = { "email": "*****@*****.**", "firstName": "Marx", "lastName": "Foo", "publicName": "Marx Foo" } user = User(**user_fields_dict) # when user_dict = as_dict(user) # then assert set(user_fields_dict).issubset(user_dict)
def test_dictify_with_default_class_includes(self, app): # given user_fields_dict = { "email": "*****@*****.**", "firstName": "Marx", "lastName": "Foo", "metier": "philosophe", "publicName": "Marx Foo" } user = User(**user_fields_dict) # when user_dict = as_dict(user) # then assert 'metier' not in user_dict assert user_dict['job'] == user_fields_dict['metier']
def test_dictify_with_removing_includes(self, app): # given user_fields_dict = { "email": "*****@*****.**", "firstName": "Marx", "lastName": "Foo", "publicName": "Marx Foo" } user = User(**user_fields_dict) # when user_dict = as_dict(user, includes=["-email"]) # then user_fields_dict_without_email = dict(user_fields_dict) del user_fields_dict_without_email['email'] assert set(user_fields_dict_without_email).issubset(user_dict) assert 'email' not in user_dict
def test_user_string_fields_are_stripped_of_whitespace(self): # Given user_data = { 'email': ' [email protected]', 'firstName': 'John ', 'lastName': None, 'postalCode': ' 93100 ', 'publicName': '' } # When user = User(**user_data) # Then assert user.email == '*****@*****.**' assert user.firstName == 'John' assert user.lastName == None assert user.postalCode == '93100' assert user.publicName == ''