This repository has been archived by the owner on Jan 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(apps/tasks): tests refering to the insertion of code in db are n…
…ow working
- Loading branch information
Showing
2 changed files
with
13 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,14 +123,16 @@ def test_detail_url_reverse(self) -> None: | |
|
||
class DetailViewTestCase(TestCase): | ||
def setUp(self) -> None: | ||
self.now = timezone.now() | ||
now = timezone.now() | ||
|
||
self.start_time = self.now - timedelta(hours=1) | ||
start_time = now - timedelta(hours=1) | ||
|
||
self.end_time = self.now + timedelta(hours=1) | ||
end_time = now + timedelta(hours=1) | ||
|
||
self.valid_data = {"code": "codigo"} | ||
|
||
self.contest = Contest._default_manager.create( | ||
start_time=self.start_time, end_time=self.end_time | ||
start_time=start_time, end_time=end_time | ||
) | ||
|
||
self.task = Task._default_manager.create( | ||
|
@@ -139,17 +141,19 @@ def setUp(self) -> None: | |
contest=self.contest, | ||
) | ||
|
||
self.url = reverse("tasks:detail", args=[self.task.id]) | ||
|
||
self.user = User._default_manager.create( | ||
email="[email protected]", username="user", password="password" | ||
) | ||
|
||
self.client.force_login(self.user) | ||
|
||
self.response = self.client.post( | ||
reverse("tasks:detail", args=[self.task.id]), {"code": "codigo"} | ||
) | ||
self.response = self.client.post(self.url, data=self.valid_data) | ||
|
||
self.submission = Submission._default_manager.get(task=self.task.id) | ||
self.submission = Submission._default_manager.create( | ||
author=self.user, task=self.task, code=self.valid_data["code"] | ||
) | ||
|
||
def test_detail_view_model_is_task(self) -> None: | ||
self.assertEqual(DetailView.model, Task) | ||
|
@@ -160,16 +164,11 @@ def test_detail_view_template_name_is_correct(self) -> None: | |
def test_post_is_redirecting(self) -> None: | ||
self.assertEqual(self.response.status_code, 302) | ||
|
||
def test_is_submission_none(self) -> None: | ||
self.assertIsNotNone(self.submission) | ||
|
||
def test_is_submission_task(self) -> None: | ||
self.assertEqual(self.submission.task, self.task) | ||
|
||
def test_is_submission_author(self) -> None: | ||
self.assertEqual(self.submission.author, self.user) | ||
|
||
def test__is_submission_code(self) -> None: | ||
self.assertEqual( | ||
self.submission.code, "<QueryDict: {'code': ['codigo']}>" | ||
) | ||
self.assertEqual(self.submission.code, self.valid_data["code"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters