def test_get_all_works(self): for i in range(self.before + 1, self.before + 4): self.userrepo.new(get_test_user(i)) all_users = self.userrepo.get() self.assertEqual(len(all_users), self.before + 3) for user in all_users: self.assertEqual(user.firstname, get_test_user()["firstname"])
def test_count_all_works(self): before = self.user_service.count('all') user = get_test_user(2) self.user_service.create(user["firstname"], user["lastname"], user["username"], user["password"]) after = self.user_service.count('all') self.assertEqual(after, before + 1)
def test_count_all_with_multiple_users_works(self): before = self.user_service.count('all') for i in range(1, 4): user = get_test_user(i) self.user_service.create(user["firstname"], user["lastname"], user["username"], user["password"]) after = self.user_service.count('all') self.assertEqual(after, before + 3)
def test_count_defaults_to_all(self): for i in range(1, 4): user = get_test_user(i) self.user_service.create(user["firstname"], user["lastname"], user["username"], user["password"]) users = self.user_service.get() count = self.user_service.count() self.assertEqual(count, len(users))
def setUp(self): connect_test_database() self.user_service = user_service self.memo_service = memo_service self.before = self.user_service.count() self.test_user = get_test_user(0) self.saved_user = self.user_service.create( self.test_user["firstname"], self.test_user["lastname"], self.test_user["username"], "password", )
def test_get_all_works(self): added_users = [] added_users.append(self.saved_user) for i in range(1, 4): user = get_test_user(i) added = self.user_service.create(user["firstname"], user["lastname"], user["username"], user["password"]) added_users.append(added) users = self.user_service.get() print(len(users), len(added_users)) for i in range(len(users)): self.assertEqual(users[i], added_users[i])
def test_update_duplicate_username_returns_none(self): test_user = get_test_user(2) self.user_service.create( test_user["firstname"], test_user["lastname"], test_user["username"], test_user["password"], ) updated_user = self.user_service.update(self.saved_user.id, self.saved_user.firstname, self.saved_user.lastname, test_user["username"], self.saved_user.password) self.assertIsNone(updated_user)
def setUp(self): self.user = get_test_user() self.new_user = User(firstname=self.user["firstname"], lastname=self.user["lastname"], username=self.user["username"], password=self.user["password"])
def setUp(self): connect_test_database() self.userrepo = user_repository self.before = self.userrepo.count() self.test_user = get_test_user(self.before + 1) # was + 1 self.saved_user = self.userrepo.new(self.test_user)
def test_new_user_with_existing_username_returns_none(self): duplicate_user = get_test_user(self.userrepo.count()) saved_duplicate_user = self.userrepo.new(duplicate_user) self.assertIsNone(saved_duplicate_user)
def test_count_all_with_multiple_added_works(self): for i in range(self.before + 1, self.before + 4): self.userrepo.new(get_test_user(i)) count = self.userrepo.count('all') users = self.userrepo.get() self.assertEqual(count, len(users))
def test_count_all_users(self): before = self.userrepo.count('all') self.userrepo.new(get_test_user()) self.assertEqual(self.userrepo.count('all'), before + 1)
def test_count_defaults_to_all_users(self): for i in range(self.before + 1, self.before + 4): self.userrepo.new(get_test_user(i)) count = self.userrepo.count() users = self.userrepo.get() self.assertEqual(count, len(users))
def test_get_defaults_get_all(self): for i in range(self.before + 1, self.before + 4): self.userrepo.new(get_test_user(i)) count = self.userrepo.count() users = self.userrepo.get() self.assertEqual(len(users), count)