def test_register_email_taken(self, db, current_user): data = { 'email': current_user.email, 'first_name': 'Bilbo', 'last_name': 'Taggins', 'password': '******' } with record_messages() as outbox: response = client.post(app.url_path_for('register'), json=data) assert len(outbox) == 0 assert response.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY assert 'email already exists' in response.json()['detail'].lower()
def test_request_reset_password_not_verified(self, db): user = User(email='*****@*****.**', first_name='forgot', last_name='password', hashed_password='******') db.add(user) db.commit() data = {'email': user.email} with record_messages() as outbox: response = client.post(app.url_path_for('request_password_reset'), json=data) assert len(outbox) == 0 assert response.status_code == status.HTTP_200_OK
def test_register(self, db): data = { 'email': '*****@*****.**', 'first_name': 'Bilbo', 'last_name': 'Taggins', 'password': '******' } with record_messages() as outbox: response = client.post(app.url_path_for('register'), json=data) assert len(outbox) == 1 assert 'verify' in outbox[0].get('subject').lower() assert response.json()['email'] == data['email'] assert response.status_code == status.HTTP_201_CREATED assert db.query(exists().where(User.email == data['email'])).scalar()