当前位置: 首页>>代码示例>>Python>>正文


Python OrderFactory.get_summary_data方法代码示例

本文整理汇总了Python中brambling.tests.factories.OrderFactory.get_summary_data方法的典型用法代码示例。如果您正苦于以下问题:Python OrderFactory.get_summary_data方法的具体用法?Python OrderFactory.get_summary_data怎么用?Python OrderFactory.get_summary_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在brambling.tests.factories.OrderFactory的用法示例。


在下文中一共展示了OrderFactory.get_summary_data方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_summary_data__itemoption_deleted

# 需要导入模块: from brambling.tests.factories import OrderFactory [as 别名]
# 或者: from brambling.tests.factories.OrderFactory import get_summary_data [as 别名]
    def test_summary_data__itemoption_deleted(self):
        """
        Test that get_summary_data returns correct values for savings and
        total cost even if an itemoption was deleted.

        """
        event = EventFactory()
        order = OrderFactory(event=event)
        item = ItemFactory(event=event)
        item_option = ItemOptionFactory(price=100, item=item)
        discount = DiscountFactory(amount=20, event=event, item_options=[item_option])

        order.add_to_cart(item_option)

        summary_data = order.get_summary_data()
        self.assertEqual(summary_data['gross_cost'], 100)
        self.assertEqual(summary_data['total_savings'], 0)
        self.assertEqual(summary_data['net_cost'], 100)

        order.add_discount(discount)

        summary_data = order.get_summary_data()
        self.assertEqual(summary_data['gross_cost'], 100)
        self.assertEqual(summary_data['total_savings'], -20)
        self.assertEqual(summary_data['net_cost'], 80)

        item_option.delete()

        # Make sure that the value isn't cached.
        order = Order.objects.get(pk=order.pk)

        summary_data = order.get_summary_data()
        self.assertEqual(summary_data['gross_cost'], 100)
        self.assertEqual(summary_data['total_savings'], -20)
        self.assertEqual(summary_data['net_cost'], 80)
开发者ID:gitter-badger,项目名称:django-brambling,代码行数:37,代码来源:test_order_model.py

示例2: test_summary_data__base

# 需要导入模块: from brambling.tests.factories import OrderFactory [as 别名]
# 或者: from brambling.tests.factories.OrderFactory import get_summary_data [as 别名]
    def test_summary_data__base(self):
        """
        Test that get_summary_data returns correct values for savings and
        total cost.

        """
        event = EventFactory()
        order = OrderFactory(event=event)
        item = ItemFactory(event=event)
        item_option = ItemOptionFactory(price=100, item=item)
        discount = DiscountFactory(amount=20, event=event, item_options=[item_option])

        order.add_to_cart(item_option)

        summary_data = order.get_summary_data()
        self.assertEqual(summary_data['gross_cost'], 100)
        self.assertEqual(summary_data['total_savings'], 0)
        self.assertEqual(summary_data['net_cost'], 100)

        order.add_discount(discount)

        summary_data = order.get_summary_data()
        self.assertEqual(summary_data['gross_cost'], 100)
        self.assertEqual(summary_data['total_savings'], -20)
        self.assertEqual(summary_data['net_cost'], 80)
开发者ID:gitter-badger,项目名称:django-brambling,代码行数:27,代码来源:test_order_model.py

示例3: test_summary_data__discount_changed

# 需要导入模块: from brambling.tests.factories import OrderFactory [as 别名]
# 或者: from brambling.tests.factories.OrderFactory import get_summary_data [as 别名]
    def test_summary_data__discount_changed(self):
        """
        Test that get_summary_data returns correct values for savings and
        total cost even if a discount was changed.

        """
        event = EventFactory()
        order = OrderFactory(event=event)
        transaction = TransactionFactory(event=event, order=order)
        item = ItemFactory(event=event)
        item_option = ItemOptionFactory(price=100, item=item)
        discount = DiscountFactory(amount=20, event=event, item_options=[item_option])

        order.add_to_cart(item_option)
        order.add_discount(discount)
        order.mark_cart_paid(transaction)

        summary_data = order.get_summary_data()
        self.assertEqual(summary_data['gross_cost'], 100)
        self.assertEqual(summary_data['total_savings'], -20)
        self.assertEqual(summary_data['net_cost'], 80)

        discount.amount = 100
        discount.save()

        # Make sure that the value isn't cached.
        order = Order.objects.get(pk=order.pk)

        summary_data = order.get_summary_data()
        self.assertEqual(summary_data['gross_cost'], 100)
        self.assertEqual(summary_data['total_savings'], -20)
        self.assertEqual(summary_data['net_cost'], 80)
开发者ID:littleweaver,项目名称:django-brambling,代码行数:34,代码来源:test_order_model.py

示例4: test_summary_data__items_no_transaction

# 需要导入模块: from brambling.tests.factories import OrderFactory [as 别名]
# 或者: from brambling.tests.factories.OrderFactory import get_summary_data [as 别名]
    def test_summary_data__items_no_transaction(self):
        """
        Items without transactions are included in summary data.

        """
        event = EventFactory()
        order = OrderFactory(event=event)
        item = ItemFactory(event=event)
        item_option = ItemOptionFactory(price=100, item=item)

        order.add_to_cart(item_option)
        summary_data = order.get_summary_data()
        self.assertEqual(summary_data['gross_cost'], 100)
        self.assertEqual(summary_data['total_savings'], 0)
        self.assertEqual(summary_data['net_cost'], 100)
