def testPriceListAcceptsNewNamedPriceObjects(self):
     context = StubContext()
     priced = behaviors.IPriced(context)
     priced.pricelist = behaviors.PriceList()
     a_price = Decimal('2.99')
     priced.pricelist.append(behaviors.NamedPrice(a_price))
     self.assertEqual(a_price,
                      behaviors.IPriced(context).pricelist[0].price)
 def testEnabled(self):
     context = StubContext()
     priced = behaviors.IPriced(context)
     self.assertTrue(hasattr(priced, 'enabled'))
     # should be false by default
     self.failIf(priced.enabled)
     # should be settable
     priced.enabled = True
     self.assertEqual(True, behaviors.IPriced(context).enabled)
Exemplo n.º 3
0
    def _lineitems(self, to_add):
        """ to_add looks like this:

            [{'id': 'members', 'quantity': '1'},
             {'id': 'non-members', 'quantity': ''}]
        """
        context = aq_inner(self.context)
        priced = behaviors.IPriced(context)
        lineItemBuilder = LineItemFactory(priced.pricelist, context, to_add)
        return lineItemBuilder.create()
 def testInvariants(self):
     validation = behaviors.IPriced.validateInvariants
     context = StubContext()
     priced = behaviors.IPriced(context)
     priced.enabled = True
     self.assertRaises(zif.Invalid, validation, priced)
     # an empty PriceList should also fail
     priced.pricelist = behaviors.PriceList()
     self.assertRaises(zif.Invalid, validation, priced)
     # set a price and we're OK
     a_price = Decimal('2.99')
     priced.pricelist.append(behaviors.NamedPrice(a_price))
     self.assertEqual(None, validation(priced))
 def priced(self):
     return behaviors.IPriced(self.context, None)
 def testPriceListDefaultsToOurMissingValue(self):
     context = StubContext()
     priced = behaviors.IPriced(context)
     self.assertEqual(behaviors.NO_PRICELIST, priced.pricelist)
 def testAdaptation(self):
     context = StubContext()
     priced = behaviors.IPriced(context)
     self.assertTrue(priced is not None)