From d3051cf55c71de519e0ec07a2cb4725e1b407606 Mon Sep 17 00:00:00 2001 From: HladczukLe Date: Sun, 10 Dec 2023 19:11:49 -0300 Subject: [PATCH] test(apps/tasks): add test --- apps/tasks/tests.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/apps/tasks/tests.py b/apps/tasks/tests.py index 44e23de..e539282 100644 --- a/apps/tasks/tests.py +++ b/apps/tasks/tests.py @@ -560,6 +560,23 @@ def test_upload_file_form_valid(self) -> None: self.assertTrue(form.is_valid()) + def test_upload_form_valid(self) -> None: + file_content = b"Test file content" + + upload_form = SimpleUploadedFile("test_file.txt", file_content) + + form_data = {"title": "Test Title"} + files_data = MultiValueDict( + {"file": [cast(UploadedFile, upload_form)]} + ) + + form = UploadFileForm(data=form_data, files=files_data) + + if not form.is_valid(): + print(form.errors) + + self.assertTrue(form.is_valid()) + class BackgroundJobTaskTest(TestCase): def setUp(self) -> None: