本文整理汇总了Python中brambling.tests.factories.OrderFactory.mark_cart_paid方法的典型用法代码示例。如果您正苦于以下问题:Python OrderFactory.mark_cart_paid方法的具体用法?Python OrderFactory.mark_cart_paid怎么用?Python OrderFactory.mark_cart_paid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类brambling.tests.factories.OrderFactory
的用法示例。
在下文中一共展示了OrderFactory.mark_cart_paid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OrderAlertMailerForNonUserOrderTestCase
# 需要导入模块: from brambling.tests.factories import OrderFactory [as 别名]
# 或者: from brambling.tests.factories.OrderFactory import mark_cart_paid [as 别名]
class OrderAlertMailerForNonUserOrderTestCase(TestCase):
def setUp(self):
event = EventFactory()
self.order = OrderFactory(event=event, email='[email protected]')
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
def test_subject(self):
subject = self.mailer.render_subject(self.mailer.get_context_data())
expected_subject = ('[{event_name}] New purchase by {order_email}'
.format(event_name=self.event_name,
order_email=self.order.email))
self.assertEqual(subject, expected_subject)
示例2: test_attendee_count__home_housing
# 需要导入模块: from brambling.tests.factories import OrderFactory [as 别名]
# 或者: from brambling.tests.factories.OrderFactory import mark_cart_paid [as 别名]
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)
示例3: OrderAlertMailerWithUnconfirmedCheckPayments
# 需要导入模块: from brambling.tests.factories import OrderFactory [as 别名]
# 或者: from brambling.tests.factories.OrderFactory import mark_cart_paid [as 别名]
class OrderAlertMailerWithUnconfirmedCheckPayments(TestCase):
def setUp(self):
event = EventFactory()
self.order = OrderFactory(event=event, email='[email protected]')
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(transaction)
self.mailer = OrderAlertMailer(transaction, site='dancerfly.com',
secure=True)
self.event_name = event.name
def test_body_plaintext(self):
body = self.mailer.render_body(self.mailer.get_context_data(),
plaintext=True)
self.assertIn("keep an eye on your mail", body)
示例4: test_unicode_csv
# 需要导入模块: from brambling.tests.factories import OrderFactory [as 别名]
# 或者: from brambling.tests.factories.OrderFactory import mark_cart_paid [as 别名]
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])
示例5: test_summary_data__base
# 需要导入模块: from brambling.tests.factories import OrderFactory [as 别名]
# 或者: from brambling.tests.factories.OrderFactory import mark_cart_paid [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)
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)
示例6: test_summary_data__discount_deleted
# 需要导入模块: from brambling.tests.factories import OrderFactory [as 别名]
# 或者: from brambling.tests.factories.OrderFactory import mark_cart_paid [as 别名]
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)
示例7: test_summary_data__itemoption_changed
# 需要导入模块: from brambling.tests.factories import OrderFactory [as 别名]
# 或者: from brambling.tests.factories.OrderFactory import mark_cart_paid [as 别名]
def test_summary_data__itemoption_changed(self):
"""
Test that get_summary_data returns correct values for savings and
total cost even if an itemoption 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)
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)
item_option.price = 200
item_option.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'], 0)
self.assertEqual(summary_data['net_cost'], 100)
示例8: test_order_by_purchase_date
# 需要导入模块: from brambling.tests.factories import OrderFactory [as 别名]
# 或者: from brambling.tests.factories.OrderFactory import mark_cart_paid [as 别名]
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)
示例9: OrderDetailViewTest
# 需要导入模块: from brambling.tests.factories import OrderFactory [as 别名]
# 或者: from brambling.tests.factories.OrderFactory import mark_cart_paid [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')
示例10: ItemOptionViewSetTestCase
# 需要导入模块: from brambling.tests.factories import OrderFactory [as 别名]
# 或者: from brambling.tests.factories.OrderFactory import mark_cart_paid [as 别名]
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])
示例11: test_needs_housing
# 需要导入模块: from brambling.tests.factories import OrderFactory [as 别名]
# 或者: from brambling.tests.factories.OrderFactory import mark_cart_paid [as 别名]
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())
示例12: set_up_view
# 需要导入模块: from brambling.tests.factories import OrderFactory [as 别名]
# 或者: from brambling.tests.factories.OrderFactory import mark_cart_paid [as 别名]
def set_up_view(self, orderer=None, is_confirmed=False):
organization = OrganizationFactory(check_payment_allowed=True)
OrganizationMember.objects.create(
person=PersonFactory(),
organization=organization,
role=OrganizationMember.OWNER,
)
event = EventFactory(
collect_housing_data=False,
organization=organization,
check_postmark_cutoff=timezone.now().date() + timedelta(1),
)
item = ItemFactory(event=event)
item_option = ItemOptionFactory(price=100, item=item)
receiver = PersonFactory()
order_kwargs = dict(event=event)
if orderer:
order_kwargs['person'] = orderer
order = OrderFactory(**order_kwargs)
order.add_to_cart(item_option)
transaction = TransactionFactory(event=event, order=order, is_confirmed=is_confirmed)
order.mark_cart_paid(transaction)
# The BoughtItem should be in the correct state if we've set up this
# test Order correctly.
self.assertEqual(order.bought_items.first().status, BoughtItem.BOUGHT)
view = TransferView()
view.kwargs = dict(
event_slug=event.slug,
organization_slug=organization.slug,
)
view.request = self.factory.post('/', dict(
bought_item=order.bought_items.first().pk,
email=receiver.email,
))
view.request.user = orderer if orderer else AnonymousUser()
view.event = event
view.order = order
view.workflow = RegistrationWorkflow(order=order, event=event)
view.current_step = view.workflow.steps.get(view.current_step_slug)
return view
示例13: setUp
# 需要导入模块: from brambling.tests.factories import OrderFactory [as 别名]
# 或者: from brambling.tests.factories.OrderFactory import mark_cart_paid [as 别名]
def setUp(self):
self.factory = RequestFactory()
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,
)
order = OrderFactory(event=self.event, code='aaaaaaaa')
self.transaction = TransactionFactory(event=self.event, order=order)
item = ItemFactory(event=self.event)
item_option = ItemOptionFactory(price=100, item=item)
order.add_to_cart(item_option)
order.add_to_cart(item_option)
order.mark_cart_paid(self.transaction)
AttendeeFactory(order=order, bought_items=order.bought_items.all())
示例14: OrderReceiptMailerWithUnconfirmedCheckPayments
# 需要导入模块: from brambling.tests.factories import OrderFactory [as 别名]
# 或者: from brambling.tests.factories.OrderFactory import mark_cart_paid [as 别名]
class OrderReceiptMailerWithUnconfirmedCheckPayments(TestCase):
def setUp(self):
event = EventFactory()
self.order = OrderFactory(event=event, email='[email protected]')
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(transaction)
self.mailer = OrderReceiptMailer(transaction, site='dancerfly.com',
secure=True)
self.event = event
def test_still_time_to_mail_check(self):
self.event.check_postmark_cutoff = date.today() + timedelta(days=5)
body = self.mailer.render_body(self.mailer.get_context_data(),
plaintext=True)
self.assertIn("Checks must be postmarked no later than", body)
def test_past_postmark_cutoff(self):
self.event.check_postmark_cutoff = date.today() - timedelta(days=5)
body = self.mailer.render_body(self.mailer.get_context_data(),
plaintext=True)
self.assertIn("Payment was due to be postmarked", body)
def test_postmark_cutoff_today(self):
self.event.check_postmark_cutoff = date.today()
body = self.mailer.render_body(self.mailer.get_context_data(),
plaintext=True)
self.assertIn("postmarked no later than today", body)
示例15: AttendeeFilterViewTest
# 需要导入模块: from brambling.tests.factories import OrderFactory [as 别名]
# 或者: from brambling.tests.factories.OrderFactory import mark_cart_paid [as 别名]
class AttendeeFilterViewTest(TestCase):
def setUp(self):
self.event = EventFactory()
self.order = OrderFactory(event=self.event)
self.transaction = TransactionFactory(
event=self.event,
order=self.order,
)
self.item = ItemFactory(event=self.event)
self.item_option = ItemOptionFactory(price=100, item=self.item)
self.order.add_to_cart(self.item_option)
self.order.mark_cart_paid(self.transaction)
self.attendee = AttendeeFactory(
order=self.order,
bought_items=self.order.bought_items.all(),
)
self.view = AttendeeFilterView()
self.view.event = self.event
def test_get_queryset__includes_bought(self):
self.assertEqual(
list(self.view.get_queryset()),
[self.attendee],
)
def test_get_queryset__excludes_transferred(self):
"""
Received transferred items use status: BOUGHT. Sent transferred
items use status: TRANSFERRED. These attendees shouldn't _exist_
but also shouldn't be displayed if they do.
"""
self.order.bought_items.update(status=BoughtItem.TRANSFERRED)
self.assertEqual(
list(self.view.get_queryset()),
[],
)