Exemplo n.º 1
0
    def setUp(self):
        super(OrderPaymentTestCase, 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)
Exemplo n.º 2
0
    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')
Exemplo n.º 3
0
    def test_export_rewards_anonymous(self):
        request = self.request_factory.get('/')
        request.user = MockUser()

        project = ProjectFactory.create()
        reward = RewardFactory.create(project=project, amount=Money(10, 'EUR'))

        reward_order = OrderFactory.create(status='success', user=None)
        donation = DonationFactory.create(project=project,
                                          reward=reward,
                                          order=reward_order,
                                          name='test',
                                          amount=Money(100, 'EUR'))

        order = OrderFactory.create(status='success')
        DonationFactory.create(project=project, order=order)

        response = self.project_admin.export_rewards(request, project.id)
        reader = csv.DictReader(StringIO.StringIO(response.content))

        result = [line for line in reader]
        self.assertEqual(len(result), 1)
        line = result[0]

        self.assertEqual(line['Email'], '')
        self.assertEqual(line['Name'], '')
        self.assertEqual(line['Order id'], str(reward_order.id))
        self.assertEqual(line['Reward'], reward.title)
        self.assertEqual(line['Amount'], str(reward.amount))
        self.assertEqual(line['Actual Amount'], str(donation.amount))
        self.assertEqual(line['Name on Donation'], donation.name)
Exemplo n.º 4
0
    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()
Exemplo n.º 5
0
    def test_donation_stats_named_donation(self):
        self.some_project.status = self.campaign_status
        self.some_project.save()

        order = OrderFactory.create(user=self.another_user,
                                    status=StatusDefinition.SUCCESS)
        self.donation = DonationFactory.create(amount=Money(1000, 'EUR'),
                                               order=order,
                                               project=self.some_project,
                                               fundraiser=None)
        order = OrderFactory.create(user=self.another_user,
                                    status=StatusDefinition.SUCCESS)
        self.donation = DonationFactory.create(amount=Money(1000, 'EUR'),
                                               order=order,
                                               project=self.some_project,
                                               name='test-name',
                                               fundraiser=None)

        self.assertEqual(self.stats.donated_total, Money(2000, 'EUR'))
        # People involved:
        # - campaigner
        # - donator (another_user)
        # - donator (another_user on behalve of somebody else)
        self.assertEqual(self.stats.people_involved, 3)
        self.assertEqual(self.stats.participants, 1)
Exemplo n.º 6
0
    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')
Exemplo n.º 7
0
    def setUp(self):
        super(TestRefund, self).setUp()

        self.init_projects()

        self.project = ProjectFactory.create(status=ProjectPhase.objects.get(
            slug='refunded'))

        self.order = OrderFactory.create()
        self.order_payment = OrderPaymentFactory.create(
            order=self.order,
            payment_method='docdataIdeal',
            integration_data={'default_pm': 'ideal'},
        )
        payment = DocdataPaymentFactory.create(
            order_payment=self.order_payment,
            payment_cluster_key='123-4',
            default_pm='ideal',
            total_gross_amount=100)

        DonationFactory.create(
            project=self.project,
            order=self.order,
            amount=Money(100, 'EUR'),
        )
        payment.status = 'authorized'
        payment.save()
        payment.status = 'settled'
        payment.save()

        self.project.refresh_from_db()
Exemplo n.º 8
0
 def test_authorization_action(self, get_current_host, create_hash):
     """
     Play some posts that Vitepay might fire at us.
     """
     self.init_projects()
     order = OrderFactory.create()
     DonationFactory.create(amount=Money(2000, NGN), order=order)
     order_payment = OrderPaymentFactory.create(payment_method='interswitchWebpay', order=order)
     adapter = InterswitchPaymentAdapter(order_payment)
     authorization_action = adapter.get_authorization_action()
     redirect_url = 'https://onepercentclub.com/payments_interswitch/payment_response/{0}'.format(order_payment.id)
     data = {
         'hash': '123123',
         'product_id': '1234',
         'site_redirect_url': redirect_url,
         'local_date_time': None,
         'txn_ref': '-{0}'.format(order_payment.id),
         'cust_name': None,
         'currency': '566',
         'amount': 200000,
         'pay_item_name': None,
         'cust_id': None,
         'pay_item_id': '123',
         'site_name': 'testserver',
         'cust_id_desc': None,
         'cust_name_desc': None
     }
     self.assertEqual(authorization_action['url'], 'https://stageserv.interswitchng.com/test_paydirect/pay')
     self.assertEqual(authorization_action['payload'], data)
