diff options
Diffstat (limited to 'pydis_site')
| -rw-r--r-- | pydis_site/apps/home/tests.py | 9 | ||||
| -rw-r--r-- | pydis_site/apps/home/tests/__init__.py | 0 | ||||
| -rw-r--r-- | pydis_site/apps/home/tests/test_wiki_templatetags.py | 39 | 
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) | 
