Esempio n. 1
0
    async def test_regular_user(self, email: str,
                                user_manager: UserManagerMock):
        user = UserCreate(email=email, password="******")
        created_user = await user_manager.create(user)
        assert type(created_user) == UserDB

        assert user_manager.on_after_register.called is True
Esempio n. 2
0
 async def test_is_active(self, create_user, safe, result):
     user = UserCreate(email="[email protected]",
                       password="******",
                       is_active=False)
     created_user = await create_user(user, safe)
     assert type(created_user) == UserDB
     assert created_user.is_active is result
Esempio n. 3
0
 async def test_superuser(self, create_user, safe, result):
     user = UserCreate(phone="[email protected]",
                       password="******",
                       is_superuser=True)
     created_user = await create_user(user, safe)
     assert type(created_user) == UserDB
     assert created_user.is_superuser is result
Esempio n. 4
0
    async def test_is_active(self, user_manager: UserManagerMock, safe: bool,
                             result: bool):
        user = UserCreate(email="[email protected]",
                          password="******",
                          is_active=False)
        created_user = await user_manager.create(user, safe)
        assert type(created_user) == UserDB
        assert created_user.is_active is result

        assert user_manager.on_after_register.called is True
 async def test_invalid_password(self, test_app_client: httpx.AsyncClient,
                                 after_register, validate_password):
     json = {"email": "*****@*****.**", "password": "******"}
     response = await test_app_client.post("/register", json=json)
     assert response.status_code == status.HTTP_400_BAD_REQUEST
     data = cast(Dict[str, Any], response.json())
     assert data["detail"] == {
         "code": ErrorCode.REGISTER_INVALID_PASSWORD,
         "reason": "Password should be at least 3 characters",
     }
     validate_password.assert_called_with(
         "g", UserCreate(email="*****@*****.**", password="******"))
     assert after_register.called is False
Esempio n. 6
0
 async def test_regular_user(self, email, create_user):
     user = UserCreate(email=email, password="******")
     created_user = await create_user(user)
     assert type(created_user) == UserDB
Esempio n. 7
0
 async def test_existing_user(self, email, create_user):
     user = UserCreate(email=email, password="******")
     with pytest.raises(UserAlreadyExists):
         await create_user(user)
Esempio n. 8
0
 async def test_existing_user(self, email: str,
                              user_manager: UserManagerMock):
     user = UserCreate(email=email, password="******")
     with pytest.raises(UserAlreadyExists):
         await user_manager.create(user)
     assert user_manager.on_after_register.called is False
Esempio n. 9
0
 async def test_regular_user(self, phone, create_user):
     user = UserCreate(phone=phone, password="******")
     created_user = await create_user(user)
     assert type(created_user) == UserDB