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


Python factories.OrderFactory类代码示例

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


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

示例1: test_order_by_purchase_date

    def test_order_by_purchase_date(self):
        """
        If ordering by purchase date is selected, we should get that
        ordering even if the field isn't selected.

        """
        order2 = OrderFactory(event=self.event)
        transaction = TransactionFactory(
            event=self.event,
            order=order2,
            timestamp=timezone.now() - datetime.timedelta(days=50)
        )
        order2.add_to_cart(self.item_option)
        order2.mark_cart_paid(transaction)
        attendee2 = AttendeeFactory(
            order=order2,
            bought_items=order2.bought_items.all(),
            housing_status='have',
            email='[email protected]',
            other_needs='99 mattresses',
            person_avoid='Darth Vader',
            person_prefer='Han Solo',
        )

        table = AttendeeTable(
            event=self.event,
            data={
                'o': '-purchase_date',
                TABLE_COLUMN_FIELD: ['pk', 'get_full_name'],
            },
        )
        rows = list(table)
        self.assertEqual(rows[0]['pk'].value, self.attendee.pk)
        self.assertEqual(rows[1]['pk'].value, attendee2.pk)
开发者ID:littleweaver,项目名称:django-brambling,代码行数:34,代码来源:test_attendee_table.py

示例2: test_attendee_count__home_housing

    def test_attendee_count__home_housing(self):
        """Attendee count should be present & accurate; housing data should."""
        event = EventFactory(collect_housing_data=True)
        order = OrderFactory(event=event)
        transaction = TransactionFactory(event=event, order=order)
        item = ItemFactory(event=event)
        item_option = ItemOptionFactory(price=100, item=item)

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

        AttendeeFactory(
            order=order,
            bought_items=order.bought_items.all(),
            housing_status=Attendee.HOME,
        )

        view = EventSummaryView()
        view.request = self.factory.get('/')
        view.request.user = AnonymousUser()
        view.event = event
        context_data = view.get_context_data()

        self.assertEqual(context_data['attendee_count'], 1)
        self.assertEqual(context_data['attendee_requesting_count'], 0)
        self.assertEqual(context_data['attendee_arranged_count'], 0)
        self.assertEqual(context_data['attendee_home_count'], 1)
开发者ID:littleweaver,项目名称:django-brambling,代码行数:28,代码来源:test_organizer_views.py

示例3: test_unicode_csv

    def test_unicode_csv(self):
        event = EventFactory(collect_housing_data=True, currency='GBP')
        order = OrderFactory(event=event)
        transaction = TransactionFactory(event=event, order=order)
        item = ItemFactory(event=event)
        item_option = ItemOptionFactory(price=100, item=item)

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

        AttendeeFactory(
            order=order,
            bought_items=order.bought_items.all(),
            housing_status=Attendee.HOME,
        )

        view = AttendeeFilterView()
        view.event = event
        view.request = self.factory.get('/?format=csv')
        view.request.user = AnonymousUser()

        table = view.get_table(Attendee.objects.all())
        response = view.render_to_response({'table': table})
        self.assertEqual(response['content-disposition'], 'attachment; filename="export.csv"')
        content = list(response)
        self.assertIn('£200.00', content[1])
开发者ID:littleweaver,项目名称:django-brambling,代码行数:27,代码来源:test_organizer_views.py

示例4: test_payment__sends_email

    def test_payment__sends_email(self):
        """A successful payment should send a receipt email and an alert email."""
        organization = OrganizationFactory(check_payment_allowed=True)
        owner = PersonFactory()
        OrganizationMember.objects.create(
            person=owner,
            organization=organization,
            role=OrganizationMember.OWNER,
        )
        event = EventFactory(
            collect_housing_data=False,
            organization=organization,
            check_postmark_cutoff=timezone.now().date(),
        )
        order = OrderFactory(event=event)
        item = ItemFactory(event=event)
        item_option = ItemOptionFactory(price=100, item=item)

        order.add_to_cart(item_option)
        order.add_to_cart(item_option)

        view = SummaryView()
        view.request = self.factory.post('/', {
            'check': 1
        })
        view.request.user = AnonymousUser()
        view.event = event
        view.order = order

        self.assertEqual(len(mail.outbox), 0)
        response = view.post(view.request)
        self.assertEqual(response.status_code, 302)
        self.assertEqual(len(mail.outbox), 2)
开发者ID:littleweaver,项目名称:django-brambling,代码行数:33,代码来源:test_order_views.py

