Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

test coverage for helpers module

  • Loading branch information...
commit a3c3b91f8e9c254f60aa96e9f6baf221a272db3d 1 parent 74d14c4
@mcdonc mcdonc authored
Showing with 65 additions and 0 deletions.
  1. +65 −0 substanced/sdi/tests/test_helpers.py
View
65 substanced/sdi/tests/test_helpers.py
@@ -15,3 +15,68 @@ def _callFUT(self):
def test_it(self):
val = self._callFUT()
self.assertTrue('master' in val)
+
+class Test_breadcrumbs(unittest.TestCase):
+ def setUp(self):
+ self.config = testing.setUp()
+
+ def tearDown(self):
+ testing.tearDown()
+
+ def _callFUT(self, request):
+ from ..helpers import breadcrumbs
+ return breadcrumbs(request)
+
+ def test_no_permissions(self):
+ self.config.testing_securitypolicy(permissive=False)
+ resource = testing.DummyResource()
+ request = testing.DummyRequest()
+ request.context = resource
+ result = self._callFUT(request)
+ self.assertEqual(result, [])
+
+ def test_with_permissions(self):
+ self.config.testing_securitypolicy(permissive=True)
+ resource = testing.DummyResource()
+ request = testing.DummyRequest()
+ request.mgmt_path = lambda *arg: '/path'
+ request.context = resource
+ request.registry.content = DummyContent()
+ result = self._callFUT(request)
+ self.assertEqual(
+ result,
+ [{'url': '/path',
+ 'active': 'active',
+ 'name': 'Home',
+ 'icon': None}]
+ )
+
+class Test_get_site_title(unittest.TestCase):
+ def _callFUT(self, request):
+ from ..helpers import get_site_title
+ return get_site_title(request)
+
+ def test_it(self):
+ from ...interfaces import ISite
+ resource = testing.DummyResource(__provides__=ISite)
+ resource.title = 'My Title'
+ request = testing.DummyRequest()
+ request.context = resource
+ result = self._callFUT(request)
+ self.assertEqual(result, 'My Title')
+
+class Test_add_renderer_globals(unittest.TestCase):
+ def _callFUT(self, event):
+ from ..helpers import add_renderer_globals
+ add_renderer_globals(event)
+
+ def test_it(self):
+ from .. import helpers
+ e = {}
+ self._callFUT(e)
+ self.assertEqual(e['sdi_h'], helpers)
+
+class DummyContent(object):
+ def metadata(self, context, name, default=None):
+ return default
+
Please sign in to comment.
Something went wrong with that request. Please try again.