示例#1
0
    def test_budget_currency_change(self):
        funding = FundingFactory.create(target=Money(100, 'EUR'))

        BudgetLineFactory.create_batch(5, activity=funding, amount=Money(20, 'EUR'))

        funding.target = Money(50, 'USD')
        funding.save()

        for line in funding.budget_lines.all():
            self.assertEqual(str(line.amount.currency), 'USD')
示例#2
0
    def test_budget_line_required(self):
        funding = FundingFactory.create(target=Money(100, 'EUR'))
        errors = list(funding.errors)

        self.assertEqual(len(errors), 2)
        self.assertEqual(errors[1].message, 'Please specify a budget')

        BudgetLineFactory.create_batch(5, activity=funding, amount=Money(20, 'EUR'))

        errors = list(funding.errors)
        self.assertEqual(len(errors), 1)
    def setUp(self):
        super(FundingTestCase, self).setUp()
        user = BlueBottleUserFactory.create(first_name='Jean Baptiste')
        self.initiative = InitiativeFactory.create(activity_manager=user)
        self.initiative.states.submit()
        self.initiative.states.approve(save=True)
        payout_account = StripePayoutAccountFactory.create(status='verified')
        bank_account = ExternalAccountFactory.create(
            connect_account=payout_account, status='verified')
        self.funding = FundingFactory.create(owner=user,
                                             initiative=self.initiative,
                                             target=Money(500, 'EUR'),
                                             deadline=now() +
                                             timedelta(weeks=2),
                                             bank_account=bank_account)
        BudgetLineFactory.create(activity=self.funding)
        self.funding.bank_account.reviewed = True

        self.funding.states.submit()
        self.funding.states.approve(save=True)
        BudgetLineFactory.create_batch(4,
                                       activity=self.funding,
                                       amount=Money(125, 'EUR'))
        mail.outbox = []