41 lines
1.4 KiB
Python
41 lines
1.4 KiB
Python
# -*- coding: utf-8; -*-
|
|
|
|
from wuttjamaican.testing import DataTestCase
|
|
|
|
from sideshow import orders as mod
|
|
|
|
|
|
class TestOrderHandler(DataTestCase):
|
|
|
|
def make_config(self, **kwargs):
|
|
config = super().make_config(**kwargs)
|
|
config.setdefault('wutta.enum_spec', 'sideshow.enum')
|
|
return config
|
|
|
|
def make_handler(self):
|
|
return mod.OrderHandler(self.config)
|
|
|
|
def test_get_order_qty_uom_text(self):
|
|
enum = self.app.enum
|
|
handler = self.make_handler()
|
|
|
|
# typical, plain text
|
|
text = handler.get_order_qty_uom_text(2, enum.ORDER_UOM_CASE, case_size=12)
|
|
self.assertEqual(text, "2 Cases (x 12 = 24 Units)")
|
|
|
|
# typical w/ html
|
|
text = handler.get_order_qty_uom_text(2, enum.ORDER_UOM_CASE, case_size=12, html=True)
|
|
self.assertEqual(text, "2 Cases (× 12 = 24 Units)")
|
|
|
|
# unknown case size
|
|
text = handler.get_order_qty_uom_text(2, enum.ORDER_UOM_CASE)
|
|
self.assertEqual(text, "2 Cases (x ?? = ?? Units)")
|
|
text = handler.get_order_qty_uom_text(2, enum.ORDER_UOM_CASE, html=True)
|
|
self.assertEqual(text, "2 Cases (× ?? = ?? Units)")
|
|
|
|
# units only
|
|
text = handler.get_order_qty_uom_text(2, enum.ORDER_UOM_UNIT)
|
|
self.assertEqual(text, "2 Units")
|
|
text = handler.get_order_qty_uom_text(2, enum.ORDER_UOM_UNIT, html=True)
|
|
self.assertEqual(text, "2 Units")
|