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


Python donations.DonationFactory类代码示例

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


在下文中一共展示了DonationFactory类的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')
开发者ID:jfterpstra,项目名称:onepercentclub-site,代码行数:29,代码来源:test_api.py

示例2: 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")
开发者ID:jfterpstra,项目名称:bluebottle,代码行数:34,代码来源:test_adapters.py

示例3: 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()
开发者ID:jfterpstra,项目名称:bluebottle,代码行数:33,代码来源:test_unit.py

示例4: pay

    def pay(self, project, amount):
        order = OrderFactory.create()
        DonationFactory.create(project=project, order=order, amount=amount)
        order.locked()
        order.succeeded()
        order.save()

        return order
开发者ID:pombredanne,项目名称:bluebottle,代码行数:8,代码来源:test_deadline.py

示例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)
开发者ID:pombredanne,项目名称:bluebottle,代码行数:56,代码来源:test_api.py

示例6: test_single_donation_different_currency

    def test_single_donation_different_currency(self):
        DonationFactory.create(
            order=OrderFactory.create(status=StatusDefinition.SUCCESS),
            fundraiser=self.fundraiser,
            amount=Money(100, 'USD')
        )

        self.assertEqual(
            self.fundraiser.amount_donated,
            Money(150, 'EUR')
        )
开发者ID:jfterpstra,项目名称:bluebottle,代码行数:11,代码来源:test_unit.py

示例7: test_successful_my_project_donation_list

    def test_successful_my_project_donation_list(self, check_status_psp):
        # Unsuccessful donations should not be shown
        order = OrderFactory.create(user=self.user2)
        DonationFactory.create(amount=2000, project=self.project3,
                               order=order)

        response = self.client.get(self.project_donation_list_url,
                                   {'project': self.project3.slug},
                                   token=self.user1_token)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(len(response.data['results']), 1,
                         'Only the successful donation should be returned')
开发者ID:jfterpstra,项目名称:bluebottle,代码行数:12,代码来源:test_api.py

示例8: setUp

    def setUp(self):
        super(TestProjectDonationList, self).setUp()

        self.project3 = ProjectFactory.create(amount_asked=5000,
                                              owner=self.user1)
        self.project3.set_status('campaign')

        order = OrderFactory.create(user=self.user1, status=StatusDefinition.SUCCESS)
        DonationFactory.create(amount=1000, project=self.project3,
                               order=order)

        self.project_donation_list_url = reverse('project-donation-list')
开发者ID:jfterpstra,项目名称:bluebottle,代码行数:12,代码来源:test_api.py

示例9: 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
        )
开发者ID:repodevs,项目名称:bluebottle,代码行数:52,代码来源:test_mails.py

示例10: test_project_donation_list_no_co_financing

    def test_project_donation_list_no_co_financing(self, check_status_psp):
        order = OrderFactory.create(user=self.user2, status=StatusDefinition.SUCCESS)
        DonationFactory.create(amount=1500, project=self.project3,
                               order=order)

        response = self.client.get(self.project_donation_list_url,
                                   {'project': self.project3.slug, 'co_financing': 'false'},
                                   token=self.user1_token)

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['count'], 1,
                         'Only donations by co-financers should be returned')
        self.assertEqual(response.data['results'][0]['amount'], 1000)
开发者ID:repodevs,项目名称:bluebottle,代码行数:13,代码来源:test_api.py

示例11: test_project_donation_list_without_amounts

    def test_project_donation_list_without_amounts(self, check_status_psp):
        setattr(properties, 'SHOW_DONATION_AMOUNTS', False)
        order = OrderFactory.create(user=self.user2)
        DonationFactory.create(amount=2000, project=self.project3,
                               order=order)

        response = self.client.get(self.project_donation_list_url,
                                   {'project': self.project3.slug},
                                   token=self.user1_token)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['count'], 1,
                         'Only the successful donation should be returned')
        self.assertNotIn('amount', response.data['results'][0])
开发者ID:repodevs,项目名称:bluebottle,代码行数:13,代码来源:test_api.py

示例12: test_successful_project_donation_list_paged

    def test_successful_project_donation_list_paged(self, check_status_psp):
        for i in range(30):
            order = OrderFactory.create(user=self.user1, status=StatusDefinition.SUCCESS)
            DonationFactory.create(amount=2000, project=self.project3,
                                   order=order)

        response = self.client.get(self.project_donation_list_url,
                                   {'project': self.project3.slug},
                                   token=self.user1_token)
        self.assertEqual(response.status_code, status.HTTP_200_OK)

        self.assertEqual(response.data['count'], 31,
                         'All the donations should be returned')
        self.assertEqual(len(response.data['results']), 20)
开发者ID:jfterpstra,项目名称:bluebottle,代码行数:14,代码来源:test_api.py

