a6ce5eb21d
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.
27 lines
809 B
Python
27 lines
809 B
Python
# -*- coding: utf-8; -*-
|
|
|
|
from unittest.mock import patch
|
|
|
|
from tailbone.views import master as mod
|
|
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'])
|