Exemplo n.º 9
0
    def setUp(self):
        super(TestPayoutAdapter, self).setUp()
        self.init_projects()
        campaign = ProjectPhase.objects.get(slug='campaign')
        self.project = ProjectFactory.create(status=campaign,
                                             amount_asked=Money(500, 'EUR'))

        order = OrderFactory()
        DonationFactory.create_batch(7,
                                     project=self.project,
                                     amount=Money(100, 'EUR'),
                                     order=order)
        order.locked()
        order.success()
        order.save()

        order = OrderFactory()
        DonationFactory.create_batch(4,
                                     project=self.project,
                                     amount=Money(150, 'USD'),
                                     order=order)
        order.locked()
        order.success()
        order.save()

        yesterday = now() - timedelta(days=1)
        self.project.deadline = yesterday
        self.project.save()

        self.mock_response = requests.Response()
        self.mock_response.status_code = 200

        self.adapter = DoradoPayoutAdapter(self.project)
Exemplo n.º 10
0
    def test_create_payment_redirect(self, charge, get_current_host):
        """
        Test Flutterwave payment that turns to success without otp (one time pin)
        """
        self.init_projects()
        order = OrderFactory.create()
        DonationFactory.create(amount=Money(150000, NGN), order=order)
        order_payment = OrderPaymentFactory.create(
            payment_method='flutterwaveCreditcard',
            order=order,
            integration_data=integration_data)
        adapter = FlutterwaveCreditcardPaymentAdapter(order_payment)
        authorization_action = adapter.get_authorization_action()

        self.assertEqual(adapter.payment.amount, '150000.00')
        self.assertEqual(adapter.payment.status, 'started')
        self.assertEqual(adapter.payment.transaction_reference, 'FLW005')
        self.assertEqual(
            authorization_action, {
                'method': 'get',
                'payload': {
                    'method': 'flutterwave-otp',
                    'text': redirect_response['data']['responsemessage']
                },
                'type': 'redirect',
                'url': redirect_response['data']['authurl']
            })
Exemplo n.º 11
0
    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")
Exemplo n.º 12
0
    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()
Exemplo n.º 13
0
    def test_results_stats_no_dates(self):
        self.page.start_date = None
        self.page.end_date = None
        self.page.save()

        long_ago = now() - timedelta(days=365 * 2)
        yesterday = now() - timedelta(days=1)
        user = BlueBottleUserFactory(is_co_financer=False)
        project = ProjectFactory(created=yesterday, owner=user)
        project = ProjectFactory(owner=user)
        order1 = OrderFactory(user=user, confirmed=yesterday, status='success')
        order1.created = yesterday
        order1.save()
        order2 = OrderFactory(user=user, confirmed=long_ago, status='success')
        order1.created = long_ago
        order1.save()

        DonationFactory(order=order1, amount=Money(50, 'EUR'), project=project)
        DonationFactory(order=order2, amount=Money(50, 'EUR'), project=project)

        block = StatsContent.objects.create_for_placeholder(self.placeholder, title='Look at us!')
        self.stat1 = StatFactory(type='manual', title='Poffertjes', value=3500, block=block)
        self.stat2 = StatFactory(type='donated_total', title='Donations', value=None, block=block)

        response = self.client.get(self.url)
        self.assertEquals(response.status_code, status.HTTP_200_OK)

        stats = response.data['blocks'][0]
        self.assertEqual(stats['type'], 'statistics')
        self.assertEqual(stats['title'], 'Look at us!')
        self.assertEqual(stats['stats'][0]['title'], self.stat1.title)
        self.assertEqual(stats['stats'][0]['value'], str(self.stat1.value))
        self.assertEqual(stats['stats'][1]['title'], self.stat2.title)
        self.assertEqual(stats['stats'][1]['value'], {"amount": Decimal('100'), "currency": "EUR"})
