def test_order_execute_multi_transaction(self, fulfill): order = Order(self.member, self.room) item = OrderItem(self.product, order, 2) order.items.add(item) order.execute() fulfill.assert_called_once_with(PayTransaction(20))
def test_order_execute_no_money(self, fulfill, can_fulfill): can_fulfill.return_value = False order = Order(self.member, self.room) item = OrderItem(self.product, order, 2) order.items.add(item) with self.assertRaises(StregForbudError): order.execute() fulfill.was_not_called()
def test_order_execute_multi_some_remaining(self, fulfill): self.product.sale_set.create(price=100, member=self.member) self.product.start_date = datetime.date(year=2017, month=1, day=1) self.product.quantity = 2 order = Order(self.member, self.room) item = OrderItem(self.product, order, 2) order.items.add(item) with self.assertRaises(NoMoreInventoryError): order.execute() fulfill.was_not_called()
def test_order_execute_no_money(self, can_fulfill): can_fulfill.return_value = False balance_before = self.member.balance order = Order(self.member, self.room) item = OrderItem(self.product, order, 2) order.items.add(item) with self.assertRaises(StregForbudError): order.execute() balance_after = self.member.balance self.assertEqual(balance_before, balance_after)