mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-01-30 23:08:59 -06:00
Actually simpler
This commit is contained in:
@@ -862,69 +862,37 @@ class TestApiWorkflows(DirectoriesMixin, APITestCase):
|
|||||||
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
|
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
|
||||||
self.assertEqual(response.data["passwords"], passwords)
|
self.assertEqual(response.data["passwords"], passwords)
|
||||||
|
|
||||||
def test_password_action_no_passwords_field(self):
|
def test_password_action_invalid_passwords_field(self):
|
||||||
"""
|
"""
|
||||||
GIVEN:
|
GIVEN:
|
||||||
- Nothing
|
- Nothing
|
||||||
WHEN:
|
WHEN:
|
||||||
- A workflow password removal action is created with no passwords set
|
- A workflow password removal action is created with invalid passwords field
|
||||||
- A workflow password removal action is created with passwords set to empty string
|
|
||||||
THEN:
|
THEN:
|
||||||
- The required validation error is raised
|
- The required validation error is raised
|
||||||
"""
|
"""
|
||||||
response = self.client.post(
|
for payload in [
|
||||||
"/api/workflow_actions/",
|
{"type": WorkflowAction.WorkflowActionType.PASSWORD_REMOVAL},
|
||||||
{
|
{
|
||||||
"type": WorkflowAction.WorkflowActionType.PASSWORD_REMOVAL,
|
"type": WorkflowAction.WorkflowActionType.PASSWORD_REMOVAL,
|
||||||
|
"passwords": "",
|
||||||
},
|
},
|
||||||
)
|
{
|
||||||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
|
"type": WorkflowAction.WorkflowActionType.PASSWORD_REMOVAL,
|
||||||
self.assertIn(
|
"passwords": [],
|
||||||
"Passwords are required",
|
},
|
||||||
str(response.data["non_field_errors"][0]),
|
{
|
||||||
)
|
"type": WorkflowAction.WorkflowActionType.PASSWORD_REMOVAL,
|
||||||
response = self.client.post(
|
"passwords": ["", "password2"],
|
||||||
"/api/workflow_actions/",
|
},
|
||||||
json.dumps(
|
]:
|
||||||
{
|
response = self.client.post(
|
||||||
"type": WorkflowAction.WorkflowActionType.PASSWORD_REMOVAL,
|
"/api/workflow_actions/",
|
||||||
"passwords": "",
|
json.dumps(payload),
|
||||||
},
|
content_type="application/json",
|
||||||
),
|
)
|
||||||
content_type="application/json",
|
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
|
||||||
)
|
self.assertIn(
|
||||||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
|
"Passwords are required",
|
||||||
self.assertIn(
|
str(response.data["non_field_errors"][0]),
|
||||||
"Passwords are required",
|
)
|
||||||
str(response.data["non_field_errors"][0]),
|
|
||||||
)
|
|
||||||
response = self.client.post(
|
|
||||||
"/api/workflow_actions/",
|
|
||||||
json.dumps(
|
|
||||||
{
|
|
||||||
"type": WorkflowAction.WorkflowActionType.PASSWORD_REMOVAL,
|
|
||||||
"passwords": [],
|
|
||||||
},
|
|
||||||
),
|
|
||||||
content_type="application/json",
|
|
||||||
)
|
|
||||||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
|
|
||||||
self.assertIn(
|
|
||||||
"Passwords are required",
|
|
||||||
str(response.data["non_field_errors"][0]),
|
|
||||||
)
|
|
||||||
response = self.client.post(
|
|
||||||
"/api/workflow_actions/",
|
|
||||||
json.dumps(
|
|
||||||
{
|
|
||||||
"type": WorkflowAction.WorkflowActionType.PASSWORD_REMOVAL,
|
|
||||||
"passwords": ["", "password2"],
|
|
||||||
},
|
|
||||||
),
|
|
||||||
content_type="application/json",
|
|
||||||
)
|
|
||||||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
|
|
||||||
self.assertIn(
|
|
||||||
"Passwords are required",
|
|
||||||
str(response.data["non_field_errors"][0]),
|
|
||||||
)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user