Beispiel #1
0
    def test_calculate_fundraiser_count(self):
        """ Test the counter for the number of fundraisers a user is owner of """
        self.assertEqual(self.user.fundraiser_count, 0)

        FundraiserFactory.create(amount=4000, owner=self.user)
        self.assertEqual(self.user.fundraiser_count, 1)
        FundraiserFactory.create(amount=4000, owner=self.user)
        self.assertEqual(self.user.fundraiser_count, 2)
Beispiel #2
0
    def test_calculate_fundraiser_count(self):
        """ Test the counter for the number of fundraisers a user is owner of """
        self.assertEqual(self.user.fundraiser_count, 0)

        FundraiserFactory.create(amount=4000, owner=self.user)
        self.assertEqual(self.user.fundraiser_count, 1)
        FundraiserFactory.create(amount=4000, owner=self.user)
        self.assertEqual(self.user.fundraiser_count, 2)
Beispiel #3
0
    def test_create_single_donation(self, check_status_psp):
        """
        Test donation in the current donation flow where we have just one donation that can't be deleted.
        """

        # Create an order
        response = self.client.post(self.manage_order_list_url, {}, HTTP_AUTHORIZATION=self.user1_token)
        order_id = response.data['id']

        fundraiser = FundraiserFactory.create(amount=100)

        donation1 = {
            "fundraiser": fundraiser.pk,
            "project": fundraiser.project.slug,
            "order": order_id,
            "amount": 50
        }

        response = self.client.post(self.manage_donation_list_url, donation1, HTTP_AUTHORIZATION=self.user1_token)
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        self.assertEqual(response.data['status'], 'created')
        donation_id = response.data['id']

        # Check that the order total is equal to the donation amount
        order_url = "{0}{1}".format(self.manage_order_list_url, order_id)
        response = self.client.get(order_url, HTTP_AUTHORIZATION=self.user1_token)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['total'], 50)
Beispiel #4
0
    def setUp(self):
        super(TestDonationList, self).setUp()

        self.init_projects()

        # 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')
Beispiel #5
0
    def test_create_single_donation(self, check_status_psp):
        """
        Test donation in the current donation flow where we have just one donation that can't be deleted.
        """

        # Create an order
        response = self.client.post(self.manage_order_list_url, {},
                                    token=self.user1_token)
        order_id = response.data['id']

        fundraiser = FundraiserFactory.create(amount=100)

        donation1 = {
            "fundraiser": fundraiser.pk,
            "project": fundraiser.project.slug,
            "order": order_id,
            "amount": 50
        }

        response = self.client.post(self.manage_donation_list_url,
                                    donation1,
                                    token=self.user1_token)
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        self.assertEqual(response.data['status'], 'created')

        # Check that the order total is equal to the donation amount
        order_url = "{0}{1}".format(self.manage_order_list_url, order_id)
        response = self.client.get(order_url, token=self.user1_token)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['total']['amount'], 50.00)
        self.assertEqual(response.data['total']['currency'], 'EUR')
        self.assertEqual(response.data['donations'][0]['name'], None)
Beispiel #6
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
        )
Beispiel #7
0
    def setUp(self):
        super(TestMyFundraiserDonationList, self).setUp()

        self.project4 = ProjectFactory.create(amount_asked=5000, owner=self.user1)
        self.project4.set_status('campaign')
        self.fundraiser = FundraiserFactory.create(amount=4000, owner=self.user1, project=self.project4)

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

        order.locked()
        order.succeeded()

        self.fundraiser_donation_list_url = reverse('my-fundraiser-donation-list')
Beispiel #8
0
    def setUp(self):
        super(TestDonationEmails, self).setUp()
        self.init_projects()

        self.user = BlueBottleUserFactory.create(first_name='user',
                                                 last_name='userson')
        self.user.address.line1 = "'s Gravenhekje 1A"
        self.user.address.city = "Mokum A"
        self.user.save()

        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)
