diff --git a/apps/contests/tests.py b/apps/contests/tests.py index 2ed2d12..0fc8f9d 100644 --- a/apps/contests/tests.py +++ b/apps/contests/tests.py @@ -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):