class KitchenSink(Item): """ An item with one of everything, more or less. """ t = text() i = integer() ts = timestamp() tl = textlist() d = ieee754_double() p1d = point1decimal() m = money()
class DecimalDoodad(Item): integral = point1decimal(default=0, allowNone=False) otherMoney = money(allowNone=True) extraintegral = integer() money = money(default=0)
def test_decimals(self): for precision in range(1, 11): attr = getattr(attributes, "point{}decimal".format(precision)) self._test_typeFor(attr(), amp.Decimal) self._test_typeFor(attributes.money(), amp.Decimal)
class ShopItem(item.Item): typeName = "shop_item" description = attributes.text(allowNone=False) price = attributes.money(allowNone=False)