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

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

## 23 statements 23 run 0 missing 1 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 38 39 40 41 42 | import wagtail.wagtailcore.urls import wagtailsharing.urls from django.conf.urls import url from django.test import TestCase from mock import patch class TestUrlPatterns(TestCase): def setUp(self): def test_view(): pass # pragma: no cover root_patterns = [ url(r'^foo/$', url, name='foo'), url(r'^((?:[\w\-]+/)*)$', url, name='wagtail_serve'), url(r'^bar/$', url, name='bar'), ] self.patcher = patch.object( wagtail.wagtailcore.urls, 'urlpatterns', root_patterns ) self.patcher.start() self.addCleanup(self.patcher.stop) reload(wagtailsharing.urls) self.urlpatterns = wagtailsharing.urls.urlpatterns def test_leaves_previous_urls_alone(self): self.assertEqual(self.urlpatterns[0].name, 'foo') self.assertEqual(self.urlpatterns[0].regex.pattern, r'^foo/$') def test_replaces_wagtail_serve(self): self.assertEqual(self.urlpatterns[1].name, 'wagtail_serve') self.assertEqual(self.urlpatterns[1].callback.__name__, 'ServeView') def test_leaves_later_urls_alone(self): self.assertEqual(self.urlpatterns[2].name, 'bar') self.assertEqual(self.urlpatterns[2].regex.pattern, r'^bar/$')