Example #1
0
    def test_unverified_user(self, db_client):
        db_client().get_doc.return_value = make_future(UNVERIFIED_USER)
        with patch.object(User, 'check_unique', return_value=make_future()):
            user = yield User.verify(UNVERIFIED_USER['_id'],
                                     UNVERIFIED_USER['verification_hash'])

        assert user.id == UNVERIFIED_USER['_id']
        assert user.state == State.approved
        assert 'verification_hash' not in user._resource
        db_client().save_doc.assert_called_once_with(user._resource)
Example #2
0
    def test_unverified_user(self, db_client):
        db_client().get_doc.return_value = make_future(UNVERIFIED_USER)
        with patch.object(User, 'check_unique', return_value=make_future()):
            user = yield User.verify(UNVERIFIED_USER['_id'],
                                     UNVERIFIED_USER['verification_hash'])

        assert user.id == UNVERIFIED_USER['_id']
        assert user.state == State.approved
        assert 'verification_hash' not in user._resource
        db_client().save_doc.assert_called_once_with(user._resource)
Example #3
0
    def test_invalid_hash(self, db_client):
        db_client().get_doc.return_value = make_future(UNVERIFIED_USER)
        with pytest.raises(exceptions.ValidationError):
            yield User.verify(UNVERIFIED_USER['_id'], 'something')

        assert not User.db_client().save_doc.called
Example #4
0
    def test_verified_user(self, db_client):
        db_client().get_doc.return_value = make_future(USERS[0])
        user = yield User.verify(USERS[0]['_id'], 'something')

        assert user.id == USERS[0]['_id']
        assert not User.db_client().save_doc.called
Example #5
0
    def test_invalid_hash(self, db_client):
        db_client().get_doc.return_value = make_future(UNVERIFIED_USER)
        with pytest.raises(exceptions.ValidationError):
            yield User.verify(UNVERIFIED_USER['_id'], 'something')

        assert not User.db_client().save_doc.called
Example #6
0
    def test_verified_user(self, db_client):
        db_client().get_doc.return_value = make_future(USERS[0])
        user = yield User.verify(USERS[0]['_id'], 'something')

        assert user.id == USERS[0]['_id']
        assert not User.db_client().save_doc.called