コード例 #1
0
 def test_past_date(self):
     personal = Account.objects.create(name='foo')
     other = Account.objects.create(name='bar')
     form = RecurringTransactionForm({
         'amount': 100, 'multiplier': 1, 'weekend_handling': RecurringTransaction.SKIP,
         'src': personal.id, 'dst': other.id, 'date': '2016-01-01',
         'interval': RecurringTransaction.MONTHLY, 'title': 'foo', 'usual_month_day': 0})
     self.assertTrue(form.is_valid())
コード例 #2
0
 def test_two_foreign_accounts(self):
     first = Account.objects.create(name='foo', account_type=Account.AccountType.FOREIGN)
     other = Account.objects.create(name='bar', account_type=Account.AccountType.FOREIGN)
     form = RecurringTransactionForm({
         'amount': 100, 'date': '2100-01-01', 'multiplier': 1,
         'src': other.id, 'dst': first.id, 'interval': RecurringTransaction.MONTHLY,
         'title': 'foo', 'weekend_handling': RecurringTransaction.SKIP, 'usual_month_day': 0})
     self.assertFalse(form.is_valid())
     self.assertEqual(len(form.errors), 1)
コード例 #3
0
 def test_negative_amount(self):
     personal = Account.objects.create(name='foo')
     other = Account.objects.create(name='bar')
     form = RecurringTransactionForm({
         'amount': -100, 'date': '2100-01-01', 'multiplier': 1,
         'src': personal.id, 'dst': other.id, 'interval': RecurringTransaction.MONTHLY,
         'title': 'foo', 'weekend_handling': RecurringTransaction.SKIP, 'usual_month_day': 0})
     self.assertFalse(form.is_valid())
     self.assertEqual(len(form.errors), 1)
     self.assertIn('amount', form.errors)
コード例 #4
0
 def test_deposit(self):
     personal = Account.objects.create(name='foo')
     other = Account.objects.create(name='bar', account_type=Account.AccountType.FOREIGN)
     form = RecurringTransactionForm({
         'amount': 100, 'date': '2100-01-01', 'multiplier': 1,
         'src': other.id, 'dst': personal.id, 'interval': RecurringTransaction.MONTHLY,
         'title': 'foo', 'weekend_handling': RecurringTransaction.SKIP, 'usual_month_day': 0})
     self.assertTrue(form.is_valid())
     transaction = form.save()
     self.assertIsNotNone(transaction)
     self.assertEqual(transaction.transaction_type, Transaction.DEPOSIT)
コード例 #5
0
 def test_past_date(self):
     personal = Account.objects.create(name='foo')
     other = Account.objects.create(name='bar')
     form = RecurringTransactionForm({
         'amount': 100,
         'src': personal.id,
         'dst': other.id,
         'date': '2016-01-01',
         'recurrence': RecurringTransaction.MONTHLY,
         'title': 'foo'
     })
     self.assertTrue(form.is_valid())
コード例 #6
0
 def test_negative_amount(self):
     personal = Account.objects.create(name='foo')
     other = Account.objects.create(name='bar')
     form = RecurringTransactionForm({
         'amount': -100,
         'date': '2100-01-01',
         'src': personal.id,
         'dst': other.id,
         'recurrence': RecurringTransaction.MONTHLY,
         'title': 'foo'
     })
     self.assertFalse(form.is_valid())
     self.assertEqual(len(form.errors), 1)
     self.assertIn('amount', form.errors)
コード例 #7
0
 def test_two_foreign_accounts(self):
     first = Account.objects.create(name='foo',
                                    account_type=Account.FOREIGN)
     other = Account.objects.create(name='bar',
                                    account_type=Account.FOREIGN)
     form = RecurringTransactionForm({
         'amount': 100,
         'date': '2100-01-01',
         'src': other.id,
         'dst': first.id,
         'recurrence': RecurringTransaction.MONTHLY,
         'title': 'foo'
     })
     self.assertFalse(form.is_valid())
     self.assertEqual(len(form.errors), 1)
コード例 #8
0
 def test_transfer(self):
     personal = Account.objects.create(name='foo')
     other = Account.objects.create(name='bar')
     form = RecurringTransactionForm({
         'amount': 100,
         'date': '2100-01-01',
         'src': personal.id,
         'dst': other.id,
         'recurrence': RecurringTransaction.MONTHLY,
         'title': 'foo'
     })
     self.assertTrue(form.is_valid())
     transaction = form.save()
     self.assertEqual(transaction.transaction_type, Transaction.TRANSFER)
     self.assertIsNotNone(transaction)
コード例 #9
0
 def test_past_date(self):
     personal = Account.objects.create(name='foo')
     other = Account.objects.create(name='bar')
     form = RecurringTransactionForm({
         'amount': 100,
         'transaction_type': Transaction.TRANSFER,
         'src': personal,
         'dst': other,
         'date': '2016-01-01',
         'recurrence': RecurringTransaction.MONTHLY,
         'title': 'foo'
     })
     self.assertFalse(form.is_valid())
     self.assertEquals(len(form.errors), 1)
     self.assertIn('date', form.errors)
コード例 #10
0
 def test_available_form_fields(self):
     form = RecurringTransactionForm()
     fields = ['title', 'date', 'amount',
               'src', 'dst', 'category', 'interval',
               'multiplier', 'weekend_handling', 'usual_month_day']
     self.assertEqual(len(form.fields), len(fields))
     for field in fields:
         self.assertIn(field, form.fields)
コード例 #11
0
 def test_available_form_fields(self):
     form = RecurringTransactionForm()
     fields = [
         'title', 'date', 'amount', 'src', 'dst', 'category', 'recurrence'
     ]
     self.assertEqual(len(form.fields), len(fields))
     for field in fields:
         self.assertIn(field, form.fields)
コード例 #12
0
 def test_transfer_with_existing_accounts(self):
     personal = Account.objects.create(name='foo')
     other = Account.objects.create(name='bar')
     form = RecurringTransactionForm({
         'amount': 100,
         'transaction_type': Transaction.TRANSFER,
         'date': '2100-01-01',
         'src': personal,
         'dst': other,
         'recurrence': RecurringTransaction.MONTHLY,
         'title': 'foo'
     })
     self.assertTrue(form.is_valid())
     transaction = form.save()
     self.assertIsNotNone(transaction)
     self.assertEquals(transaction.src, personal)
     self.assertEquals(transaction.dst, other)