tailbone/tests/views/test_principal.py
Lance Edgar a6ce5eb21d feat: refactor forms/grids/views/templates per wuttaweb compat
this starts to get things more aligned between wuttaweb and tailbone.
the use case in mind so far is for a wuttaweb view to be included in a
tailbone app.

form and grid classes now have some new methods to match wuttaweb, so
templates call the shared method names where possible.

templates can no longer assume they have tailbone-native master view,
form, grid etc. so must inspect context more closely in some cases.
2024-08-15 15:49:54 -05:00

30 lines
1.1 KiB
Python

# -*- coding: utf-8; -*-
from unittest.mock import patch, MagicMock
from tailbone.views import principal as mod
from tests.util import WebTestCase
class TestPrincipalMasterView(WebTestCase):
def make_view(self):
return mod.PrincipalMasterView(self.request)
def test_find_by_perm(self):
model = self.app.model
self.config.setdefault('rattail.web.menus.handler_spec', 'tests.util:NullMenuHandler')
self.pyramid_config.include('tailbone.views.common')
self.pyramid_config.include('tailbone.views.auth')
self.pyramid_config.add_route('roles', '/roles/')
with patch.multiple(mod.PrincipalMasterView, create=True,
model_class=model.Role,
get_help_url=MagicMock(return_value=None),
get_help_markdown=MagicMock(return_value=None),
can_edit_help=MagicMock(return_value=False)):
# sanity / coverage check
view = self.make_view()
response = view.find_by_perm()
self.assertEqual(response.status_code, 200)