diff options
Diffstat (limited to 'app/pages/tests/test_models.py')
-rw-r--r-- | app/pages/tests/test_models.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/app/pages/tests/test_models.py b/app/pages/tests/test_models.py new file mode 100644 index 0000000..2722430 --- /dev/null +++ b/app/pages/tests/test_models.py @@ -0,0 +1,36 @@ +from django.test import TestCase + +from pages.models import Page + + +class PageModelTest(TestCase): + def setUp(self): + self.page = Page( + title="Test Page", + meta_description="The meta desc", + body_markdown="the body of the page", + ) + self.page.save() + self.pathpage = Page( + title="Test Page", + meta_description="The meta desc", + body_markdown="the body of the page", + path="test-path", + ) + self.pathpage.save() + + def test_string_representation(self): + self.assertEqual(str(self.page), "Test Page") + self.assertEqual(str(self.page.slug), "test-page") + self.assertEqual(str(self.page.body_markdown), "the body of the page") + self.assertEqual(str(self.page.body_html), "<p>the body of the page</p>") + self.assertEqual(str(self.page.meta_description), "The meta desc") + self.assertEqual(self.page.path, None) + + def test_get_absolute_url(self): + """Absolute URL should return /page """ + self.assertEqual(str(self.page.get_absolute_url()), "/test-page") + + def test_path_get_absolute_url(self): + """Absolute URL with a path should return /path/page """ + self.assertEqual(str(self.pathpage.get_absolute_url()), "/test-path/test-page") |