forked from mathialm/secfit
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create test_special_value_file_format.py
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |