diff options
author | 2019-04-19 14:54:48 +0100 | |
---|---|---|
committer | 2019-04-19 14:54:48 +0100 | |
commit | e43d5f97bb27d13bb75f22edd8fd2e19e2d22f8d (patch) | |
tree | aac7e5405fcf904cc481101a0bdf582ae57d68e9 /pydis_site/apps/home/tests | |
parent | Settings: PARENT_HOST will be added to ALLOWED_HOSTS in debug mode (diff) |
First testing attempt
Diffstat (limited to 'pydis_site/apps/home/tests')
-rw-r--r-- | pydis_site/apps/home/tests/__init__.py | 0 | ||||
-rw-r--r-- | pydis_site/apps/home/tests/test_wiki_templatetags.py | 39 |
2 files changed, 39 insertions, 0 deletions
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) |