Coverage for jbank/management/commands/wsedi_exec.py: 0%

# Coverage for jbank/management/commands/wsedi_exec.py : 0%

## 28 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 import pytz

3 from django.core.management.base import CommandParser

4 from jutil.command import SafeCommand

5 from jbank.helpers import parse_start_and_end_date

6 from jbank.models import WsEdiConnection

7 from jbank.wsedi import wsedi_execute

8

9

10 logger = logging.getLogger(__name__)

11

12

13 class Command(SafeCommand):

14 help = """

15 Executes WS-EDI command using direct bank connection.

16 """

17

18 def add_arguments(self, parser: CommandParser):

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

20 parser.add_argument('--cmd', type=str, default='DownloadFileList')

21 parser.add_argument('--file-reference', type=str)

22 parser.add_argument('--file-type', type=str)

23 parser.add_argument('--start-date', type=str)

24 parser.add_argument('--end-date', type=str)

25

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

27 ws = WsEdiConnection.objects.get(id=options['ws'])

28 assert isinstance(ws, WsEdiConnection)

29 if ws and not ws.enabled:

30 logger.info('WS connection %s not enabled, exiting', ws)

31 return

32

33 start_date, end_date = parse_start_and_end_date(pytz.timezone('Europe/Helsinki'), **options)

34 cmd = options['cmd']

35 file_reference = options['file_reference']

36 file_type = options['file_type']

37 wsedi_execute(ws, command=cmd, file_reference=file_reference, file_type=file_type, start_date=start_date, end_date=end_date, verbose=True)