aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/content/tests
diff options
context:
space:
mode:
authorGravatar kosayoda <[email protected]>2021-03-23 17:17:22 +0800
committerGravatar kosayoda <[email protected]>2021-03-23 18:35:19 +0800
commit7de2959402a048652bf6d4ec8e3bec1172bb11e8 (patch)
treefb4c7397ef262ca60e6aa90315dc1ec9371398fe /pydis_site/apps/content/tests
parentStyle <pre> tag backgrounds same as <code>. (diff)
Remove Github metadata feature.
This feature is still under implementation debate, so it will be further discussed in another issue and implemeneted in a future PR.
Diffstat (limited to 'pydis_site/apps/content/tests')
-rw-r--r--pydis_site/apps/content/tests/test_utils.py40
-rw-r--r--pydis_site/apps/content/tests/test_views.py10
2 files changed, 1 insertions, 49 deletions
diff --git a/pydis_site/apps/content/tests/test_utils.py b/pydis_site/apps/content/tests/test_utils.py
index 85f1139a..26b2bba9 100644
--- a/pydis_site/apps/content/tests/test_utils.py
+++ b/pydis_site/apps/content/tests/test_utils.py
@@ -146,43 +146,3 @@ class TestGetArticle(TestCase):
"""Check does this raise Http404 when category don't exist."""
with self.assertRaises(Http404):
utils.get_article(["invalid", "some-guide"])
-
-
-class GetGitHubInformationTests(TestCase):
- @patch("pydis_site.apps.content.utils.requests.get")
- @patch("pydis_site.apps.content.utils.COMMITS_URL", "foobar")
- def test_call_get_github_information_requests_get(self, requests_get_mock):
- """Check does this call requests.get function with proper URL."""
- utils.get_github_information(["foo"])
- requests_get_mock.assert_called_once_with("foobar")
-
- @patch("pydis_site.apps.content.utils.requests.get")
- def test_github_status_code_200_response(self, requests_get_mock):
- """Check does this return provided modified date and contributors."""
- requests_get_mock.return_value = MagicMock(status_code=200)
- requests_get_mock.return_value.json.return_value = [{
- "commit": {
- "committer": {
- "date": datetime(2020, 10, 1).isoformat(),
- "name": "foobar",
- }
- },
- "committer": {
- "html_url": "abc1234"
- }
- }]
- result = utils.get_github_information(["foo"])
- self.assertEqual(result, {
- "last_modified": datetime(2020, 10, 1).strftime("%dth %B %Y"),
- "contributors": {"foobar": "abc1234"}
- })
-
- @patch("pydis_site.apps.content.utils.requests.get")
- def test_github_other_status_code_response(self, requests_get_mock):
- """Check does this return provided modified date and contributors."""
- requests_get_mock.return_value = MagicMock(status_code=404)
- result = utils.get_github_information(["foo"])
- self.assertEqual(result, {
- "last_modified": "N/A",
- "contributors": {}
- })
diff --git a/pydis_site/apps/content/tests/test_views.py b/pydis_site/apps/content/tests/test_views.py
index 98b99b83..55bfb8ea 100644
--- a/pydis_site/apps/content/tests/test_views.py
+++ b/pydis_site/apps/content/tests/test_views.py
@@ -30,8 +30,7 @@ class TestArticleOrCategoryView(TestCase):
@override_settings(ARTICLES_PATH=BASE_PATH)
@patch("pydis_site.apps.content.views.article_category.utils.get_article")
@patch("pydis_site.apps.content.views.article_category.utils.get_category")
- @patch("pydis_site.apps.content.views.article_category.utils.get_github_information")
- def test_article_return_code_200(self, gh_info_mock, get_category_mock, get_article_mock):
+ def test_article_return_code_200(self, get_category_mock, get_article_mock):
get_article_mock.return_value = {"guide": "test", "metadata": {}}
url = reverse("content:article_category", args=["test2"])
@@ -39,7 +38,6 @@ class TestArticleOrCategoryView(TestCase):
self.assertEqual(response.status_code, 200)
get_category_mock.assert_not_called()
get_article_mock.assert_called_once()
- gh_info_mock.assert_called_once()
@patch("pydis_site.apps.content.views.article_category.utils.get_article")
@patch("pydis_site.apps.content.views.article_category.utils.get_category")
@@ -99,11 +97,9 @@ class TestArticleOrCategoryView(TestCase):
@patch("pydis_site.apps.content.views.article_category.utils.get_article")
@patch("pydis_site.apps.content.views.article_category.utils.get_category")
- @patch("pydis_site.apps.content.views.article_category.utils.get_github_information")
@override_settings(ARTICLES_PATH=BASE_PATH)
def test_valid_category_article_code_200(
self,
- gh_info_mock,
get_category_mock,
get_article_mock
):
@@ -115,15 +111,12 @@ class TestArticleOrCategoryView(TestCase):
self.assertEqual(response.status_code, 200)
get_article_mock.assert_called_once()
self.assertEqual(get_category_mock.call_count, 2)
- gh_info_mock.assert_called_once()
@patch("pydis_site.apps.content.views.article_category.utils.get_article")
@patch("pydis_site.apps.content.views.article_category.utils.get_category")
- @patch("pydis_site.apps.content.views.article_category.utils.get_github_information")
@override_settings(ARTICLES_PATH=BASE_PATH)
def test_invalid_category_article_code_404(
self,
- gh_info_mock,
get_category_mock,
get_article_mock
):
@@ -135,7 +128,6 @@ class TestArticleOrCategoryView(TestCase):
self.assertEqual(response.status_code, 404)
get_article_mock.assert_not_called()
get_category_mock.assert_not_called()
- gh_info_mock.assert_not_called()
@override_settings(ARTICLES_PATH=BASE_PATH)
def test_article_category_template_names(self):