示例5: test_cart_discount_caching

    def test_cart_discount_caching(self):
        """
        Test that the cached discount information is correct.
        """
        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)
        order.add_discount(discount)

        discount.delete()

        self.assertTrue(order.bought_items.exists())
        boughtitem = order.bought_items.all()[0]
        self.assertTrue(boughtitem.discounts.exists())
        boughtitemdiscount = boughtitem.discounts.all()[0]

        self.assertTrue(boughtitemdiscount.discount_id is None)
        self.assertEqual(boughtitemdiscount.name, discount.name)
        self.assertEqual(boughtitemdiscount.code, discount.code)
        self.assertEqual(boughtitemdiscount.discount_type, discount.discount_type)
        self.assertEqual(boughtitemdiscount.amount, discount.amount)

        self.assertEqual(boughtitemdiscount.savings(), 20)
开发者ID:gitter-badger,项目名称:django-brambling,代码行数:27,代码来源:test_order_model.py

示例6: test_comped__sends_email

    def test_comped__sends_email(self):
        """A successful completion with fully-comped items should send a receipt email and an alert email."""
        organization = OrganizationFactory()
        owner = PersonFactory()
        OrganizationMember.objects.create(
            person=owner,
            organization=organization,
            role=OrganizationMember.OWNER,
        )
        event = EventFactory(
            collect_housing_data=False,
            organization=organization,
        )
        order = OrderFactory(event=event)
        item = ItemFactory(event=event)
        item_option = ItemOptionFactory(price=100, item=item)
        discount = DiscountFactory(amount=100, discount_type='percent', event=event, item_options=[item_option])

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

        view = SummaryView()
        view.request = self.factory.post('/')
        view.request.user = AnonymousUser()
        view.event = event
        view.order = order

        self.assertEqual(len(mail.outbox), 0)
        response = view.post(view.request)
        self.assertEqual(response.status_code, 302)
        self.assertEqual(len(mail.outbox), 2)
开发者ID:littleweaver,项目名称:django-brambling,代码行数:32,代码来源:test_order_views.py

示例7: ItemOptionViewSetTestCase

class ItemOptionViewSetTestCase(TestCase):
    def setUp(self):
        self.factory = RequestFactory()

        event = EventFactory()
        self.order = OrderFactory(event=event, email='[email protected]')
        self.transaction = TransactionFactory(
            event=event, order=self.order, amount=130,
            method=Transaction.CHECK, is_confirmed=False)
        item = ItemFactory(event=event, name='Multipass')
        item_option1 = ItemOptionFactory(price=100, item=item, name='Gold')
        item_option2 = ItemOptionFactory(price=60, item=item, name='Silver')

        discount = DiscountFactory(amount=30, discount_type='percent',
                                   event=event, item_options=[item_option1])

        self.order.add_to_cart(item_option1)
        self.order.add_to_cart(item_option2)
        self.order.add_discount(discount)
        self.order.mark_cart_paid(self.transaction)

        order2 = OrderFactory(event=event, email='[email protected]')
        order2.add_to_cart(item_option2)
        transaction2 = TransactionFactory(event=event, order=self.order,
                                          amount=130, method=Transaction.CHECK,
                                          is_confirmed=True)
        order2.mark_cart_paid(transaction2)

        self.order3 = OrderFactory(event=event, email='[email protected]')
        self.order3.add_to_cart(item_option1)
        transaction3 = TransactionFactory(event=event, order=self.order3,
                                          amount=130, method=Transaction.CHECK,
                                          is_confirmed=True)
        self.order3.mark_cart_paid(transaction3)

        self.viewset = ItemOptionViewSet()
        self.viewset.request = self.factory.get('/')
        self.viewset.request.user = self.order.person

    def test_taken_counts(self):
        qs = self.viewset.get_queryset()
        self.assertEqual([2, 2], [int(p.taken) for p in qs])

    def test_exclude_refunded(self):
        """should exclude refunded items from the taken count"""
        self.transaction.refund()
        qs = self.viewset.get_queryset()
        self.assertEqual([1, 1], [int(p.taken) for p in qs])

    def test_exclude_transferred(self):
        """should exclude transferred items from the taken count"""
        for item in self.order3.bought_items.all():
            item.status = BoughtItem.TRANSFERRED
            item.save()
        qs = self.viewset.get_queryset()
        self.assertEqual([1, 2], [int(p.taken) for p in qs])
开发者ID:littleweaver,项目名称:django-brambling,代码行数:56,代码来源:test_itemoption.py