Exemplo n.º 14
0
    def test_project_donation_list_co_financing_is_unspecified(
            self, check_status_psp):
        # Co_financing order and donation
        order = OrderFactory.create(user=self.user2,
                                    status=StatusDefinition.SUCCESS)
        DonationFactory.create(amount=1500, project=self.project3, order=order)

        # Anonymous order and donation
        anonymous_order = OrderFactory.create(status=StatusDefinition.SUCCESS)
        DonationFactory.create(amount=1500,
                               project=self.project3,
                               order=anonymous_order,
                               anonymous=True)

        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'], 2,
            'Donations and anonymous donations should be returned')
        self.assertEqual(response.data['results'][0]['amount']['amount'],
                         1500.00)
        self.assertEqual(response.data['results'][1]['amount']['amount'],
                         1000.00)
Exemplo n.º 15
0
    def test_refund_created_payment(self):
        order = OrderFactory.create()
        order_payment = OrderPaymentFactory.create(
            order=order,
            payment_method='docdataIdeal',
            integration_data={'default_pm': 'ideal'},
        )
        DocdataPaymentFactory.create(order_payment=order_payment,
                                     payment_cluster_key='456-4',
                                     payment_cluster_id='test',
                                     default_pm='ideal',
                                     total_gross_amount=100)

        DonationFactory.create(
            project=self.project,
            order=order,
            amount=Money(100, 'EUR'),
        )

        with mock.patch.object(DocdataPaymentAdapter,
                               'refund_payment',
                               side_effect=self.mock_side_effect) as refund:
            refund_project(connection.tenant, self.project)

        self.order = Order.objects.get(pk=self.order.pk)
        self.assertEqual(refund.call_count, 1)
        self.assertEqual(self.order.status, 'refund_requested')

        self.order_payment.payment.status = 'refunded'
        self.order_payment.payment.save()

        self.order = Order.objects.get(pk=self.order.pk)
        self.assertEqual(self.order.status, 'cancelled')
Exemplo n.º 16
0
    def test_no_duplicate_follow(self):
        """ Test that no duplicate followers are created """
        self.assertEqual(Follow.objects.count(), 0)
        user = BlueBottleUserFactory.create()

        order = OrderFactory.create(user=user, status=StatusDefinition.CREATED)
        # Make sure to set Fundraiser to None. Otherwise, fundraiser is created
        DonationFactory(order=order, amount=35,
                        project=self.project, fundraiser=None)
        order.locked()
        order.success()
        order.save()

        self.assertEqual(Follow.objects.count(), 1)

        order = OrderFactory.create(user=user, status=StatusDefinition.CREATED)
        # Make sure to set Fundraiser to None. Otherwise, fundraiser is created
        DonationFactory(order=order, amount=35,
                        project=self.project, fundraiser=None)
        order.locked()
        order.success()
        order.save()

        self.assertEqual(Follow.objects.count(), 1)
        # Make sure to inspect the second Follow object, this is the Follow
        # object for the donation
        self.assertEqual(Follow.objects.all()[0].followed_object, self.project)
        self.assertEqual(Follow.objects.all()[0].user, user)
Exemplo n.º 17
0
    def pay(self, project, amount):
        order = OrderFactory.create()
        DonationFactory.create(project=project, order=order, amount=amount)
        order.locked()
        order.succeeded()
        order.save()

        return order
Exemplo n.º 18
0
    def pay(self, project, amount):
        order = OrderFactory.create()
        DonationFactory.create(project=project, order=order, amount=amount)
        order.locked()
        order.save()
        order.success()
        order.save()

        return order
Exemplo n.º 19
0
 def test_create_only_one_payment(self, get_current_host):
     self.init_projects()
     order = OrderFactory.create()
     DonationFactory.create(amount=Money(2000, NGN), order=order)
     order_payment = OrderPaymentFactory.create(payment_method='interswitchWebpay', order=order)
     InterswitchPaymentAdapter(order_payment)
     self.assertEqual(InterswitchPayment.objects.count(), 1)
     InterswitchPaymentAdapter(order_payment)
     self.assertEqual(InterswitchPayment.objects.count(), 1)
Exemplo n.º 20
0
    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)
Exemplo n.º 21
0
    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')
        )
Exemplo n.º 22
0
    def test_refund_requested(self):
        DonationFactory.create(order=self.order)
        self.order_payment.started()

        self.order_payment.save()

        self.order_payment.authorized()
        self.order_payment.save()

        self.order_payment.refund_requested()
        self.assertEqual(self.order.status, StatusDefinition.REFUND_REQUESTED)
Exemplo n.º 23
0
    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')
        )
Exemplo n.º 24
0
    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')
