コード例 #1
0
ファイル: test_unit.py プロジェクト: repodevs/bluebottle
    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)
コード例 #2
0
ファイル: test_models.py プロジェクト: raux/bluebottle
    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)
コード例 #3
0
ファイル: test_unit.py プロジェクト: repodevs/bluebottle
    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)
コード例 #4
0
ファイル: test_admin.py プロジェクト: raux/bluebottle
    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)
コード例 #5
0
    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()
コード例 #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')
コード例 #7
0
ファイル: test_unit.py プロジェクト: raux/bluebottle
    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)
コード例 #8
0
ファイル: test_api.py プロジェクト: raux/bluebottle
    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)
コード例 #9
0
ファイル: test_api.py プロジェクト: pombredanne/bluebottle
    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)
コード例 #10
0
ファイル: test_api.py プロジェクト: raux/bluebottle
    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"})
コード例 #11
0
ファイル: test_models.py プロジェクト: raux/bluebottle
    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, [])
コード例 #12
0
ファイル: test_mails.py プロジェクト: repodevs/bluebottle
    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
        )
コード例 #13
0
    def setUp(self):
        super(MonthlyDonationAdminTest, self).setUp()

        self.app.extra_environ['HTTP_HOST'] = str(self.tenant.domain_url)
        self.superuser = BlueBottleUserFactory.create(is_staff=True,
                                                      is_superuser=True)

        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(
                ProjectFactory.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.save()
        order.success()
        order.save()

        # 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()

        # Create a monthly donor with a preferred project
        self.monthly_donor1 = MonthlyDonorFactory(user=self.user1, amount=25)
        self.monthly_donor1_project = MonthlyDonorProjectFactory(
            donor=self.monthly_donor1, project=self.projects[0])

        # Create a monthly donor without preferred projects
        self.monthly_donor2 = MonthlyDonorFactory(user=self.user2, amount=100)
        Project.update_popularity()
コード例 #14
0
ファイル: test_mail.py プロジェクト: raux/bluebottle
    def setUp(self):
        super(TestPledgeMails, self).setUp()

        self.init_projects()

        self.user = BlueBottleUserFactory(can_pledge=True)
        self.project_owner = BlueBottleUserFactory(username='******',
                                                   email='*****@*****.**',
                                                   password='******')
        self.organization = OrganizationFactory.create(name='test_org',
                                                       slug='test_org')

        self.project = ProjectFactory(owner=self.project_owner,
                                      organization=self.organization,
                                      title='Project 1',
                                      amount_needed=1111,
                                      amount_asked=1111)
        self.order = OrderFactory.create(user=self.user)
        self.donation = DonationFactory(amount=60,
                                        order=self.order,
                                        project=self.project,
                                        fundraiser=None)

        self.order_payment = OrderPaymentFactory.create(
            order=self.order, payment_method='pledgeStandard')
        self.order_payment.pledged()
        self.order_payment.save()
コード例 #15
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)
コード例 #16
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')
        )
コード例 #17
0
ファイル: test_unit.py プロジェクト: jfterpstra/bluebottle
    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')
        )
コード例 #18
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")
コード例 #19
0
    def setUp(self):
        self.order = OrderFactory.create(total=Money(200, 'EUR'))
        self.order_payment = OrderPaymentFactory.create(
            payment_method='docdata', order=self.order)

        PaymentFactory.create(order_payment=self.order_payment)
        self.adapter = BasePaymentAdapter(self.order_payment)
コード例 #20
0
    def test_incomplete_userdata(self, mock_client):
        # Mock response to creating the payment at docdata
        instance = mock_client.return_value
        instance.create.return_value = {'order_key': 123, 'order_id': 123}

        patch.object(DocdataPaymentAdapter, 'create_payment',
                     fake_create_payment)

        user = BlueBottleUserFactory()
        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'], 'Unknown')
        self.assertEqual(user_data['house_number'], 'Unknown')
        self.assertEqual(user_data['postal_code'], 'Unknown')
        self.assertEqual(user_data['city'], 'Unknown')
        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'], '')
コード例 #21
0
ファイル: test_unit.py プロジェクト: jfterpstra/bluebottle
    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'))
コード例 #22
0
ファイル: test_unit.py プロジェクト: jfterpstra/bluebottle
    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()
コード例 #23
0
ファイル: test_models.py プロジェクト: jfterpstra/bluebottle
    def test_incomplete_userdata(self, mock_client):
        # Mock response to creating the payment at docdata
        instance = mock_client.return_value
        instance.create.return_value = {'order_key': 123, 'order_id': 123}

        patch.object(DocdataPaymentAdapter, 'create_payment',
                     fake_create_payment)

        user = BlueBottleUserFactory()
        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'], 'Unknown')
        self.assertEqual(user_data['house_number'], 'Unknown')
        self.assertEqual(user_data['postal_code'], 'Unknown')
        self.assertEqual(user_data['city'], 'Unknown')
        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'], '')
