コード例 #1
0
 def test_user_retrieved_passes_password_validation(self):
     user = User("testowy", "*****@*****.**")
     user.set_password("ocietrudnehaslo")
     repo = RedisUserRepository()
     user = run_sync(repo.save_user(user))
     retrieved_user = run_sync(repo.get_user_by_username(user.username))
     self.assertTrue(retrieved_user.check_password("ocietrudnehaslo"))
コード例 #2
0
 def test_user_retrieved_by_username(self):
     user = User("testowy", "*****@*****.**")
     repo = RedisUserRepository()
     user = run_sync(repo.save_user(user))
     retrieved_user = run_sync(repo.get_user_by_username(user.username))
     self.assertEqual(user.id, retrieved_user.id)
     self.assertEqual(user.username, retrieved_user.username)
     self.assertEqual(user.email, retrieved_user.email)
コード例 #3
0
 def test_user_auth_and_retrieved(self):
     auth = UserAuth(AuthProviders.SPOTIFY, "test", datetime(2030, 12, 10))
     repo = RedisUserAuthRepository()
     run_sync(repo.save_user_auth(1, auth))
     retrieved = run_sync(
         repo.get_auth_for_user_and_provider(1, AuthProviders.SPOTIFY)
     )
     self.assertEqual(auth, retrieved)
コード例 #4
0
    def test_retrieve_all_user_auth_none_found(self):
        repo = RedisUserAuthRepository()
        auth_1 = UserAuth(AuthProviders.SPOTIFY, "test", datetime(2030, 12, 10))
        auth_2 = UserAuth(AuthProviders.GOOGLE, "other", datetime(2030, 12, 10))
        run_sync(repo.save_user_auth(1, auth_1))
        run_sync(repo.save_user_auth(1, auth_2))

        retrieved = run_sync(repo.get_auth_for_user(2))
        self.assertEqual(retrieved, [])
コード例 #5
0
 def test_save_overwrites(self):
     repo = RedisUserAuthRepository()
     auth_1 = UserAuth(AuthProviders.SPOTIFY, "test", datetime(2030, 12, 10))
     auth_2 = UserAuth(AuthProviders.SPOTIFY, "other", datetime(2028, 12, 10))
     run_sync(repo.save_user_auth(1, auth_1))
     run_sync(repo.save_user_auth(1, auth_2))
     retrieved = run_sync(
         repo.get_auth_for_user_and_provider(1, AuthProviders.SPOTIFY)
     )
     self.assertEqual(auth_2, retrieved)
コード例 #6
0
 def test_user_auth_not_found(self):
     auth = UserAuth(AuthProviders.SPOTIFY, "test", datetime(2030, 12, 10))
     repo = RedisUserAuthRepository()
     run_sync(repo.save_user_auth(1, auth))
     retrieved = run_sync(
         repo.get_auth_for_user_and_provider(1, AuthProviders.GOOGLE)
     )
     self.assertIsNone(retrieved, None)
     retrieved = run_sync(
         repo.get_auth_for_user_and_provider(2, AuthProviders.SPOTIFY)
     )
     self.assertIsNone(retrieved, None)
コード例 #7
0
 def test_user_saved_with_id(self):
     user = User("testowy", "*****@*****.**")
     repo = RedisUserRepository()
     user = run_sync(repo.save_user(user))
     self.assertIsNotNone(user.id)
コード例 #8
0
 def test_user_not_found_by_username(self):
     user = User("testowy", "*****@*****.**")
     repo = RedisUserRepository()
     run_sync(repo.save_user(user))
     retrieved_user = run_sync(repo.get_user_by_username("xd"))
     self.assertIsNone(retrieved_user)