tailbone/tests/views/test_master.py

36 lines
1.1 KiB
Python

# -*- coding: utf-8; -*-
from unittest.mock import patch
from tailbone.views import master as mod
from wuttaweb.grids import GridAction
from tests.util import WebTestCase
class TestMasterView(WebTestCase):
def make_view(self):
return mod.MasterView(self.request)
def test_make_form_kwargs(self):
self.pyramid_config.add_route('settings.view', '/settings/{name}')
model = self.app.model
setting = model.Setting(name='foo', value='bar')
self.session.add(setting)
self.session.commit()
with patch.multiple(mod.MasterView, create=True,
model_class=model.Setting):
view = self.make_view()
# sanity / coverage check
kw = view.make_form_kwargs(model_instance=setting)
self.assertIsNotNone(kw['action_url'])
def test_make_action(self):
model = self.app.model
with patch.multiple(mod.MasterView, create=True,
model_class=model.Setting):
view = self.make_view()
action = view.make_action('view')
self.assertIsInstance(action, GridAction)