Beispiel #9
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
        )
Beispiel #10
0
    def setUp(self):
        super(WallpostPermissionsTest, self).setUp()

        self.init_projects()

        self.owner = BlueBottleUserFactory.create(
            password='******', first_name='someName', last_name='someLast')
        self.owner_token = "JWT {0}".format(self.owner.get_jwt_token())

        self.project = ProjectFactory.create(owner=self.owner)
        self.fundraiser = FundraiserFactory.create(owner=self.owner)
        self.task = TaskFactory.create(author=self.owner)

        self.other_user = BlueBottleUserFactory.create()
        self.other_token = "JWT {0}".format(
            self.other_user.get_jwt_token())

        self.media_wallpost_url = reverse('media_wallpost_list')
Beispiel #11
0
    def test_create_donations_with_names(self, check_status_psp):
        """
        Test donation with specifying a custom donor name.
        """

        # Create an order
        response = self.client.post(self.manage_order_list_url, {},
                                    token=self.user1_token)
        order_id = response.data['id']

        fundraiser = FundraiserFactory.create(amount=100)

        donation1 = {
            "fundraiser": fundraiser.pk,
            "project": fundraiser.project.slug,
            "order": order_id,
            "name": 'Tante Sjaan',
            "amount": 7.5
        }
        donation2 = {
            "fundraiser": fundraiser.pk,
            "project": fundraiser.project.slug,
            "order": order_id,
            "name": 'Ome Piet',
            "amount": 12.5
        }

        response = self.client.post(self.manage_donation_list_url,
                                    donation1,
                                    token=self.user1_token)
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        response = self.client.post(self.manage_donation_list_url,
                                    donation2,
                                    token=self.user1_token)
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)

        # Check that the order total is equal to the donation amount
        order_url = "{0}{1}".format(self.manage_order_list_url, order_id)
        response = self.client.get(order_url, token=self.user1_token)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['total']['amount'], 20.00)
        self.assertEqual(response.data['total']['currency'], 'EUR')
        self.assertEqual(response.data['donations'][1]['name'], 'Tante Sjaan')
        self.assertEqual(response.data['donations'][0]['name'], 'Ome Piet')
Beispiel #12
0
    def setUp(self):
        super(WallpostPermissionsTest, self).setUp()

        self.init_projects()

        self.owner = BlueBottleUserFactory.create(password='******',
                                                  first_name='someName',
                                                  last_name='someLast')
        self.owner_token = "JWT {0}".format(self.owner.get_jwt_token())

        self.project = ProjectFactory.create(owner=self.owner)
        self.fundraiser = FundraiserFactory.create(owner=self.owner)
        self.task = TaskFactory.create(author=self.owner)

        self.other_user = BlueBottleUserFactory.create()
        self.other_token = "JWT {0}".format(self.other_user.get_jwt_token())

        self.media_wallpost_url = reverse('media_wallpost_list')
        self.text_wallpost_url = reverse('text_wallpost_list')
        self.wallpost_url = reverse('wallpost_list')
Beispiel #13
0
    def setUp(self):
        super(TestMyFundraiserDonationList, self).setUp()

        self.project4 = ProjectFactory.create(amount_asked=5000,
                                              owner=self.user1)
        self.project4.set_status('campaign')
        self.fundraiser = FundraiserFactory.create(amount=4000,
                                                   owner=self.user1,
                                                   project=self.project4)

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

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

        self.fundraiser_donation_list_url = reverse(
            'my-fundraiser-donation-list')
Beispiel #14
0
 def test_posted_on_fundraiser(self):
     self.wallpost.content_object = FundraiserFactory.create()
     self.wallpost.save()
     posted_on = self.admin.posted_on(self.wallpost)
     self.assertTrue('Fundraiser:' in posted_on)
     self.assertTrue(self.wallpost.content_object.title in posted_on)