开发者ID:littleweaver,项目名称:django-brambling,代码行数:17,代码来源:test_order_model.py

示例5: test_summary_data__transaction_no_items

# 需要导入模块: from brambling.tests.factories import OrderFactory [as 别名]
# 或者: from brambling.tests.factories.OrderFactory import get_summary_data [as 别名]
    def test_summary_data__transaction_no_items(self):
        """
        Transactions without items are included in summary data.

        """
        event = EventFactory()
        order = OrderFactory(event=event)
        TransactionFactory(event=event, order=order, amount=100)

        summary_data = order.get_summary_data()
        self.assertEqual(summary_data['total_payments'], 100)
        self.assertEqual(summary_data['total_refunds'], 0)
        self.assertEqual(summary_data['net_balance'], -100)

        TransactionFactory(
            event=event,
            order=order,
            amount=-100,
            transaction_type=Transaction.REFUND
        )
        summary_data = order.get_summary_data()
        self.assertEqual(summary_data['total_payments'], 100)
        self.assertEqual(summary_data['total_refunds'], -100)
        self.assertEqual(summary_data['net_balance'], 0)
开发者ID:littleweaver,项目名称:django-brambling,代码行数:26,代码来源:test_order_model.py

示例6: test_summary_data__transfer

# 需要导入模块: from brambling.tests.factories import OrderFactory [as 别名]
# 或者: from brambling.tests.factories.OrderFactory import get_summary_data [as 别名]
    def test_summary_data__transfer(self):
        """Items sent or received in a transfer shouldn't count towards net cost and savings"""
        event = EventFactory()
        order = OrderFactory(
            event=event,
            person=PersonFactory(),
        )
        person2 = PersonFactory()
        transaction = TransactionFactory(
            event=event,
            order=order,
            is_confirmed=True,
            transaction_type=Transaction.PURCHASE,
            amount=80,
        )
        item = ItemFactory(event=event)
        item_option = ItemOptionFactory(price=100, item=item)
        discount = DiscountFactory(amount=20, event=event, item_options=[item_option])

        order.add_to_cart(item_option)
        order.add_discount(discount)
        order.mark_cart_paid(transaction)

        bought_item = transaction.bought_items.get()
        invite = TransferInvite.get_or_create(
            request=Mock(user=person2, session={}),
            email=person2.email,
            content=bought_item,
        )[0]
        invite.accept()

        summary_data = order.get_summary_data()
        self.assertEqual(summary_data['gross_cost'], 100)
        self.assertEqual(summary_data['total_savings'], -20)
        self.assertEqual(summary_data['total_refunds'], 0)
        self.assertEqual(summary_data['total_payments'], 80)
        self.assertEqual(summary_data['net_cost'], 80)
        self.assertEqual(summary_data['net_balance'], 0)
        self.assertEqual(summary_data['unconfirmed_check_payments'], False)
        transactions = summary_data['transactions']
        self.assertEqual(len(transactions), 2)
        transfer_txn, transfer_txn_dict = transactions.items()[0]
        self.assertEqual(transfer_txn.transaction_type, Transaction.TRANSFER)
        self.assertEqual(transfer_txn_dict['items'], [bought_item])
        self.assertEqual(transfer_txn_dict['gross_cost'], 0)
        self.assertEqual(transfer_txn_dict['discounts'], [])
        self.assertEqual(transfer_txn_dict['total_savings'], 0)
        self.assertEqual(transfer_txn_dict['net_cost'], 0)
        purchase_txn, purchase_txn_dict = transactions.items()[1]
        self.assertEqual(purchase_txn.transaction_type, Transaction.PURCHASE)
        self.assertEqual(purchase_txn_dict['items'], [bought_item])
        self.assertEqual(purchase_txn_dict['gross_cost'], 100)
        self.assertEqual(purchase_txn_dict['discounts'], [bought_item.discounts.first()])
        self.assertEqual(purchase_txn_dict['total_savings'], -20)
        self.assertEqual(purchase_txn_dict['net_cost'], 80)

        order2 = Order.objects.get(event=event, person=person2)
        summary_data2 = order2.get_summary_data()
        self.assertEqual(summary_data2['gross_cost'], 0)
        self.assertEqual(summary_data2['total_savings'], 0)
        self.assertEqual(summary_data2['total_refunds'], 0)
        self.assertEqual(summary_data2['total_payments'], 0)
        self.assertEqual(summary_data2['net_cost'], 0)
        self.assertEqual(summary_data2['net_balance'], 0)
        self.assertEqual(summary_data2['unconfirmed_check_payments'], False)
        transactions2 = summary_data2['transactions']
        self.assertEqual(len(transactions2), 1)
        transfer_txn2, transfer_txn2_dict = transactions.items()[0]
        self.assertEqual(transfer_txn2.transaction_type, Transaction.TRANSFER)
        self.assertEqual(transfer_txn2_dict['items'], [bought_item])
        self.assertEqual(transfer_txn2_dict['gross_cost'], 0)
        self.assertEqual(transfer_txn2_dict['discounts'], [])
        self.assertEqual(transfer_txn2_dict['total_savings'], 0)
        self.assertEqual(transfer_txn2_dict['net_cost'], 0)
开发者ID:littleweaver,项目名称:django-brambling,代码行数:76,代码来源:test_order_model.py


注:本文中的brambling.tests.factories.OrderFactory.get_summary_data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。