3
0
Fork 0

fix: make some tweaks for better tailbone compatibility

this is the result of minimally testing the PersonView from wutta,
configured via a tailbone app.

had to add the `view_profile()` stub, pretty sure we want that..?
This commit is contained in:
Lance Edgar 2024-08-15 02:10:08 -05:00
parent 058632ebeb
commit be8a45e543
11 changed files with 137 additions and 33 deletions

View file

@ -454,6 +454,28 @@ class TestForm(TestCase):
# nb. no error message
self.assertNotIn('message', html)
def test_get_vue_field_value(self):
schema = self.make_schema()
form = self.make_form(schema=schema)
# TODO: yikes what a hack (?)
dform = form.get_deform()
dform.set_appstruct({'foo': 'one', 'bar': 'two'})
# null for missing field
value = form.get_vue_field_value('doesnotexist')
self.assertIsNone(value)
# normal value is returned
value = form.get_vue_field_value('foo')
self.assertEqual(value, 'one')
# but not if we remove field from deform
# TODO: what is the use case here again?
dform.children.remove(dform['foo'])
value = form.get_vue_field_value('foo')
self.assertIsNone(value)
def test_get_vue_model_data(self):
schema = self.make_schema()
form = self.make_form(schema=schema)

View file

@ -190,9 +190,10 @@ class TestGridAction(TestCase):
html = action.render_icon()
self.assertIn('<i class="fas fa-blarg">', html)
# oruga not yet supported
# oruga has different output
self.request.use_oruga = True
self.assertRaises(NotImplementedError, action.render_icon)
html = action.render_icon()
self.assertIn('<o-icon icon="blarg">', html)
def test_render_label(self):

View file

@ -6,7 +6,7 @@ from unittest.mock import MagicMock, patch
from pyramid import testing
from pyramid.response import Response
from pyramid.httpexceptions import HTTPFound, HTTPNotFound
from pyramid.httpexceptions import HTTPNotFound
from wuttjamaican.conf import WuttaConfig
from wuttaweb.views import master
@ -942,7 +942,7 @@ class TestMasterView(WebTestCase):
configure_get_simple_settings=MagicMock(return_value=settings)):
# get the form page
response = view.configure()
response = view.configure(session=self.session)
self.assertIsInstance(response, Response)
# post request to save settings
@ -952,9 +952,9 @@ class TestMasterView(WebTestCase):
'wutta.foo': 'bar',
'wutta.flag': 'true',
}
response = view.configure()
response = view.configure(session=self.session)
# nb. should get redirect back to configure page
self.assertIsInstance(response, HTTPFound)
self.assertEqual(response.status_code, 302)
# should now have 5 settings
count = self.session.query(model.Setting).count()
@ -970,9 +970,9 @@ class TestMasterView(WebTestCase):
# post request to remove settings
self.request.method = 'POST'
self.request.POST = {'remove_settings': '1'}
response = view.configure()
response = view.configure(session=self.session)
# nb. should get redirect back to configure page
self.assertIsInstance(response, HTTPFound)
self.assertEqual(response.status_code, 302)
# should now have 0 settings
count = self.session.query(model.Setting).count()

View file

@ -15,6 +15,9 @@ class TestPersonView(WebTestCase):
def make_view(self):
return people.PersonView(self.request)
def test_includeme(self):
self.pyramid_config.include('wuttaweb.views.people')
def test_get_query(self):
view = self.make_view()
query = view.get_query(session=self.session)
@ -37,3 +40,19 @@ class TestPersonView(WebTestCase):
view.configure_form(form)
self.assertTrue(form.required_fields)
self.assertFalse(form.required_fields['middle_name'])
def test_view_profile(self):
self.pyramid_config.include('wuttaweb.views.common')
self.pyramid_config.include('wuttaweb.views.auth')
self.pyramid_config.add_route('people', '/people/')
model = self.app.model
person = model.Person(full_name="Barney Rubble")
self.session.add(person)
self.session.commit()
# sanity check
view = self.make_view()
self.request.matchdict = {'uuid': person.uuid}
response = view.view_profile(session=self.session)
self.assertEqual(response.status_code, 200)