本文整理汇总了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')