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


Python OrderFactory.refresh_from_db方法代码示例

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


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

示例1: OrderDetailViewTest

# 需要导入模块: from brambling.tests.factories import OrderFactory [as 别名]
# 或者: from brambling.tests.factories.OrderFactory import refresh_from_db [as 别名]
class OrderDetailViewTest(TestCase):
    def setUp(self):
        self.owner = Person.objects.create_user(email="[email protected]", password="secret")
        self.non_owner = Person.objects.create_user(email="[email protected]", password="secret")
        self.event = EventFactory(collect_housing_data=False)
        OrganizationMember.objects.create(
            person=self.owner,
            organization=self.event.organization,
            role=OrganizationMember.OWNER,
        )
        self.order = OrderFactory(event=self.event, code='aaaaaaaa')
        self.transaction = TransactionFactory(event=self.event, order=self.order)
        item = ItemFactory(event=self.event)
        item_option = ItemOptionFactory(price=100, item=item)

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

        self.attendee = AttendeeFactory(order=self.order, bought_items=self.order.bought_items.all())
        self.url = reverse('brambling_event_order_detail', kwargs={
            'event_slug': self.event.slug,
            'organization_slug': self.event.organization.slug,
            'code': self.order.code,
        })

    def test_post__order_notes(self):
        self.client.login(username=self.owner.email, password='secret')
        response = self.client.post(
            self.url,
            {
                'is_notes_form': '1',
                'notes': 'Hello',
            },
        )

        self.assertEqual(response.status_code, 302)
        self.assertEqual(response['Location'], self.url)
        self.order.refresh_from_db()
        self.assertEqual(self.order.notes, 'Hello')

    def test_post__attendee_notes(self):
        self.client.login(username=self.owner.email, password='secret')
        response = self.client.post(
            self.url,
            {
                'is_attendee_form': '1',
                'attendee_id': str(self.attendee.pk),
                'notes': 'Hello',
            },
        )

        self.assertEqual(response.status_code, 302)
        self.assertEqual(response['Location'], self.url)
        self.attendee.refresh_from_db()
        self.assertEqual(self.attendee.notes, 'Hello')
开发者ID:littleweaver,项目名称:django-brambling,代码行数:58,代码来源:test_organizer_views.py


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