def test_creating_a_new_apiuser_and_save_it_to_the_database(self): ''' Start creating a new shopping ''' shopping = ShoppingModelTest._create_shopping() token = ApiUser.create_token(shopping.slug) # Check if user can be created and saved on the database user = self._create_user(shopping, token) # Now check if it can be found in the database all_users_in_database = ApiUser.objects.all() self.assertEquals(len(all_users_in_database), 1) only_user_in_database = all_users_in_database[0] # Now check its attributes self.assertEquals(only_user_in_database, user) self.assertEquals(only_user_in_database.nome, 'Usuario teste') self.assertEquals(only_user_in_database.email, '*****@*****.**') self.assertEquals(only_user_in_database.token, token) self.assertEquals(only_user_in_database.shopping, shopping)
def create_new_user(): shopping = ShoppingModelTest._create_shopping() token = ApiUser.create_token(shopping.slug) user = ApiUserModelTest._create_user(shopping, token) return user