本文整理汇总了Python中bluebottle.test.factory_models.orders.OrderFactory类的典型用法代码示例。如果您正苦于以下问题:Python OrderFactory类的具体用法?Python OrderFactory怎么用?Python OrderFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OrderFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
super(TestDonationList, self).setUp()
# Make user 1 a staff user
self.user1.is_staff = True
self.user1.save()
# Create a target project/fundraiser
self.project = ProjectFactory.create(amount_asked=5000, owner=self.user1)
self.project.set_status('campaign')
self.fundraiser = FundRaiserFactory.create(amount=4000, owner=self.user1,
project=self.project)
# Two users make a donations
order1 = OrderFactory.create(user=self.user1)
self.donation1 = DonationFactory.create(amount=15, project=self.project,
fundraiser=self.fundraiser, order=order1)
order1.locked()
order1.succeeded()
# Create the second without fundraiser
order2 = OrderFactory.create(user=self.user2)
self.donation2 = DonationFactory.create(amount=10,
project=self.project, fundraiser=None, order=order2)
order2.locked()
order2.succeeded()
self.fundraiser_donation_list_url = reverse('fund-ticker-list')
示例2: test_total_raised
def test_total_raised(self):
""" Calculate the total amount raised by successful donations """
project1 = ProjectFactory.create(amount_asked=1000)
project2 = ProjectFactory.create(amount_asked=1000)
user1 = BlueBottleUserFactory.create()
user2 = BlueBottleUserFactory.create()
user3 = BlueBottleUserFactory.create()
order1 = OrderFactory.create(user=user1)
donation1 = DonationFactory(order=order1, amount=10, project=project1)
order1.locked()
order1.failed()
order2 = OrderFactory.create(user=user2)
donation2 = DonationFactory(order=order2, amount=10, project=project1)
order2.locked()
order2.succeeded()
order3 = OrderFactory.create(user=user2)
donation3 = DonationFactory(order=order3, amount=10, project=project2)
order3.locked()
order3.succeeded()
order4 = OrderFactory.create(user=user3)
donation4 = DonationFactory(order=order4, amount=10, project=project1)
order4.locked()
order4.succeeded()
# order2, order3, order4 should be counted
self.assertEqual(self.metrics.calculate_total_raised(), 30)
示例3: setUp
def setUp(self):
self.init_projects()
self.phase_campaign = ProjectPhase.objects.get(slug='campaign')
self.country = CountryFactory()
self.projects = []
for amount in [500, 100, 1500, 300, 200]:
self.projects.append(OnePercentProjectFactory.create(amount_asked=amount, status=self.phase_campaign))
# Some donations to get the popularity going
# Top 3 after this should be projects 4, 3, 0
order = OrderFactory()
DonationFactory(order=order, project=self.projects[3], amount=10)
DonationFactory(order=order, project=self.projects[3], amount=100)
DonationFactory(order=order, project=self.projects[3], amount=20)
DonationFactory(order=order, project=self.projects[4], amount=10)
DonationFactory(order=order, project=self.projects[4], amount=70)
DonationFactory(order=order, project=self.projects[0], amount=10)
order.locked()
order.succeeded()
# Since we force the transitions update_amounts isn't triggered by signal, so we run it manually here.
for project in self.projects:
project.update_amounts()
self.user1 = BlueBottleUserFactory.create()
self.user2 = BlueBottleUserFactory.create()
示例4: test_supporters
def test_supporters(self):
""" Test return value of supporters, users who did a succesful donation """
project = ProjectFactory.create(amount_asked=1000)
user1 = BlueBottleUserFactory.create()
user2 = BlueBottleUserFactory.create()
user3 = BlueBottleUserFactory.create()
order1 = OrderFactory.create(user=user1)
donation1 = DonationFactory(order=order1, amount=20)
order1.locked()
order1.failed()
order2 = OrderFactory.create(user=user2)
donation2 = DonationFactory(order=order2, amount=25)
order2.locked()
order2.succeeded()
order3 = OrderFactory.create(user=user2)
donation3 = DonationFactory(order=order3, amount=30)
order3.locked()
order3.succeeded()
order4 = OrderFactory.create(user=user3)
donation4 = DonationFactory(order=order4, amount=35)
order4.locked()
order4.succeeded()
# User two should be counted once, and user 3 should be counted
self.assertEqual(self.metrics.calculate_supporters(), 2)
示例5: setUp
def setUp(self):
super(HomepageEndpointTestCase, self).setUp()
self.init_projects()
self.stats = Statistics()
"""
Create 10 Project instances for one user with half in the campaign phase
and the other half in the done-complete phase
This will create:
- 10 running or realised projects
- 10 campaigners (eg 10 new people involved)
"""
self.user1 = BlueBottleUserFactory.create()
self.campaign_phase = ProjectPhase.objects.get(slug='campaign')
self.plan_phase = ProjectPhase.objects.get(slug='done-complete')
projects = []
for char in 'abcdefghij':
# Put half of the projects in the campaign phase.
if ord(char) % 2 == 1:
project = ProjectFactory.create(title=char * 3, slug=char * 3, status=self.campaign_phase)
else:
project = ProjectFactory.create(title=char * 3, slug=char * 3, status=self.plan_phase)
projects.append(project)
"""
Create 10 TaskMember instances for one project.
This will create:
- 1 realised task
- 1 task owner (eg 1 new person involved)
- 10 task members (eg 10 new people involved)
"""
self.task = TaskFactory.create(project=projects[0], status=Task.TaskStatuses.realized)
for char in 'abcdefghij':
# Put half of the projects in the campaign phase.
if ord(char) % 2 == 1:
task = TaskMemberFactory.create(task=self.task)
else:
task = TaskMemberFactory.create(task=self.task)
"""
Create 10 Donations with half to fundraisers
This will create:
- 10 donations of 1000 (total amount of 10000)
- 10 donators (eg 10 new people involved)
- 5 fundraisers (eg 5 new people involved)
"""
for char in 'abcdefghij':
if ord(char) % 2 == 1:
self.order = OrderFactory.create(status=StatusDefinition.SUCCESS)
self.donation = DonationFactory.create(amount=1000, order=self.order, fundraiser=None)
else:
self.order = OrderFactory.create(status=StatusDefinition.SUCCESS)
self.donation = DonationFactory.create(amount=1000, order=self.order)
示例6: setUp
def setUp(self):
super(TestDonationEmails, self).setUp()
self.init_projects()
self.user = BlueBottleUserFactory.create(first_name='user')
self.project_owner = BlueBottleUserFactory.create(
first_name='projectowner')
campaign_status = ProjectPhase.objects.get(slug='campaign')
self.some_project = ProjectFactory.create(owner=self.project_owner,
status=campaign_status)
self.order = OrderFactory.create(
user=self.user,
)
self.recurring_order = OrderFactory.create(
user=self.user,
order_type="recurring"
)
self.donation = DonationFactory.create(
order=self.order,
project=self.some_project,
fundraiser=None
)
self.recurring_donation = DonationFactory.create(
order=self.recurring_order,
project=self.some_project,
fundraiser=None
)
self.fund_order = OrderFactory.create(
user=self.user,
)
self.fund_project = ProjectFactory.create(owner=self.project_owner,
status=campaign_status)
self.fund_owner = BlueBottleUserFactory.create(first_name='fundraiser')
self.fundraiser_project = FundraiserFactory.create(
owner=self.fund_owner,
project=self.fund_project,
)
self.fund_donation = DonationFactory.create(
order=self.fund_order,
project=self.fund_project,
fundraiser=self.fundraiser_project
)
示例7: test_multiple_donations
def test_multiple_donations(self):
DonationFactory.create(
order=OrderFactory.create(status=StatusDefinition.SUCCESS),
fundraiser=self.fundraiser,
amount=Money(100, 'USD')
)
DonationFactory.create(
order=OrderFactory.create(status=StatusDefinition.SUCCESS),
fundraiser=self.fundraiser,
amount=Money(100, 'EUR')
)
self.assertEqual(
self.fundraiser.amount_donated,
Money(250, 'EUR')
)
示例8: test_no_mail_no_campaign_notifications
def test_no_mail_no_campaign_notifications(self):
""" Test that users who have campaign_notifications turned off don't get email """
task_owner1 = BlueBottleUserFactory.create(campaign_notifications=False)
task = TaskFactory.create(
author=task_owner1,
project=self.project
)
# Add extra project and owner that should not get any email
project_owner = BlueBottleUserFactory.create(campaign_notifications=False)
project2 = ProjectFactory(owner=project_owner, status=self.phase1)
# Create a follower by donating
donator1 = BlueBottleUserFactory.create(campaign_notifications=False)
order = OrderFactory.create(user=donator1, status=StatusDefinition.CREATED)
donation = DonationFactory(order=order, amount=35, project=self.project, fundraiser=None)
# Create a follower by being a fundraiser for the project
fundraiser_person = BlueBottleUserFactory.create(campaign_notifications=False)
fundraiser = FundraiserFactory(project=self.project, owner=fundraiser_person)
self.assertEqual(Follow.objects.count(), 3)
# Project owner creates a wallpost and emails followers
some_wallpost_2 = TextWallpostFactory.create(content_object=self.project, author=self.project.owner, text="test2", email_followers=True)
mail_count = 0
# People who should get an email: self.some_user, task_owner1, fundraiser_person, commenter, and donator1
receivers = []
for email in mail.outbox:
if "New wallpost on" in email.subject:
mail_count += 1
self.assertEqual(mail_count, 0)
示例9: test_wallpost_no_mail
def test_wallpost_no_mail(self):
""" Test that followers don't get an email if email_followers is false. Email_followers boolean is false by default on wallpost model"""
self.assertEqual(len(mail.outbox), 0)
self.assertEqual(Follow.objects.count(), 0)
commenter = BlueBottleUserFactory.create()
commenter2 = BlueBottleUserFactory.create()
# Create follower by creating a donation
order = OrderFactory.create(user=self.another_user, status=StatusDefinition.CREATED)
# Make sure to set Fundraiser to None. Otherwise, a fundraiser is created
donation = DonationFactory(order=order, amount=35, project=self.project, fundraiser=None)
# Create follower by creating a task owner
task_owner1 = BlueBottleUserFactory.create()
task = TaskFactory.create(
author=task_owner1,
project=self.project
)
# Verify we have two followers
self.assertEqual(Follow.objects.count(), 2)
# Create a text Wallpost for our dummy project
some_wallpost = TextWallpostFactory.create(content_object=self.project, author=self.project.owner, text="test1", email_followers=False)
self.assertEqual(Follow.objects.count(), 2)
# Some other emails are sent, so we do not compare the mail count. Instead we look at the subject
for email in mail.outbox:
self.assertTrue("New wallpost on" not in email.subject)
示例10: test_pledge_paid_not_fully_funded
def test_pledge_paid_not_fully_funded(self):
""" Test amounts for paid donations. """
pledge_order = OrderFactory.create()
pledge = DonationFactory.create(
project=self.project,
order=pledge_order,
amount=30
)
pledge.save()
# Set status of donation to pledged
pledge.order.pledged()
pledge.order.save()
# Update phase to done-completed
self._reload_project()
self.project.status = ProjectPhase.objects.get(slug='done-complete')
self.project.save()
# Fetch payout
payout = ProjectPayout.objects.all()[0]
# Money is safe now, nothing pending
self.assertEquals(payout.amount_raised, Money(90.00, 'EUR'))
self.assertEquals(payout.payout_rule, 'not_fully_funded')
self.assertEquals(payout.amount_payable, Money(48.00, 'EUR'))
self.assertEquals(payout.amount_pledged, Money(30.00, 'EUR'))
self.assertEquals(payout.organization_fee, Money(12.00, 'EUR'))
示例11: setUp
def setUp(self):
super(PayoutBaseTestCase, self).setUp()
self.init_projects()
# Set up a project ready for payout
self.organization = OrganizationFactory.create()
self.organization.save()
self.project = ProjectFactory.create(organization=self.organization, amount_asked=50)
self.project_incomplete = ProjectFactory.create(organization=self.organization, amount_asked=100)
# Update phase to campaign.
self.project.status = ProjectPhase.objects.get(slug='campaign')
self.project.save()
self.project_incomplete.status = ProjectPhase.objects.get(slug='campaign')
self.project_incomplete.save()
self.order = OrderFactory.create()
self.donation = DonationFactory.create(
project=self.project,
order=self.order,
amount=60
)
self.donation.save()
self.donation2 = DonationFactory.create(
project=self.project_incomplete,
order=self.order,
amount=60
)
self.donation2.save()
示例12: test_normal_userdata
def test_normal_userdata(self, mock_client_create):
mock_client_create.return_value = {'order_key': 123, 'order_id': 123}
mock_create_payment = patch.object(DocdataPaymentAdapter, 'create_payment', fake_create_payment)
user = BlueBottleUserFactory()
holland = CountryFactory(name='Netherlands', alpha2_code='NL')
address = BlueBottleAddressFactory(user=user, line1='Dam 1a', line2='Bovenste bel', city='Amsterdam',
postal_code='1000AA', country=holland)
self.order = OrderFactory.create(user=user)
self.order_payment = OrderPaymentFactory.create(order=self.order, payment_method='docdataIdeal',
integration_data={'default_pm': 'ideal'})
self.service = PaymentService(order_payment=self.order_payment)
user_data = self.service.adapter.get_user_data()
self.assertEqual(user_data['id'], user.id)
self.assertEqual(user_data['first_name'], user.first_name)
self.assertEqual(user_data['last_name'], user.last_name)
self.assertEqual(user_data['email'], user.email)
self.assertEqual(user_data['street'], 'Dam')
self.assertEqual(user_data['house_number'], '1a')
self.assertEqual(user_data['postal_code'], '1000AA')
self.assertEqual(user_data['city'], 'Amsterdam')
self.assertEqual(user_data['country'], 'NL')
self.assertEqual(user_data['company'], '')
self.assertEqual(user_data['kvk_number'], '')
self.assertEqual(user_data['vat_number'], '')
self.assertEqual(user_data['house_number_addition'], '')
self.assertEqual(user_data['state'], '')
示例13: test_authorization_action
def test_authorization_action(self, mock_post, create_hash, get_current_host):
"""
Play some posts that Vitepay might fire at us.
"""
self.init_projects()
order = OrderFactory.create()
DonationFactory.create(amount=Money(2000, XOF), order=order)
order_payment = OrderPaymentFactory.create(payment_method="vitepayOrangemoney", order=order)
adapter = VitepayPaymentAdapter(order_payment)
authorization_action = adapter.get_authorization_action()
data = {
u"api_key": u"123",
u"hash": u"123123",
u"redirect": 0,
u"payment": {
u"description": u"Thanks for your donation!",
u"order_id": u"opc-{}".format(order_payment.id),
u"decline_url": u"https://onepercentclub.com/orders/{}/failed".format(order_payment.order.id),
u"p_type": u"orange_money",
u"country_code": u"ML",
u"language_code": u"fr",
u"amount_100": 200000,
u"cancel_url": u"https://onepercentclub.com/orders/{}/failed".format(order_payment.order.id),
u"currency_code": u"XOF",
u"callback_url": u"https://onepercentclub.com/payments_vitepay/status_update/",
u"return_url": u"https://onepercentclub.com/orders/{}/success".format(order_payment.order.id),
},
}
self.assertEqual(mock_post.call_args[0][0], "https://api.vitepay.com/v1/prod/payments")
self.assertEqual(json.loads(mock_post.call_args[1]["data"]), data)
self.assertEqual(mock_post.call_args[1]["headers"], {"Content-Type": "application/json"})
self.assertEqual(authorization_action["url"], "https://vitepay.com/some-path-to-pay")
示例14: test_no_payment_method_change
def test_no_payment_method_change(self, mock_fetch_status,
mock_transaction):
self.assertEquals(PaymentLogEntry.objects.count(), 1)
# Mock the status check with docdata
mock_fetch_status.return_value = self.create_status_response(
'AUTHORIZED')
order = OrderFactory.create()
order_payment = OrderPaymentFactory.create(
order=order, payment_method='docdataCreditcard')
docdata_payment = DocdataPaymentFactory.create(
order_payment=order_payment,
default_pm='mastercard',
payment_cluster_id='1234',
total_gross_amount=100)
DocdataTransactionFactory.create(payment=docdata_payment,
payment_method='VISA')
c = Client()
merchant_order_id = "{0}-1".format(order_payment.id)
resp = c.get(reverse('docdata-payment-status-update',
kwargs={'merchant_order_id': merchant_order_id}))
self.assertEqual(resp.status_code, 200)
self.assertEqual(resp.content, 'success')
# Reload the order payment
order_payment = OrderPayment.objects.get(id=order_payment.id)
self.assertEqual(order_payment.payment_method, 'docdataCreditcard')
示例15: setUp
def setUp(self):
super(PaymentFeeTestCase, self).setUp()
self.init_projects()
self.order = OrderFactory.create()
self.donation = DonationFactory(amount=60, order=self.order)
self.order_payment = OrderPaymentFactory.create(order=self.order)