Exemple #1
0
    def test_from_request_returns_none_if_authuser_is_none(self):
        from paildocket.models import User

        fake_request = DummyObject()
        fake_request.authenticated_userid = None

        returned = User.from_request(fake_request)
        assert returned is None
Exemple #2
0
    def test_from_request(self, db_session):
        from paildocket.models import User

        alice = User(
            username=ALICE,
            password_hash=ALICE_HASH,
            email=ALICE_EMAIL,
        )
        db_session.add(alice)
        db_session.flush()

        fake_request = DummyObject()
        fake_request.db_session = db_session
        fake_request.authenticated_userid = alice.id

        returned = User.from_request(fake_request)
        assert returned is alice