-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #356 from ajib6ept/add-test-leaderboard
[#347] add test for the leaderboard
- Loading branch information
Showing
5 changed files
with
106 additions
and
2 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
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
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
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 |
---|---|---|
@@ -0,0 +1,100 @@ | ||
from http import HTTPStatus | ||
|
||
from django.test import Client, TestCase | ||
from django.urls import reverse | ||
|
||
SEARCH_FORM_CONTEXT_NAME = "form_org" | ||
SEARCH_PARAM_ORG_EXISTS = { # noqa: WPS407 | ||
"search": "", | ||
"organizations": "hexlet", | ||
} | ||
SEARCH_PARAM_ORG_NOT_EXISTS = { # noqa: WPS407 | ||
"search": "", | ||
"organizations": "123456", | ||
} | ||
|
||
OBJECTS_KEY = 'contributor_list' | ||
|
||
|
||
class TestContributorLeaderboardViews(TestCase): | ||
"""Test the functional leaderboard.""" | ||
|
||
fixtures = [ | ||
"organizations", | ||
"repositories", | ||
"contributions", | ||
"issues", | ||
"contributors", | ||
"contributionlabel", | ||
"labels", | ||
] | ||
|
||
def setUp(self): | ||
"""Create a test database.""" | ||
self.client: Client = Client() | ||
|
||
def test_contributor_leaderboard_commits_view(self): | ||
response = self.client.get( | ||
reverse("contributors:leaderboard_commits"), | ||
) | ||
self.assertEqual(response.status_code, HTTPStatus.OK) | ||
self.assertIn(SEARCH_FORM_CONTEXT_NAME, response.context) | ||
|
||
def test_contributor_leaderboard_commits_methods(self): | ||
response = self.client.get( | ||
reverse("contributors:leaderboard_commits"), | ||
SEARCH_PARAM_ORG_NOT_EXISTS, | ||
) | ||
self.assertEqual(response.status_code, HTTPStatus.OK) | ||
self.assertEqual(len(response.context[OBJECTS_KEY]), 0) | ||
|
||
response = self.client.get( | ||
reverse("contributors:leaderboard_commits"), | ||
SEARCH_PARAM_ORG_EXISTS, | ||
) | ||
self.assertEqual(response.status_code, HTTPStatus.OK) | ||
self.assertNotEqual(len(response.context[OBJECTS_KEY]), 0) | ||
|
||
def test_contributor_leaderboard_prs_view(self): | ||
response = self.client.get( | ||
reverse("contributors:leaderboard_prs"), | ||
) | ||
self.assertEqual(response.status_code, HTTPStatus.OK) | ||
self.assertIn(SEARCH_FORM_CONTEXT_NAME, response.context) | ||
|
||
def test_contributor_leaderboard_prs_methods(self): | ||
response = self.client.get( | ||
reverse("contributors:leaderboard_prs"), | ||
SEARCH_PARAM_ORG_NOT_EXISTS, | ||
) | ||
self.assertEqual(response.status_code, HTTPStatus.OK) | ||
self.assertEqual(len(response.context[OBJECTS_KEY]), 0) | ||
|
||
response = self.client.get( | ||
reverse("contributors:leaderboard_prs"), | ||
SEARCH_PARAM_ORG_EXISTS, | ||
) | ||
self.assertEqual(response.status_code, HTTPStatus.OK) | ||
self.assertNotEqual(len(response.context[OBJECTS_KEY]), 0) | ||
|
||
def test_contributor_leaderboard_issues_view(self): | ||
response = self.client.get( | ||
reverse("contributors:leaderboard_issues"), | ||
) | ||
self.assertEqual(response.status_code, HTTPStatus.OK) | ||
self.assertIn(SEARCH_FORM_CONTEXT_NAME, response.context) | ||
|
||
def test_contributor_leaderboard_issues_methods(self): | ||
response = self.client.get( | ||
reverse("contributors:leaderboard_issues"), | ||
SEARCH_PARAM_ORG_NOT_EXISTS, | ||
) | ||
self.assertEqual(response.status_code, HTTPStatus.OK) | ||
self.assertEqual(len(response.context[OBJECTS_KEY]), 0) | ||
|
||
response = self.client.get( | ||
reverse("contributors:leaderboard_issues"), | ||
SEARCH_PARAM_ORG_EXISTS, | ||
) | ||
self.assertEqual(response.status_code, HTTPStatus.OK) | ||
self.assertNotEqual(len(response.context[OBJECTS_KEY]), 0) |
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