Skip to content

Commit

Permalink
✅ [#4795] Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
robinmolen committed Dec 23, 2024
1 parent 2d11d04 commit cc51188
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/openforms/formio/tests/validation/test_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,10 +602,10 @@ def test_attach_upload_validates_unknown_file_type(self):
}

is_valid, errors = validate_formio_data(component, data, submission=submission)
error = extract_error(errors["foo"][0], "type")
error = extract_error(errors["foo"][0], "non_field_errors")

self.assertFalse(is_valid)
self.assertEqual(error.code, "blank")
self.assertEqual(error.code, "invalid")
self.assertEqual(
error,
_(
Expand Down
6 changes: 4 additions & 2 deletions src/openforms/tests/e2e/test_input_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ def test_unknown_file_type(self):
# The frontend validation will *not* create a TemporaryFileUpload,
# as the frontend will block the upload because of the invalid file type.
# However the user could do an handcrafted API call.
# For this reason, we manually create an invalid TemporaryFileUpload
# For this reason, we manually try to create an invalid TemporaryFileUpload
# and use it for the `api_value`:

with open(TEST_FILES / "unknown-type", "rb") as infile:
Expand All @@ -949,6 +949,8 @@ def test_unknown_file_type(self):
content=File(infile),
content_type="",
)
# Temporary file cannot be created, due to unknown type
self.assertEqual(TemporaryFileUpload.objects.count(), 0)

self.assertFileValidationIsAligned(
component,
Expand All @@ -967,7 +969,7 @@ def test_unknown_file_type(self):
)

# Make sure the frontend did not create one:
self.assertEqual(TemporaryFileUpload.objects.count(), 1)
self.assertEqual(TemporaryFileUpload.objects.count(), 0)


class SingleAddressNLTests(ValidationsTestCase):
Expand Down

0 comments on commit cc51188

Please sign in to comment.