feat: add first wutta-based master, for PersonView
still opt-in-only at this point, the traditional tailbone-native master is used by default. new wutta master is not feature complete yet. but at least things seem to render and form posts work okay.. when enabled, this uses a "completely" wutta-based stack for the view, grid and forms. but the underlying DB is of course rattail, and the templates are still traditional/tailbone.
This commit is contained in:
parent
a6ce5eb21d
commit
dd176a5e9e
7 changed files with 173 additions and 1 deletions
17
tests/views/test_people.py
Normal file
17
tests/views/test_people.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
|
||||
from tailbone.views import users as mod
|
||||
from tests.util import WebTestCase
|
||||
|
||||
|
||||
class TestPersonView(WebTestCase):
|
||||
|
||||
def make_view(self):
|
||||
return mod.PersonView(self.request)
|
||||
|
||||
def test_includeme(self):
|
||||
self.pyramid_config.include('tailbone.views.people')
|
||||
|
||||
def test_includeme_wutta(self):
|
||||
self.config.setdefault('tailbone.use_wutta_views', 'true')
|
||||
self.pyramid_config.include('tailbone.views.people')
|
0
tests/views/wutta/__init__.py
Normal file
0
tests/views/wutta/__init__.py
Normal file
47
tests/views/wutta/test_people.py
Normal file
47
tests/views/wutta/test_people.py
Normal file
|
@ -0,0 +1,47 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
from sqlalchemy import orm
|
||||
|
||||
from tailbone.views.wutta import people as mod
|
||||
from tests.util import WebTestCase
|
||||
|
||||
|
||||
class TestPersonView(WebTestCase):
|
||||
|
||||
def make_view(self):
|
||||
return mod.PersonView(self.request)
|
||||
|
||||
def test_includeme(self):
|
||||
self.pyramid_config.include('tailbone.views.wutta.people')
|
||||
|
||||
def test_get_query(self):
|
||||
view = self.make_view()
|
||||
|
||||
# sanity / coverage check
|
||||
query = view.get_query(session=self.session)
|
||||
self.assertIsInstance(query, orm.Query)
|
||||
|
||||
def test_configure_form(self):
|
||||
model = self.app.model
|
||||
barney = model.User(username='barney')
|
||||
self.session.add(barney)
|
||||
self.session.commit()
|
||||
view = self.make_view()
|
||||
|
||||
# customers field remains when viewing
|
||||
with patch.object(view, 'viewing', new=True):
|
||||
form = view.make_form(model_instance=barney,
|
||||
fields=view.get_form_fields())
|
||||
self.assertIn('customers', form.fields)
|
||||
view.configure_form(form)
|
||||
self.assertIn('customers', form)
|
||||
|
||||
# customers field removed when editing
|
||||
with patch.object(view, 'editing', new=True):
|
||||
form = view.make_form(model_instance=barney,
|
||||
fields=view.get_form_fields())
|
||||
self.assertIn('customers', form.fields)
|
||||
view.configure_form(form)
|
||||
self.assertNotIn('customers', form)
|
Loading…
Add table
Add a link
Reference in a new issue