Exemplo n.º 25
0
 def setUp(self):
     super(TestProjectExport, self).setUp()
     self.project = ProjectFactory.create(amount_asked=5000)
     self.user = BlueBottleUserFactory.create()
     self.orders = OrderFactory.create_batch(7)
     for order in self.orders:
         DonationFactory.create(project=self.project, order=order)
         order_payment = OrderPaymentFactory(order=order)
         payment = PaymentFactory(order_payment=order_payment)
         payment.status = 'settled'
         payment.save()
Exemplo n.º 26
0
    def test_wallpost_mail_fundraiser(self):
        """ Test that the relevant people get an email when the email_followers option is selected for a fundraiser """

        # On a Fundraiser page, people who posted to the wall and who donated get an email --> Followers
        self.assertEqual(Follow.objects.count(), 0)

        # A user creates a fundraiser
        fundraiser_person = BlueBottleUserFactory.create()
        fundraiser = FundraiserFactory(project=self.project,
                                       owner=fundraiser_person)

        # Two people donate to the fundraiser
        donator1 = BlueBottleUserFactory.create()
        order = OrderFactory.create(user=donator1,
                                    status=StatusDefinition.CREATED)
        DonationFactory(order=order, amount=35,
                        project=self.project,
                        fundraiser=fundraiser)
        order.locked()
        order.success()
        order.save()

        donator2 = BlueBottleUserFactory.create()
        order2 = OrderFactory.create(user=donator2,
                                     status=StatusDefinition.CREATED)
        DonationFactory(order=order2, amount=35,
                        project=self.project,
                        fundraiser=fundraiser)

        order2.locked()
        order2.success()
        order2.save()

        # The fundraiser owner creates a wallpost to followers
        TextWallpostFactory.create(content_object=fundraiser,
                                   author=fundraiser_person,
                                   text="test_fundraiser",
                                   email_followers=True)

        mail_count = 0
        self.assertEqual(Follow.objects.count(), 3)

        # When the fundraiser sends an email to the followers he doesn't get one himself
        receivers = [donator1.email, donator2.email]

        for email in mail.outbox:
            if "New wallpost on" in email.subject:
                mail_count += 1
                self.assertTrue(email.to[0] in receivers)
                receivers.remove(email.to[0])

        self.assertEqual(mail_count, 2)
        self.assertEqual(receivers, [])
Exemplo n.º 27
0
 def test_create_success_payment(self):
     """
     Test External payment
     """
     order = OrderFactory.create()
     DonationFactory.create(amount=Money(70, EUR), order=order)
     order_payment = OrderPaymentFactory.create(
         payment_method='externalMoney', order=order)
     order_payment.started()
     adapter = ExternalPaymentAdapter(order_payment)
     adapter.check_payment_status()
     self.assertEqual(adapter.payment.status, 'settled')
Exemplo n.º 28
0
    def test_tags_generation(self, queue_mock):
        project = ProjectFactory.create()
        DonationFactory.create(project=project)

        wallpost = TextWallpostFactory.create()
        expected_tags = {'type': 'wallpost', 'tenant': u'test'}
        expected_fields = {'id': wallpost.id, 'user_id': wallpost.author.id}

        args, kwargs = queue_mock.call_args
        self.assertEqual(kwargs['tags'], expected_tags)
        self.assertEqual(kwargs['fields'], expected_fields)
        self.assertEqual(kwargs['timestamp'], wallpost.created)
Exemplo n.º 29
0
    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')
Exemplo n.º 30
0
    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')
Exemplo n.º 31
0
    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
        )
Exemplo n.º 32
0
 def test_create_payment_incomplete(self, charge, get_current_host):
     """
     Test Flutterwave payment throws an error when incomplete data is sent
     """
     self.init_projects()
     order = OrderFactory.create()
     DonationFactory.create(amount=Money(150000, NGN), order=order)
     order_payment = OrderPaymentFactory.create(
         payment_method='flutterwaveCreditcard',
         order=order,
         integration_data={'card_number': '123blabla'})
     with self.assertRaises(PaymentException):
         FlutterwaveCreditcardPaymentAdapter(order_payment)
Exemplo n.º 33
0
    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)
Exemplo n.º 34
0
    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])
Exemplo n.º 35
0
 def test_create_payment_flutter_fail(self, charge, get_current_host):
     """
     Make sure we catch errors from Flutterwave
     """
     self.init_projects()
     order = OrderFactory.create()
     DonationFactory.create(amount=Money(150000, NGN), order=order)
     order_payment = OrderPaymentFactory.create(
         payment_method='flutterwaveCreditcard',
         order=order,
         integration_data=integration_data)
     adapter = FlutterwaveCreditcardPaymentAdapter(order_payment)
     with self.assertRaises(PaymentException):
         adapter.get_authorization_action()
