aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps
diff options
context:
space:
mode:
authorGravatar ks129 <[email protected]>2020-09-21 17:07:47 +0300
committerGravatar ks129 <[email protected]>2020-09-21 17:07:47 +0300
commitf22148f104b068ade88d677a07a20554ca466fe7 (patch)
tree780c843b5fed13ede575ea2b1fcfc4b840562d58 /pydis_site/apps
parentCreate tests for get_category guides utility function (diff)
Create tests for get_categories guides utility function
Diffstat (limited to 'pydis_site/apps')
-rw-r--r--pydis_site/apps/guides/tests/test_utils.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/pydis_site/apps/guides/tests/test_utils.py b/pydis_site/apps/guides/tests/test_utils.py
index f7ed3b62..a086cdaf 100644
--- a/pydis_site/apps/guides/tests/test_utils.py
+++ b/pydis_site/apps/guides/tests/test_utils.py
@@ -34,3 +34,22 @@ class TestGetCategory(TestCase):
p.return_value = path
with self.assertRaises(Http404):
utils.get_category("test.md")
+
+
+class TestGetCategories(TestCase):
+ def test_get_categories(self):
+ """Check does this return test guides categories."""
+ path = os.path.join(settings.BASE_DIR, "pydis_site", "apps", "guides", "tests", "test_guides")
+
+ side_effects = [path]
+ for name in os.listdir(path):
+ side_effects.append(os.path.join(path, name))
+ if os.path.isdir(os.path.join(path, name)):
+ side_effects.append(os.path.join(path, name))
+ side_effects.append(os.path.join(path, name, "_info.yml"))
+
+ with patch("pydis_site.apps.guides.utils.os.path.join") as p:
+ p.side_effect = side_effects
+ result = utils.get_categories()
+
+ self.assertEqual(result, {"category": {"name": "My Category", "description": "My Description"}})