From e43d5f97bb27d13bb75f22edd8fd2e19e2d22f8d Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Fri, 19 Apr 2019 14:54:48 +0100 Subject: First testing attempt --- pydis_site/apps/home/tests/__init__.py | 0 .../apps/home/tests/test_wiki_templatetags.py | 39 ++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 pydis_site/apps/home/tests/__init__.py create mode 100644 pydis_site/apps/home/tests/test_wiki_templatetags.py (limited to 'pydis_site/apps/home/tests') 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 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) -- cgit v1.2.3