Exemplo n.º 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())
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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())
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
 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)
Exemplo n.º 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)
Exemplo n.º 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)
 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)