コード例 #24
0
ファイル: test_api.py プロジェクト: raux/bluebottle
    def test_donation_update_order_change_currency(self,
                                                   mock_check_status_psp):
        """ Test that an update to a donation where the order does has status CREATED produces 200 OK response"""

        order = OrderFactory.create(user=self.user,
                                    status=StatusDefinition.CREATED)

        donation = DonationFactory(order=order, amount=Money(100, 'USD'))

        updated_donation = {
            "project": donation.project.slug,
            "order": order.id,
            "amount": {
                'amount': 200,
                'currency': 'EUR'
            }
        }

        self.assertEqual(Donation.objects.count(), 1)
        response = self.client.put(reverse('manage-donation-detail',
                                           kwargs={'pk': donation.id}),
                                   updated_donation,
                                   token=self.user_token)

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(Donation.objects.count(), 1)

        self.assertEqual(response.data['amount'], {
            'currency': 'EUR',
            'amount': Decimal(200)
        })
コード例 #25
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')
コード例 #26
0
ファイル: test_models.py プロジェクト: maykinmedia/bluebottle
    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'], '')
コード例 #27
0
    def setUp(self):
        self.user = BlueBottleUserFactory.create(can_pledge=True)

        self.order = OrderFactory.create(user=self.user)
        self.order_payment = OrderPaymentFactory.create(
            order=self.order, user=self.user, payment_method='pledgeStandard'
        )
コード例 #28
0
ファイル: test_models.py プロジェクト: pombredanne/bluebottle
    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)
コード例 #29
0
    def test_abnormal_address_data(self, mock_client):
        # Mock response to creating the payment at docdata
        instance = mock_client.return_value
        instance.create.return_value = {'order_key': 123, 'order_id': 123}

        patch.object(DocdataPaymentAdapter, 'create_payment',
                     fake_create_payment)

        user = BlueBottleUserFactory()
        CountryFactory(name='Netherlands', alpha2_code='NL')

        # Update user address with abnormal line1
        user.address.line1 = '1a'
        user.address.save()

        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['street'], 'Unknown')
コード例 #30
0
ファイル: test_models.py プロジェクト: pombredanne/bluebottle
    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)
コード例 #31
0
    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')
コード例 #32
0
ファイル: test_models.py プロジェクト: raux/bluebottle
    def test_create_follow_donation_with_login(self):
        """
        Test that a Follow object is created if a user does a donation
        to a project with login during donation flow
        """
        self.assertEqual(Follow.objects.count(), 0)

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

        self.assertEqual(Follow.objects.count(), 1)
        self.assertEqual(Follow.objects.all()[0].followed_object, self.project)
        self.assertEqual(Follow.objects.all()[0].user, self.another_user)
コード例 #33
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()
コード例 #34
0
ファイル: test_api.py プロジェクト: raux/bluebottle
    def setUp(self):
        super(DonationApiTestCase, self).setUp()

        self.create_session()

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

        self.init_projects()

        self.project1 = ProjectFactory.create(amount_asked=5000)
        self.project1.set_status('campaign')

        self.project2 = ProjectFactory.create(amount_asked=3750)
        self.project2.set_status('campaign')

        self.manage_order_list_url = reverse('order-manage-list')
        self.manage_donation_list_url = reverse('manage-donation-list')

        self.user = BlueBottleUserFactory.create()
        self.user_token = "JWT {0}".format(self.user.get_jwt_token())

        self.user2 = BlueBottleUserFactory.create(is_co_financer=True)
        self.user2_token = "JWT {0}".format(self.user2.get_jwt_token())

        self.project = ProjectFactory.create()
        self.order = OrderFactory.create(user=self.user)

        self.dollar_project = ProjectFactory.create(currencies=['USD'])
        self.multi_project = ProjectFactory.create(
            currencies=['EUR', 'USD', 'NGN'])
コード例 #35
0
ファイル: test_models.py プロジェクト: jfterpstra/bluebottle
    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')
コード例 #36
0
    def setUp(self):
        super(TestDonationRewardStock, self).setUp()

        self.init_projects()

        self.user = BlueBottleUserFactory.create()
        self.user_token = "JWT {0}".format(self.user.get_jwt_token())

        self.project = ProjectFactory.create(amount_asked=5000)
        self.project.set_status('campaign')

        self.reward = RewardFactory(project=self.project, limit=1)

        self.donations_url = reverse('manage-donation-list')
        self.reward_url = reverse('reward-detail', args=(self.reward.pk, ))

        self.donor = BlueBottleUserFactory.create()
        self.donor_token = "JWT {0}".format(self.donor.get_jwt_token())

        self.order = OrderFactory.create(user=self.donor)

        self.donation_data = {
            'order': self.order.id,
            'reward': self.reward.id,
            'amount': {
                'amount': self.reward.amount.amount,
                'currency': str(self.reward.amount.currency)
            },
            'project': self.project.slug,
        }
