Coverage for tests/django_tests/db/transactions/test_debit.py: 100%
19 statements
« prev ^ index » next coverage.py v7.4.3, created at 2024-03-12 13:49 +0000
« prev ^ index » next coverage.py v7.4.3, created at 2024-03-12 13:49 +0000
1from django_napse.core.models import Credit, Debit
2from django_napse.utils.model_test_case import ModelTestCase
4"""
5python tests/test_app/manage.py test tests.django_tests.transactions.test_debit -v2 --keepdb --parallel
6"""
9class DebitTestCase:
10 model = Debit
12 def simple_create(self):
13 Credit.objects.create(wallet=self.space.wallet, amount=10, ticker="BTC")
14 return Debit.objects.create(
15 wallet=self.space.wallet,
16 amount=1,
17 ticker="BTC",
18 )
20 def test_empty_credit(self):
21 debit = Debit.objects.create(
22 wallet=self.space.wallet,
23 amount=0,
24 ticker="BTC",
25 )
26 self.assertIsNone(debit)
28 def test_correct_amount(self):
29 Credit.objects.create(wallet=self.space.wallet, amount=10, ticker="BTC")
30 Debit.objects.create(
31 wallet=self.space.wallet,
32 amount=1,
33 ticker="BTC",
34 )
35 self.assertEqual(self.space.wallet.get_amount("BTC"), 9)
36 Debit.objects.create(
37 wallet=self.space.wallet,
38 amount=1,
39 ticker="BTC",
40 )
41 self.assertEqual(self.space.wallet.get_amount("BTC"), 8)
44class DebitBINANCETestCase(DebitTestCase, ModelTestCase):
45 exchange = "BINANCE"