mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-05 17:48:25 -04:00
Fixed the is_active() method on the Users model, if the user was pending they would come back as active, allowing a user to sign in before being active. There is still a problem with the validate_sms_code and validate_email_code method.
19 lines
921 B
Python
19 lines
921 B
Python
from app.main.dao import services_dao
|
|
from app.main.forms import AddServiceForm
|
|
from tests.app.main import create_test_user
|
|
|
|
|
|
def test_form_should_have_errors_when_duplicate_service_is_added(notifications_admin,
|
|
notifications_admin_db,
|
|
notify_db_session):
|
|
with notifications_admin.test_request_context(method='POST',
|
|
data={'service_name': 'some service'}) as req:
|
|
user = create_test_user('active')
|
|
services_dao.insert_new_service('some service', user)
|
|
req.session['user_id'] = user.id
|
|
form = AddServiceForm(req.request.form)
|
|
assert form.validate() is False
|
|
assert len(form.errors) == 1
|
|
expected = {'service_name': ['Duplicate service name']}
|
|
assert form.errors == expected
|