Esempio n. 1
0
    def test_finds_by_email_returns_the_expected_user(self, database):
        user = User.create(first_name=self.first_name,
                           last_name=self.last_name,
                           email=self.email)

        assert User.query.count() == 1
        assert User.find_by_email('*****@*****.**') is None
        assert User.find_by_email(self.email) == user
Esempio n. 2
0
    def test_when_user_does_not_exists_and_all_details_correct_creates_user(
            self, database):
        assert User.find_by_email(self.details['email']) is None
        assert UserAuthenticationDetail.find_by_email_and_password(
            self.details['email'], self.details['password']) is None

        user_authentication_details = UserCreate.call(self.details)

        assert user_authentication_details is not None
        assert UserAuthenticationDetail.find_by_email_and_password(
            self.details['email'],
            self.details['password']) == user_authentication_details
        assert User.find_by_email(self.details['email']) == User.find_by_id(
            user_authentication_details.user_id)
Esempio n. 3
0
    def _get_receiver(self, email: str):
        user = User.find_by_email(email)

        if user is None:
            raise InvalidUser

        return user
Esempio n. 4
0
    def create_user(self):
        user = User.find_by_email(self.email)

        if user is None:
            user = User.create(self.first_name, self.last_name, self.email)

        return user
Esempio n. 5
0
    def test_when_user_exists_and_all_details_correct_return_existing_user(
            self, database):
        user_authentication_details = UserCreate.call(self.details)
        user = User.find_by_email(self.details['email'])

        assert user is not None
        assert user.id == user_authentication_details.user_id

        before_count_user = User.query.count()
        before_count_user_auth_details = UserAuthenticationDetail.query.count()

        new_user_authentication_details = UserCreate.call(self.details)

        assert User.query.count() == before_count_user
        assert UserAuthenticationDetail.query.count(
        ) == before_count_user_auth_details
        assert new_user_authentication_details == user_authentication_details