aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Gareth Coles <[email protected]>2019-04-19 14:54:48 +0100
committerGravatar Gareth Coles <[email protected]>2019-04-19 14:54:48 +0100
commite43d5f97bb27d13bb75f22edd8fd2e19e2d22f8d (patch)
treeaac7e5405fcf904cc481101a0bdf582ae57d68e9
parentSettings: PARENT_HOST will be added to ALLOWED_HOSTS in debug mode (diff)
First testing attempt
-rw-r--r--pydis_site/apps/home/tests.py9
-rw-r--r--pydis_site/apps/home/tests/__init__.py0
-rw-r--r--pydis_site/apps/home/tests/test_wiki_templatetags.py39
3 files changed, 39 insertions, 9 deletions
diff --git a/pydis_site/apps/home/tests.py b/pydis_site/apps/home/tests.py
deleted file mode 100644
index 54fac6e8..00000000
--- a/pydis_site/apps/home/tests.py
+++ /dev/null
@@ -1,9 +0,0 @@
-from django.test import TestCase
-from django_hosts.resolvers import reverse
-
-
-class TestIndexReturns200(TestCase):
- def test_index_returns_200(self):
- url = reverse('index')
- resp = self.client.get(url)
- self.assertEqual(resp.status_code, 200)
diff --git a/pydis_site/apps/home/tests/__init__.py b/pydis_site/apps/home/tests/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/pydis_site/apps/home/tests/__init__.py
diff --git a/pydis_site/apps/home/tests/test_wiki_templatetags.py b/pydis_site/apps/home/tests/test_wiki_templatetags.py
new file mode 100644
index 00000000..af85339f
--- /dev/null
+++ b/pydis_site/apps/home/tests/test_wiki_templatetags.py
@@ -0,0 +1,39 @@
+from unittest.mock import Mock
+
+from django.test import TestCase
+from django.template import Template
+from wiki.models import URLPath as _URLPath
+
+
+URLPath = Mock(_URLPath)
+
+
+class TestURLPathFilter(TestCase):
+ TEMPLATE = Template(
+ """
+ {% load wiki_extra %}
+ {{ obj|render_urlpath }}
+ """
+ )
+
+ def test_str(self):
+ context = {"obj": "path"}
+ rendered = self.TEMPLATE.render(context)
+
+ def test_str_empty(self):
+ context = {"obj": ""}
+ rendered = self.TEMPLATE.render(context)
+
+ def test_urlpath(self):
+ url_path = URLPath()
+ url_path.path = None
+
+ context = {"obj": url_path}
+ rendered = self.TEMPLATE.render(context)
+
+ def test_urlpath_root(self):
+ url_path = URLPath()
+ url_path.path = "/path/"
+
+ context = {"obj": url_path}
+ rendered = self.TEMPLATE.render(context)