Beispiel #1
0
 def test_fails_with_duplicate_email(self) -> None:
     with self.app.app_context():
         create_user(
             email=self.email,
             password='******',
         )
     with self.app.app_context():
         with pytest.raises(UserAlreadyExistsException):
             create_user(
                 email=self.email,
                 password='******',
             )
Beispiel #2
0
 def setUp(self) -> None:
     super().setUp()
     with self.app.app_context():
         user = create_user(
             email=self.email,
             password='******',
         )
         self.user_id = user.id
Beispiel #3
0
 def test_returned_user_has_id(self) -> None:
     with self.app.app_context():
         user = create_user(
             email=self.email,
             password='******',
         )
         assert user is not None
         assert user.id is not None
Beispiel #4
0
 def post(self, data: UserInput) -> ResponseReturnValue:
     try:
         user = create_user(
             email=data.email,
             password=data.password,
         )
         return response.ok(asdict(UserSchema.from_model(user)))
     except UserAlreadyExistsException:
         return response.bad_request(
             asdict(
                 SingleErrorSchema(
                     error=f'User with email {data.email} already exists')))
Beispiel #5
0
    def test_created_user_is_queryable(self) -> None:
        with self.app.app_context():
            user = create_user(
                email=self.email,
                password='******',
            )
            user_id = user.id

        with self.app.app_context():
            queried_user = db.session.query(User).filter(
                User.id == user_id, ).first()

            assert queried_user is not None