Exemplo n.º 36
0
    def test_create_payment(self, get_current_host):
        self.init_projects()
        order = OrderFactory.create()
        DonationFactory.create(amount=Money(2000, NGN), order=order)
        order_payment = OrderPaymentFactory.create(payment_method='interswitchWebpay', order=order)
        adapter = InterswitchPaymentAdapter(order_payment)
        self.assertEqual(adapter.payment.amount, 200000)

        #  Check generated payload
        payload = adapter._get_payload()
        self.assertEqual(payload['product_id'], '1234')
        self.assertEqual(payload['amount'], 200000)
        tenant = connection.tenant
        self.assertEqual(payload['txn_ref'], '{0}-{1}'.format(tenant.name, order_payment.id))
Exemplo n.º 37
0
    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)
Exemplo n.º 38
0
 def setUp(self):
     super(TestPayoutExport, self).setUp()
     self.project = ProjectFactory.create(amount_asked=5000)
     self.user = BlueBottleUserFactory.create()
     self.orders = OrderFactory.create_batch(7)
     for order in self.orders:
         DonationFactory.create(project=self.project, order=order)
         order_payment = OrderPaymentFactory(order=order)
         payment = PaymentFactory(order_payment=order_payment)
         payment.status = 'settled'
         payment.save()
     self.payout = ProjectPayoutFactory(project=self.project,
                                        amount_payable=Money(125.00, 'EUR'),
                                        amount_raised=Money(175.0, 'EUR'),
                                        status='settled')
Exemplo n.º 39
0
    def test_successful_project_donation_list(self, check_status_psp):
        setattr(properties, 'SHOW_DONATION_AMOUNTS', True)
        # Unsuccessful donations should not be shown
        order = OrderFactory.create(user=self.user2)
        reward = RewardFactory.create(project=self.project3)
        DonationFactory.create(amount=2000, project=self.project3, reward=reward,
                               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.assertIn('amount', response.data['results'][0])
        self.assertIn('reward', response.data['results'][0])
Exemplo n.º 40
0
    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, '*****@*****.**')  # 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)
Exemplo n.º 41
0
    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)
Exemplo n.º 42
0
    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'))
Exemplo n.º 43
0
    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')
        )
Exemplo n.º 44
0
    def setUp(self):
        super(TestMyProjectDonationList, self).setUp()

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

        # User 2 makes a donation
        order = OrderFactory.create(user=self.user2)
        DonationFactory.create(amount=1000, project=self.project3,
                               order=order)

        order.locked()
        order.succeeded()

        self.project_donation_list_url = reverse('my-project-donation-list')
Exemplo n.º 45
0
    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'))
Exemplo n.º 46
0
    def test_journal_multicurrency(self):
        self.donation = DonationFactory.create(
            amount=Money(100, 'EUR'),
            project=self.project,
            order__user=self.user
        )

        # We should now have one journal
        self.assertEqual(DonationJournal.objects.count(), 1)

        # Update the amount to USD
        self.donation.amount=Money(100, 'USD')
        self.donation.save()

        # We should now have 2 journals
        self.assertEqual(DonationJournal.objects.count(), 2)

        # Update the amount to USD
        self.donation.amount=Money(150, 'USD')
        self.donation.save()

        self.assertEqual(DonationJournal.objects.count(), 3)

        for journal in DonationJournal.objects.all():
            if journal.amount.currency == Currency('EUR'):
                self.assertEqual(journal.get_journal_total(), Money(100, 'EUR'))
            else:
                self.assertEqual(journal.get_journal_total(), Money(150, 'USD'))
Exemplo n.º 47
0
    def test_calculate_donation_count(self):
        """ Test the counter for the number of donations a user has done """
        self.assertEqual(self.user.donation_count, 0)

        order = OrderFactory.create(user=self.user)
        DonationFactory.create(amount=1000, order=order)

        # Only successful or pending orders/donations are counted
        self.assertEqual(self.user.donation_count, 0)

        # Set donation to pending to be included in count
        order.locked()
        order.save()
        order.pending()
        order.save()
        self.assertEqual(self.user.donation_count, 1)
