fix: prevent error in DateTime schema type if no widget/request set
when we use this intentionally, the widget/request should be set as expected. but apparently this gets instantiated sometimes (by ColanderAlchemy?) without a widget. so this adds sane fallback logic, instead of outright error
This commit is contained in:
parent
131eb22580
commit
2ccfe29553
2 changed files with 28 additions and 9 deletions
|
|
@ -62,6 +62,13 @@ class TestWuttaDateTime(WebTestCase):
|
|||
)
|
||||
self.assertEqual(result, "2024-12-11 02:33 PM")
|
||||
|
||||
# missing widget/request/config
|
||||
typ = mod.WuttaDateTime()
|
||||
node = colander.SchemaNode(typ)
|
||||
result = typ.serialize(node, datetime.datetime(2024, 12, 11, 22, 33))
|
||||
# nb. not possible to know which timezone is system-local
|
||||
self.assertTrue(result.startswith("2024-12-"))
|
||||
|
||||
def test_deserialize(self):
|
||||
tzlocal = get_timezone_by_name("America/Los_Angeles")
|
||||
with patch.object(self.app, "get_timezone", return_value=tzlocal):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue