Esempio n. 1
0
    def init_projects(self):
        """
        Set up some basic models needed for project creation.
        """
        phase_data = [{'id': 1, 'name': 'Plan - New', 'viewable': False},
                      {'id': 2, 'name': 'Plan - Submitted', 'viewable': False},
                      {'id': 3, 'name': 'Plan - Needs Work', 'viewable': False},
                      {'id': 4, 'name': 'Plan - Rejected', 'viewable': False},
                      {'id': 6, 'name': 'Plan - Accepted', 'viewable': True},
                      {'id': 5, 'name': 'Campaign', 'viewable': True},
                      {'id': 7, 'name': 'Stopped', 'viewable': False},
                      {'id': 8, 'name': 'Done - Complete', 'viewable': True},
                      {'id': 9, 'name': 'Done - Incomplete', 'viewable': True}]

        theme_data = [{'id': 1, 'name': 'Education'},
                      {'id': 2, 'name': 'Environment'}]

        language_data = [{'id': 1, 'code': 'en', 'language_name': 'English', 'native_name': 'English'},
                         {'id': 2, 'code': 'nl', 'language_name': 'Dutch', 'native_name': 'Nederlands'}]

        partner_data = [{'id': 1, 'slug': 'cheetah', 'name': 'The Cheetah Campaign'},
                        {'id': 2, 'slug': 'macro_micro', 'name': 'Macro Micro'}]

        for partner in partner_data:
            PartnerFactory.create(**partner)

        for phase in phase_data:
            ProjectPhaseFactory.create(**phase)

        for theme in theme_data:
            ProjectThemeFactory.create(**theme)

        for language in language_data:
            LanguageFactory.create(**language)
    def test_create_partner_project(self):
        """
        Creating a partner project should set the partner on the new project
        """
        self.partner = PartnerFactory.create()
        self.visit_path('/my/projects/pp:{0}'.format(self.partner.slug))

        # Wait for title to show
        self.wait_for_element_css("h3")
        self.assertEqual(self.browser.find_by_css("h3").text, self.partner.name.upper())
    def test_amounts_paid_cheetah(self):
        """ Test amounts for paid donations. """

        # Setup organization
        organization = self.project.organization
        organization.account_name = 'Funny organization'
        organization.account_iban = 'NL90ABNA0111111111'
        organization.account_bic = 'ABNANL2A'
        organization.save()

        cheetah_partner = PartnerFactory.create(slug='cheetah')

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

        # Update phase to act.
        self._reload_project()
        self.project.partner_organization = cheetah_partner
        self.project.status = ProjectPhase.objects.get(slug='realised')

        self.project.status = ProjectPhase.objects.get(slug='realised')
        self.project.save()

        # Fetch payout
        payout = ProjectPayout.objects.all()[0]

        # Money is safe now, nothing pending
        self.assertEquals(payout.amount_raised, Decimal('60.00'))

        self.assertEquals(payout.payout_rule, 'zero')
        self.assertEquals(payout.amount_payable, Decimal('60'))

        self.assertEquals(payout.amount_pending, Decimal('0.00'))
        self.assertEquals(payout.amount_safe, Decimal('60.00'))
        self.assertEquals(payout.amount_failed, Decimal('0.00'))