Coverage for wagtailsharing/tests/test_helpers.py: 100%

# Coverage for wagtailsharing/tests/test_helpers.py : 100%

## 26 statements 26 run 0 missing 0 excluded

Hot-keys on this page

r m x p toggle line displays

j k next/prev highlighted chunk

0 (zero) top of page

1 (one) first highlighted chunk

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | from django.test import TestCase from wagtail.wagtailcore.models import Site from wagtailsharing.helpers import get_sharing_url from wagtailsharing.models import SharingSite from wagtailsharing.tests.helpers import create_draft_page class TestGetSharingUrl(TestCase): def setUp(self): self.default_site = Site.objects.get(is_default_site=True) def create_sharing_site(self, hostname): SharingSite.objects.create( site=self.default_site, hostname=hostname ) def test_draft_page_no_sharing_site_returns_none(self): page = create_draft_page(self.default_site, title='draft') self.assertIsNone(get_sharing_url(page)) def test_draft_page_sharing_site_returns_url(self): self.create_sharing_site(hostname='hostname') page = create_draft_page(self.default_site, title='draft') self.assertEqual(get_sharing_url(page), 'http://hostname/draft/') def test_published_page_no_sharing_site_returns_none(self): page = create_draft_page(self.default_site, title='published') page.save_revision().publish() self.assertIsNone(get_sharing_url(page)) def test_published_page_sharing_site_returns_url(self): self.create_sharing_site(hostname='hostname') page = create_draft_page(self.default_site, title='published') page.save_revision().publish() self.assertEqual(get_sharing_url(page), 'http://hostname/published/')