Exemplo n.º 48
0
    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.project.refresh_from_db()
        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'))
Exemplo n.º 49
0
    def setUp(self):
        super(OrderPaymentTestCase, 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)
Exemplo n.º 50
0
    def test_no_campaign_started_date(self):
        """
        Test that a campaign that never started gets the phase stopped.
        """
        now = timezone.now()

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

        order = OrderFactory.create()

        donation = DonationFactory.create(project=some_project,
                                          order=order,
                                          amount=20)
        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.closed)
Exemplo n.º 51
0
    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)
Exemplo n.º 52
0
    def test_less_than_20_done_stopped(self):
        """
        Test that a campaign with 20 euros or less and hits the deadline gets
        the status "Done-stopped"
        """
        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=20)
        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.closed)
Exemplo n.º 53
0
    def test_no_campaign_started_date(self):
        """
        Test that a campaign that never started gets the phase stopped.
        """
        now = timezone.now()

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

        order = OrderFactory.create()

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

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

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

        call_command('cron_status_realised', 'test')

        project = Project.objects.get(title='test')
        self.assertEqual(project.status, self.closed)
Exemplo n.º 54
0
    def test_less_than_20_done_stopped(self):
        """
        Test that a campaign with 20 euros or less and hits the deadline gets
        the status "Done-stopped"
        """
        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=20
        )
        donation.save()

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

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

        call_command('cron_status_realised', 'test')

        project = Project.objects.get(title='test')
        self.assertEqual(project.status, self.closed)
Exemplo n.º 55
0
    def test_fully_funded(self):
        """
        Test that a campaign that is fully funded
        and hits the deadline gets the status done-complete
        """
        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=500
        )
        donation.save()

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

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

        call_command('cron_status_realised', 'test')

        project = Project.objects.get(title='test')
        self.assertEqual(project.status, self.complete)
Exemplo n.º 56
0
    def setUp(self):
        super(TestDonationEmails, self).setUp()
        self.user = BlueBottleUserFactory.create(first_name='user')

        self.project_owner = BlueBottleUserFactory.create(first_name='projectowner')
        self.some_project = ProjectFactory.create(owner=self.project_owner)

        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)

        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
        )
Exemplo n.º 57
0
    def test_successful_my_fundraiser_donation_list(self, check_status_psp):
        # Unsuccessful donations should not be shown
        order = OrderFactory.create(user=self.user2)
        donation = DonationFactory.create(amount=2000, project=self.project4, fundraiser=self.fundraiser, order=order)

        response = self.client.get(self.fundraiser_donation_list_url, {'fundraiser': self.fundraiser.pk}, HTTP_AUTHORIZATION=self.user1_token)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(len(response.data), 1, 'Only the successful donation should be returned')
Exemplo n.º 58
0
    def test_system_wallpost(self, queue_mock):
        project = ProjectFactory.create()
        donation = DonationFactory.create(project=project)

        previous_call_count = queue_mock.call_count

        SystemWallpostFactory.create(related_object=donation, content_object=project)
        self.assertEqual(queue_mock.call_count, previous_call_count,
                         'Analytics should not be sent for system wallposts')
Exemplo n.º 59
0
    def setUp(self):
        super(PaymentErrorTests, self).setUp()
        self.donation1 = DonationFactory.create(amount=500)
        self.donation2 = DonationFactory.create(amount=700)
        self.donation3 = DonationFactory.create(amount=5)

        self.user1 = self.donation1.order.user
        self.user1.first_name = 'Jimmy 1%'
        self.user1.save()

        self.user1_token = "JWT {0}".format(self.user1.get_jwt_token())

        self.user2 = self.donation2.order.user
        self.user2.last_name = "Veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryverylongname"
        self.user2.save()
        self.user2_token = "JWT {0}".format(self.user2.get_jwt_token())

        self.order_payment_url = reverse('manage-order-payment-list')
Exemplo n.º 60
0
    def setUp(self):
        super(TestLatestDonationListApi, self).setUp()
        self.user2.is_staff = True
        self.user2.save()

        self.project = ProjectFactory.create(amount_asked=5000,
                                             owner=self.user1)

        self.project.set_status('campaign')

        # User 2 makes a donation
        order = OrderFactory.create(user=self.user2)
        DonationFactory.create(amount=1000, project=self.project,
                               order=order)

        order.locked()
        order.save()
        order.success()
        order.save()