forked from DGNum/gestioCOF
More general forbidden test
This commit is contained in:
parent
6adfaba8e9
commit
c14c2d54a5
2 changed files with 51 additions and 18 deletions
|
@ -79,10 +79,15 @@ class TestCaseMixin:
|
|||
self.assertEqual(response.status_code, 200)
|
||||
try:
|
||||
form = response.context[form_ctx]
|
||||
self.assertIn("Permission refusée", form.non_field_errors())
|
||||
errors = [y for x in form.errors.as_data().values() for y in x]
|
||||
self.assertTrue(any(e.code == "permission-denied" for e in errors))
|
||||
except (AssertionError, AttributeError, KeyError):
|
||||
messages = [str(msg) for msg in response.context["messages"]]
|
||||
self.assertIn("Permission refusée", messages)
|
||||
self.assertTrue(
|
||||
any(
|
||||
"permission-denied" in msg.tags
|
||||
for msg in response.context["messages"]
|
||||
)
|
||||
)
|
||||
except AssertionError:
|
||||
request = response.wsgi_request
|
||||
raise AssertionError(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue