Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Commit

Permalink
feat(validators): contest status form validator tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LuizaMaluf committed Nov 14, 2023
1 parent 5a24e8d commit 2afddf1
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions apps/contests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,18 @@ def test_cancelled(self) -> None:
self.assertEqual(ContestStatus.CANCELLED, "Cancelled")

def test_valid_status(self) -> None:
valid_status = ContestStatus.RUNNING
self.assertIsNone(ContestStatus.validate_contest_status(valid_status))

def test_invalid_status(self) -> None:
invalid_status = "InvalidStatus"
with self.assertRaises(ValueError) as context:
ContestStatus.validate_contest_status(
ContestStatus(invalid_status)
)
expected_message = (
f"Invalid contest status: {invalid_status}. "
f"Must be one of {list(ContestStatus.__members__.values())}"
)
actual_message = str(context.exception)
self.assertEqual(expected_message, actual_message)
valid_statuses = [
ContestStatus.PENDING,
ContestStatus.RUNNING,
ContestStatus.FINISHED,
ContestStatus.CANCELLED,
]

for status in valid_statuses:
with self.subTest(status=status):
self.assertIsNone(
ContestStatus.validate_contest_status(status)
)


class ContestModelFormTestCase(TestCase):
Expand Down

0 comments on commit 2afddf1

Please sign in to comment.