mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-15 07:18:58 -04:00
Move data transformation into the form
Follows what we’re doing with the folders stuff. Avoids having too many very straightforward methods on the model. Especially when the data they need is only used by the form. So it’s better to encapsulate the logic in the form.
This commit is contained in:
@@ -5,10 +5,12 @@ from app.main.forms import CreateKeyForm
|
||||
|
||||
|
||||
def test_return_validation_error_when_key_name_exists(client):
|
||||
def _get_names():
|
||||
return ['some key', 'another key']
|
||||
_existing_keys = [
|
||||
{'name': 'some key'},
|
||||
{'name': 'another key'},
|
||||
]
|
||||
|
||||
form = CreateKeyForm(_get_names(),
|
||||
form = CreateKeyForm(_existing_keys,
|
||||
formdata=MultiDict([('key_name', 'Some key')]))
|
||||
form.key_type.choices = [('a', 'a'), ('b', 'b')]
|
||||
form.validate()
|
||||
|
||||
Reference in New Issue
Block a user