Skip to content

Commit

Permalink
Create test_special_value_file_format.py
Browse files Browse the repository at this point in the history
  • Loading branch information
malenelu authored and GitHub Enterprise committed Apr 1, 2025
1 parent ce0fa19 commit 6d83cae
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions backend/tests/test_special_value_file_format.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""
TC_004 - Special value test for uploading a valid and invalid file to a workout.
"""
def test_file_upload_special_value(self):
# Creates a PDF-file
pdf_file = SimpleUploadedFile("pdf_file.pdf")
# Creates a DOCX-file
docx_file = SimpleUploadedFile("docx_file.docx")
# Creates AthleteFile object with the files
athlete_pdf_file = AthleteFile(athlete=self.user, owner=self.user, file=pdf_file)
athlete_docx_file = AthleteFile(athlete=self.user, owner=self.user, file=docx_file)

try:
# Runs validation check for PDF-file
athlete_pdf_file.full_clean()
except ValidationError as e:
# Fails if any validation errors are raised
self.fail(f"ValidationError raised: {e}")

try:
# Runs validation check for DOCX-file
athlete_pdf_file.full_clean()
# Fails if no validation errors are raised
self.fail("ValidationError not raised for file of format DOCX.")
except ValidationError as e:
# Passes if validation error is raised.
self.assertIn('file', e.message_dict)

0 comments on commit 6d83cae

Please sign in to comment.