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

Commit

Permalink
test: Problem test case
Browse files Browse the repository at this point in the history
  • Loading branch information
LuizaMaluf committed Nov 6, 2023
1 parent 7ab68db commit 82701c2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
7 changes: 6 additions & 1 deletion apps/contests/tests_contests.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,15 @@ def test_fieldsets(self) -> None:
self.assertEqual(self.contest_admin.fieldsets, expected_fieldsets)


class TestContestsUrls(TestCase):
class ContestsUrlsTestCase(TestCase):
def test_detail_url_resolves(self) -> None:
url = reverse("contests:detail", args=[1])
resolved_view_name = resolve(url).view_name
expected_view_name = "contests:detail"

self.assertEqual(resolved_view_name, expected_view_name)


class ContestViewsTesteCase(TestCase):
# tentar novamente depois
pass
29 changes: 28 additions & 1 deletion apps/problems/tests_problems.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,35 @@
from datetime import timedelta

from django.test import TestCase
from django.utils import timezone

from apps.contests.models import Contest
from apps.problems.models import Problem


class ProblemTestCase(TestCase):
pass
def test_is_accessible(self) -> None:
now = timezone.now()

start_time = now - timedelta(hours=1)
end_time = now + timedelta(hours=1)
contest = Contest(start_time=start_time, end_time=end_time)

problem = Problem(contest=contest)

self.assertTrue(problem.is_accessible)

contest.start_time = now - timedelta(hours=2)
contest.end_time = now - timedelta(hours=1)
contest.save()

self.assertTrue(problem.is_accessible)

contest.start_time = now + timedelta(hours=1)
contest.end_time = now + timedelta(hours=2)
contest.save()

self.assertFalse(problem.is_accessible)


class DetailViewTestCase(TestCase):
Expand Down

0 comments on commit 82701c2

Please sign in to comment.