From f9883e319f356c40b02004c935474f5d96cee65e Mon Sep 17 00:00:00 2001 From: Malene Lundemo Date: Tue, 1 Apr 2025 14:46:23 +0200 Subject: [PATCH] Create test_boundary_file_size.py --- backend/tests/test_boundary_file_size.py | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 backend/tests/test_boundary_file_size.py diff --git a/backend/tests/test_boundary_file_size.py b/backend/tests/test_boundary_file_size.py new file mode 100644 index 0000000..5984cdf --- /dev/null +++ b/backend/tests/test_boundary_file_size.py @@ -0,0 +1,31 @@ +""" +TC_002 - Boundary test for file size +""" +def test_file_size_boundary(self): + # Create file with minimum valid size (1 byte) + min_file = SimpleUploadedFile("min_file.txt", b"x" * 1) + + # Create file with minimum valid size (2 bytes) + min_plus_file = SimpleUploadedFile("min_plus_file.txt", b"x" * 2) + + # Create file with maximum valid size (5MB - 1 byte) + max_minus_file = SimpleUploadedFile("max_minus_file.txt", b"x" * (max_size - 1)) + + # Create file with maximum valid size (5MB) + max_file = SimpleUploadedFile("max_file.txt", b"x" * max_size) + + # Create AthleteFile objects with both files + athlete_min_file = AthleteFile(athlete=self.user, owner=self.user, file=min_file) + athlete_min_plus_file = AthleteFile(athlete=self.user, owner=self.user, file=min_plus_file) + athlete_max_minus_file = AthleteFile(athlete=self.user, owner=self.user, file=max_minus_file) + athlete_max_file = AthleteFile(athlete=self.user, owner=self.user, file=max_file) + + try: + # Runs validation checks + athlete_min_file.full_clean() + athlete_min_plus_file.full_clean() + athlete_max_minus_file.full_clean() + athlete_max_file.full_clean() + except ValidationError as e: + # Fails if any validation errors are raised + self.fail(f"ValidationError raised: {e}")