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

Commit

Permalink
test: Contest View test case
Browse files Browse the repository at this point in the history
  • Loading branch information
LuizaMaluf committed Nov 6, 2023
1 parent 62a80ff commit 6cf5eee
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
26 changes: 23 additions & 3 deletions apps/contests/tests_contests.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,26 @@ def test_detail_url_resolves(self) -> None:
self.assertEqual(resolved_view_name, expected_view_name)


class ContestViewsTesteCase(TestCase):
# tentar novamente depois
pass
class ContestViewTestCase(TestCase):
def setUp(self) -> None:
now = timezone.now()
self.contest = Contest(
id=1,
title="Test Contest",
description="This is a test contest",
start_time=now,
end_time=now + timedelta(hours=1),
cancelled=False,
)

def test_index_view(self) -> None:
response = self.client.get(reverse("contests:index"))
self.assertEqual(response.status_code, 200)
self.assertContains(response, "Test Contest")

def test_detail_view(self) -> None:
response = self.client.get(
reverse("contests:detail", args=[self.contest.id])
)
self.assertEqual(response.status_code, 200)
self.assertContains(response, "Test Contest")
6 changes: 3 additions & 3 deletions apps/problems/tests_problems.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,16 @@ def test_admin_fields(self) -> None:

class ProblemURLsTestCase(TestCase):
def test_detail_url_resolves_to_detail_view(self) -> None:
url = reverse("problems:detail", args=[int])
url = reverse("problems:detail", args=[1])

resolver = resolve(url)

self.assertEqual(resolver.url_name, DetailView)

def test_detail_url_reverse(self) -> None:
expected_url = "/problems/int/"
expected_url = "/problems/1/"

generated_url = reverse("problems:detail", args=[int])
generated_url = reverse("problems:detail", args=[1])

self.assertEqual(generated_url, expected_url)

Expand Down

0 comments on commit 6cf5eee

Please sign in to comment.