Skip to content

Commit

Permalink
add tests for govuk_errors
Browse files Browse the repository at this point in the history
  • Loading branch information
risicle authored and lfdebrux committed Dec 10, 2019
1 parent e88356c commit 1c9079d
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
Empty file added tests/forms/__init__.py
Empty file.
46 changes: 46 additions & 0 deletions tests/forms/test_errors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from collections import OrderedDict

import pytest

from dmutils.forms.errors import govuk_errors


@pytest.mark.parametrize("dm_errors,expected_output", (
({}, OrderedDict()),
(
OrderedDict((
("haddock", {
"input_name": "haddock",
"question": "What was that, Joe?",
"message": "Too numerous to be enumerated",
},),
("pollock", {},),
("flounder", {
"input_name": "flounder",
"question": "Anything strange or wonderful, Joe?",
"roach": "halibut",
},),
)),
OrderedDict((
("haddock", {
"input_name": "haddock",
"question": "What was that, Joe?",
"message": "Too numerous to be enumerated",
"text": "Too numerous to be enumerated",
"href": "#input-haddock",
"errorMessage": {"text": "Too numerous to be enumerated"},
},),
("pollock", {},),
("flounder", {
"input_name": "flounder",
"question": "Anything strange or wonderful, Joe?",
"roach": "halibut",
"text": "Anything strange or wonderful, Joe?",
"href": "#input-flounder",
"errorMessage": {"text": "Anything strange or wonderful, Joe?"},
},),
)),
),
))
def test_govuk_errors(dm_errors, expected_output):
assert govuk_errors(dm_errors) == expected_output

0 comments on commit 1c9079d

Please sign in to comment.