示例8: test_summary_data__discount_deleted

    def test_summary_data__discount_deleted(self):
        """
        Test that get_summary_data returns correct values for savings and
        total cost even if a discount was deleted.

        """
        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.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:littleweaver,项目名称:django-brambling,代码行数:31,代码来源:test_order_model.py

示例9: test_summary_data__base

    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)
        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.mark_cart_paid(transaction)

        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)

        # Discounts don't get added to BOUGHT items.
        order.add_discount(discount)

        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,代码行数:28,代码来源:test_order_model.py

示例10: test_summary_data__items_no_transaction

    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,代码行数:15,代码来源:test_order_model.py

示例11: setUp

 def setUp(self):
     self.factory = RequestFactory()
     self.person = PersonFactory(
         first_name="Conan",
         last_name="O'Brien",
     )
     self.event = EventFactory()
     self.order = OrderFactory(
         event=self.event,
         person=self.person,
     )
     TransactionFactory(
         event=self.event,
         order=self.order,
         amount=130,
     )
     self.item = ItemFactory(
         event=self.event,
         name='Multipass',
     )
     self.item_option1 = ItemOptionFactory(
         price=100,
         item=self.item,
         name='Gold',
     )
     self.order.add_to_cart(self.item_option1)
     self.bought_item = self.order.bought_items.all()[0]
开发者ID:littleweaver,项目名称:django-brambling,代码行数:27,代码来源:test_invites.py

示例12: setUp

 def setUp(self):
     self.event = EventFactory()
     self.order = OrderFactory(event=self.event)
     self.item = ItemFactory(event=self.event)
     self.item_option = ItemOptionFactory(price=100, item=self.item)
     self.order.add_to_cart(self.item_option)
     self.discount = DiscountFactory(amount=20, event=self.event, item_options=[self.item_option])
开发者ID:littleweaver,项目名称:django-brambling,代码行数:7,代码来源:test_order_model.py

示例13: setUp

    def setUp(self):
        self.person = PersonFactory()
        event = EventFactory()
        owner = PersonFactory()
        OrganizationMember.objects.create(
            person=owner,
            organization=event.organization,
            role=OrganizationMember.OWNER,
        )
        self.order = OrderFactory(event=event, person=self.person)
        transaction = TransactionFactory(event=event, order=self.order,
                                         amount=130)
        item = ItemFactory(event=event, name='Multipass')
        item_option1 = ItemOptionFactory(price=100, item=item, name='Gold')
        item_option2 = ItemOptionFactory(price=60, item=item, name='Silver')

        discount = DiscountFactory(amount=30, discount_type='percent',
                                   event=event, item_options=[item_option1])

        self.order.add_to_cart(item_option1)
        self.order.add_to_cart(item_option2)
        self.order.add_discount(discount)
        self.order.mark_cart_paid(transaction)

        self.mailer = OrderAlertMailer(transaction, site='dancerfly.com',
                                       secure=True)
        self.event_name = event.name
        self.discount_amount = format_money(discount.amount, event.currency)
        self.total_amount = format_money(transaction.amount, event.currency)
        self.option1 = '{0} ({1})'.format(item.name, item_option1.name)
        self.option2 = '{0} ({1})'.format(item.name, item_option1.name)
        self.item_price = format_money(item_option1.price, event.currency)
开发者ID:littleweaver,项目名称:django-brambling,代码行数:32,代码来源:test_mailers.py

示例14: test_needs_housing

    def test_needs_housing(self):
        event = EventFactory(collect_housing_data=False)
        order = OrderFactory(event=event)
        transaction = TransactionFactory(event=event, order=order)
        item = ItemFactory(event=event)
        item_option = ItemOptionFactory(price=100, item=item)

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

        a1 = AttendeeFactory(order=order, bought_items=order.bought_items.all(),
                             housing_status=Attendee.NEED)
        a2 = AttendeeFactory(order=order, bought_items=order.bought_items.all())
        self.assertTrue(a1.needs_housing())
        self.assertFalse(a2.needs_housing())
开发者ID:littleweaver,项目名称:django-brambling,代码行数:16,代码来源:test_attendee_model.py

示例15: _get_fake_content

 def _get_fake_content(self):
     order = OrderFactory.build()
     return BoughtItem(
         order=order,
         item_name='test item',
         item_option_name='test item option',
     )
开发者ID:littleweaver,项目名称:django-brambling,代码行数:7,代码来源:invites.py


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