mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-01 04:09:46 -04:00
19 lines
913 B
Python
19 lines
913 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()
|
|
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
|