コード例 #37
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'))
コード例 #38
0
ファイル: test_models.py プロジェクト: jfterpstra/bluebottle
    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)
コード例 #39
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)
コード例 #40
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']
            })
コード例 #41
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'))
コード例 #42
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()
コード例 #43
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)
コード例 #44
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)
コード例 #45
0
    def test_fully_funded_before_deadline(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.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.assertTrue(project.campaign_funded)
コード例 #46
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)
コード例 #47
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)
コード例 #48
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)
コード例 #49
0
ファイル: test_models.py プロジェクト: raux/bluebottle
    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)
コード例 #50
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)
コード例 #51
0
ファイル: test_api.py プロジェクト: maykinmedia/bluebottle
    def setUp(self):
        settings.SESSION_ENGINE = 'django.contrib.sessions.backends.file'
        engine = import_module(settings.SESSION_ENGINE)
        store = engine.SessionStore()
        store.save()
        self.session = store
        self.client.cookies[settings.SESSION_COOKIE_NAME] = store.session_key

        self.addCleanup(self._clear_session)

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

        self.init_projects()
        self.project1 = ProjectFactory.create(amount_asked=5000)
        self.project1.set_status('campaign')

        self.project2 = ProjectFactory.create(amount_asked=3750)
        self.project2.set_status('campaign')

        self.manage_order_list_url = reverse('manage-order-list')
        self.manage_donation_list_url = reverse('manage-donation-list')

        self.user = BlueBottleUserFactory.create()
        self.user_token = "JWT {0}".format(self.user.get_jwt_token())

        self.user2 = BlueBottleUserFactory.create()
        self.user2_token = "JWT {0}".format(self.user2.get_jwt_token())

        self.project = ProjectFactory.create()
        self.order = OrderFactory.create(user=self.user)
コード例 #52
0
ファイル: test_api.py プロジェクト: jfterpstra/bluebottle
    def setUp(self):
        super(DonationApiTestCase, self).setUp()

        self.create_session()

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

        self.init_projects()

        self.project1 = ProjectFactory.create(amount_asked=5000)
        self.project1.set_status('campaign')

        self.project2 = ProjectFactory.create(amount_asked=3750)
        self.project2.set_status('campaign')

        self.manage_order_list_url = reverse('manage-order-list')
        self.manage_donation_list_url = reverse('manage-donation-list')

        self.user = BlueBottleUserFactory.create()
        self.user_token = "JWT {0}".format(self.user.get_jwt_token())

        self.user2 = BlueBottleUserFactory.create(is_co_financer=True)
        self.user2_token = "JWT {0}".format(self.user2.get_jwt_token())

        self.project = ProjectFactory.create()
        self.order = OrderFactory.create(user=self.user)

        self.dollar_project = ProjectFactory.create(currencies=['USD'])
        self.multi_project = ProjectFactory.create(currencies=['EUR', 'USD', 'NGN'])
コード例 #53
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.save()
        order.success()
        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'))
コード例 #54
0
ファイル: test_mails.py プロジェクト: maykinmedia/bluebottle
    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
        )
コード例 #55
0
ファイル: test_api.py プロジェクト: pombredanne/bluebottle
    def test_successful_my_project_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.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), 1, 'Only the successful donation should be returned')
コード例 #56
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
コード例 #57
0
ファイル: test_api.py プロジェクト: maykinmedia/bluebottle
    def setUp(self):
        super(TestUnauthenticatedDonationCreate, self).setUp()

        self.order_anon = OrderFactory.create()

        s = self.session
        s['new_order_id'] = self.order_anon.pk
        s.save()
コード例 #58
0
ファイル: test_models.py プロジェクト: pombredanne/bluebottle
    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, a fundraiser is created
        donation = DonationFactory(order=order, amount=35, project=self.project, fundraiser=None)

        order = OrderFactory.create(user=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)

        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)
コード例 #59
0
ファイル: test_api.py プロジェクト: maykinmedia/bluebottle
    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')
コード例 #60
0
ファイル: test_models.py プロジェクト: pombredanne/bluebottle
    def setUp(self):
        super(PaymentsMockTestCase, self).setUp()

    	self.init_projects()

        self.order = OrderFactory.create(total=35)
        self.order_payment = OrderPaymentFactory.create(order=self.order, payment_method='mock')
        self.service = PaymentService(order_payment=self.order_payment)