tests: fix test for orders / configure_form()

This commit is contained in:
Lance Edgar 2025-01-13 18:56:41 -06:00
parent 6d884bccc3
commit e7a5f6c09e

View file

@ -1074,18 +1074,27 @@ class TestOrderView(WebTestCase):
local = model.LocalCustomer(first_name='Jack', last_name='Black',
phone_number='555-1234')
self.session.add(local)
order.local_customer = local
self.session.flush()
# viewing (local customer)
with patch.object(view, 'viewing', new=True):
form = view.make_form(model_instance=order)
# nb. this is to avoid include/exclude ambiguity
form.remove('items')
view.configure_form(form)
self.assertNotIn('pending_customer', form)
schema = form.get_schema()
self.assertIsInstance(schema['total_price'].typ, WuttaMoney)
with patch.object(order, 'local_customer', new=local):
form = view.make_form(model_instance=order)
# nb. this is to avoid include/exclude ambiguity
form.remove('items')
view.configure_form(form)
self.assertNotIn('pending_customer', form)
schema = form.get_schema()
self.assertIsInstance(schema['total_price'].typ, WuttaMoney)
# local customer is hidden if missing when customer_id is set
with patch.object(view, 'viewing', new=True):
with patch.object(order, 'customer_id', new='42'):
form = view.make_form(model_instance=order)
# nb. this is to avoid include/exclude ambiguity
form.remove('items')
view.configure_form(form)
self.assertNotIn('local_customer', form)
def test_get_xref_buttons(self):
self.pyramid_config.add_route('neworder_batches.view', '/batch/neworder/{uuid}')