コード例 #1
0
 def test_no_destination_amount(self):
     form = CurrencyTradeForm(dict(
         source_account=self.account_gbp.uuid,
         source_amount_0='100',
         source_amount_1='GBP',
         trading_account=self.trading_gbp_eur.uuid,
         destination_account=self.account_eur.uuid,
         destination_amount_0='',
         destination_amount_1='',
     ))
     self.assertFalse(form.is_valid())
コード例 #2
0
 def test_trading_account_no_destination_currency(self):
     form = CurrencyTradeForm(dict(
         source_account=self.account_gbp.uuid,
         source_amount_0='100',
         source_amount_1='GBP',
         trading_account=self.account(name='trading', type=Account.TYPES.trading, currencies=['GBP', 'USD']).uuid,
         destination_account=self.account_eur.uuid,
         destination_amount_0='110',
         destination_amount_1='EUR',
     ))
     self.assertFalse(form.is_valid())
コード例 #3
0
 def test_no_destination_account(self):
     form = CurrencyTradeForm(
         dict(
             source_account=self.account_gbp.uuid,
             source_amount_0="100",
             source_amount_1="GBP",
             trading_account=self.trading_gbp_eur.uuid,
             destination_account="",
             destination_amount_0="110",
             destination_amount_1="EUR",
         )
     )
     self.assertFalse(form.is_valid())
コード例 #4
0
 def test_trading_account_no_destination_currency(self):
     form = CurrencyTradeForm(
         dict(
             source_account=self.account_gbp.uuid,
             source_amount_0="100",
             source_amount_1="GBP",
             trading_account=self.account(
                 name="trading", type=Account.TYPES.trading, currencies=["GBP", "USD"]
             ).uuid,
             destination_account=self.account_eur.uuid,
             destination_amount_0="110",
             destination_amount_1="EUR",
         )
     )
     self.assertFalse(form.is_valid())
コード例 #5
0
 def test_valid(self):
     form = CurrencyTradeForm(dict(
         source_account=self.account_gbp.uuid,
         source_amount_0='100',
         source_amount_1='GBP',
         trading_account=self.trading_gbp_eur.uuid,
         destination_account=self.account_eur.uuid,
         destination_amount_0='110',
         destination_amount_1='EUR',
     ))
     self.assertTrue(form.is_valid(), form.errors)
     form.save()
     self.assertEqual(self.account_gbp.balance(), Balance('-100', 'GBP'))
     self.assertEqual(self.trading_gbp_eur.balance(), Balance('-100', 'GBP', '110', 'EUR'))
     self.assertEqual(self.account_eur.balance(), Balance('110', 'EUR'))
コード例 #6
0
 def test_valid(self):
     form = CurrencyTradeForm(
         dict(
             source_account=self.account_gbp.uuid,
             source_amount_0="100",
             source_amount_1="GBP",
             trading_account=self.trading_gbp_eur.uuid,
             destination_account=self.account_eur.uuid,
             destination_amount_0="110",
             destination_amount_1="EUR",
         )
     )
     self.assertTrue(form.is_valid(), form.errors)
     form.save()
     self.assertEqual(self.account_gbp.balance(), Balance("-100", "GBP"))
     self.assertEqual(self.trading_gbp_eur.balance(), Balance("-100", "GBP", "110", "EUR"))
     self.assertEqual(self.account_eur.balance(), Balance("110", "EUR"))