diff options
Diffstat (limited to 'apps/pages/tests/test_models.py')
-rw-r--r-- | apps/pages/tests/test_models.py | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/apps/pages/tests/test_models.py b/apps/pages/tests/test_models.py index f8de5c7..2722430 100644 --- a/apps/pages/tests/test_models.py +++ b/apps/pages/tests/test_models.py @@ -4,17 +4,33 @@ from pages.models import Page class PageModelTest(TestCase): - - def test_string_representation(self): - page = Page( + def setUp(self): + self.page = Page( title="Test Page", meta_description="The meta desc", body_markdown="the body of the page", ) - page.save() - self.assertEqual(str(page), "Test Page") - self.assertEqual(str(page.slug), "test-page") - self.assertEqual(str(page.body_markdown), "the body of the page") - self.assertEqual(str(page.body_html), "<p>the body of the page</p>") - self.assertEqual(str(page.meta_description), "The meta desc") - self.assertEqual(page.path, None) + 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") |