Coverage for jbank/management/commands/test_payment.py: 52%

# Coverage for jbank/management/commands/test_payment.py : 52%

## 21 statements

Hot-keys on this page

r m x p toggle line displays

j k next/prev highlighted chunk

0 (zero) top of page

1 (one) first highlighted chunk

1 import logging

2 from decimal import Decimal

3 from django.core.management.base import CommandParser

4 from jutil.command import SafeCommand

5 from jbank.helpers import make_msg_id

6 from jbank.models import Payout, PayoutParty

7

8 logger = logging.getLogger(__name__)

9

10

11 class Command(SafeCommand):

12 help = 'Makes test payment'

13

14 def add_arguments(self, parser: CommandParser):

15 parser.add_argument('--payer-id', type=int, default=1)

16 parser.add_argument('--recipient-id', type=int, default=2)

17 parser.add_argument('--messages', type=str, default='test payment')

18 parser.add_argument('--amount', type=Decimal, default=Decimal('1.23'))

19 parser.add_argument('--ws', type=int, default=1)

20

21 def do(self, *args, **options):

22 payer = PayoutParty.objects.get(id=options['payer_id'])

23 p = Payout(account=payer.payouts_account, payer=payer, recipient_id=options['recipient_id'], messages=options['messages'], msg_id=make_msg_id(), amount=options['amount'], connection_id=options['ws'])

24 p.full_clean()

25 p.save()

26 print('{} created'.format(p))