Skip to content

Commit

Permalink
Create test_boundary_file_size.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 8ce0c30 commit f9883e3
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions backend/tests/test_boundary_file_size.py
Original file line number Diff line number Diff line change
@@ -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}")

0 comments on commit f9883e3

Please sign in to comment.