示例13: test_status_overfunded_projects

    def test_status_overfunded_projects(self):
        """ Overfunded projects should have status 'done-complete' """
        project = ProjectFactory.create(title='test', amount_asked=100)
        project.status = ProjectPhase.objects.get(slug='campaign')
        project.save()

        order = OrderFactory.create()

        donation = DonationFactory.create(
            project=project,
            order=order,
            amount=110
        )

        donation.save()

        order.locked()
        order.succeeded()
        order.save()

        project = Project.objects.get(title='test')
        project.deadline = timezone.now() - timezone.timedelta(days=1)
        project.save()

        project = Project.objects.get(title='test')
        self.assertEqual(project.status,
                         ProjectPhase.objects.get(slug='done-complete'))
开发者ID:pombredanne,项目名称:bluebottle,代码行数:27,代码来源:test_unittests.py

示例14: test_journal_created_when_donation_is_made

    def test_journal_created_when_donation_is_made(self):
        """
        Create a Donation, and check if it results in a Journal.

        Then create a Journal, and check if the Donation is updated.
        Do this also for a negative value
        """
        self.assertEqual(DonationJournal.objects.all().count(), 0)

        self.assertEqual(Member.objects.count(), 2)  # self.user and self.project_owner
        # creates another user for fundraiser
        self.donation = DonationFactory.create(user=self.user,
                                               amount=Decimal('100'),
                                               project=self.project,
                                               order__user=self.user)
        self.assertEqual(Member.objects.count(), 4)

        # creation of a donation should always result in the creation of a journal
        donation_from_db = self._get_only_one_from_db(Donation)
        journal_from_db = self._get_only_one_from_db(DonationJournal)

        self.assertEqual(journal_from_db.donation, donation_from_db)
        self.assertEqual(donation_from_db.amount, Decimal('100'))
        self.assertEqual(journal_from_db.amount, Decimal('100'))

        # #### Create a Journal, check if it results in an updated Donation ##### #
        journal = DonationJournal.objects.create(donation = self.donation,
                                                 amount = Decimal('50'))
        new_journal_pk = journal.pk
        self.assertEqual(DonationJournal.objects.all().count(), 2)
        new_journal_from_db = DonationJournal.objects.get(pk=new_journal_pk)

        self.assertEqual(new_journal_from_db.user_reference, '[email protected]')  # should be auto filled with donation user
        self.assertEqual(new_journal_from_db.description, '')  # should be blank

        self.assertEqual(new_journal_from_db.date.date(), date.today())  # date today
        self.assertEqual(new_journal_from_db.amount, Decimal('50'))

        # the donation should be updated with the amount added via the journal
        donation_from_db = self._get_only_one_from_db(Donation)
        self.assertEqual(donation_from_db.amount, Decimal('150'))  # change to new amount

        self._check_if_journal_total_equals_value(new_journal_from_db, donation_from_db.amount)

        # Change the Donation, and check if a new Journal is created
        donation_from_db.amount = Decimal('145')
        donation_from_db.save()
        self.assertEqual(DonationJournal.objects.all().count(), 3)
        new_journal = DonationJournal.objects.all().last()  # the latest is the newest
        self.assertEqual(new_journal.amount, Decimal('-5'))

        # mastercheck to see if Donation and related Journals addup
        self._check_if_journal_total_equals_value(new_journal, Decimal('145'))

        # Change the donation without changing the amount, no journal should be created.
        donation_from_db = self._get_only_one_from_db(Donation)
        self.assertEqual(DonationJournal.objects.all().count(), 3)
        donation_from_db.completed = timezone.now()
        donation_from_db.save()
        self.assertEqual(DonationJournal.objects.all().count(), 3)
开发者ID:repodevs,项目名称:bluebottle,代码行数:60,代码来源:test_models.py

示例15: test_more_than_20_not_fully_funded

    def test_more_than_20_not_fully_funded(self):
        """
        Test that a campaign with more than 20 euros but is not fully funded,
        and hits the deadline gets the status done-incomplete
        """
        now = timezone.now()

        some_project = ProjectFactory.create(
            title="test",
            amount_asked=500,
            campaign_started=now - timezone.timedelta(days=15),
            deadline=now - timezone.timedelta(days=5),
        )

        order = OrderFactory.create()

        donation = DonationFactory.create(project=some_project, order=order, amount=21)
        donation.save()

        # Set status of donation to paid
        donation.order.locked()
        donation.order.save()
        donation.order.success()
        donation.order.save()

        some_project.status = self.campaign
        some_project.save()

        call_command("cron_status_realised")

        project = Project.objects.get(title="test")
        self.assertEqual(project.status, self.incomplete)
开发者ID:jfterpstra,项目名称:bluebottle,代码行数:32,代码来源:test_management.py


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