def setUp(self): super(RecurringTransactionTestCase, self).setUp() #'monthly, on the 1st without end rule = Rule(bymonthday=[1], freq=1, interval=1) recurrence = Recurrence(rrules=[rule,]) self.rtd1 = RecurringTransactionDef( category=self.category_misc, amount=150, transaction_type='expense', notes='here are some notes', recurrences=recurrence, start_date=datetime.date(year=2014, month=1, day=1) ) #don't save the rtd since this will create the transactions friday = Weekday(4) rule2 = Rule(byday=[friday,], freq=2, interval=2) recurrence2 = Recurrence(rrules=[rule2,]) self.rtd2 = RecurringTransactionDef( category=self.category_food, amount=100, transaction_type='expense', notes='food notes', recurrences=recurrence2, start_date=datetime.date(year=2014, month=1, day=1) )
class RecurringTransactionTestCase(BaseBudgetTestCase): def setUp(self): super(RecurringTransactionTestCase, self).setUp() #'monthly, on the 1st without end rule = Rule(bymonthday=[1], freq=1, interval=1) recurrence = Recurrence(rrules=[rule,]) self.rtd1 = RecurringTransactionDef( category=self.category_misc, amount=150, transaction_type='expense', notes='here are some notes', recurrences=recurrence, start_date=datetime.date(year=2014, month=1, day=1) ) #don't save the rtd since this will create the transactions friday = Weekday(4) rule2 = Rule(byday=[friday,], freq=2, interval=2) recurrence2 = Recurrence(rrules=[rule2,]) self.rtd2 = RecurringTransactionDef( category=self.category_food, amount=100, transaction_type='expense', notes='food notes', recurrences=recurrence2, start_date=datetime.date(year=2014, month=1, day=1) ) #make another rtd with multiple recurrences in a given month #make one for the last day of the month def test_get_recurrences_between(self): self.assertEqual( len(self.rtd1.get_recurrences_between( self.budget.start_date, self.budget.end_date)),1 ) self.assertEqual( len(self.rtd2.get_recurrences_between( self.budget.start_date, self.budget.end_date)), 3) def test_pending_budgets(self): self.assertEqual(self.rtd1.pending_budgets(), [self.budget]) self.assertEqual(self.rtd2.pending_budgets(), [self.budget])