Improve test cov

This commit is contained in:
Matthias 2024-03-29 13:12:01 +01:00
parent 0a0105c31e
commit e971f043f4
2 changed files with 17 additions and 3 deletions

View File

@ -19,7 +19,7 @@ logging.basicConfig(
logger = logging.getLogger("ft_rest_client")
def add_arguments():
def add_arguments(args: Any = None):
parser = argparse.ArgumentParser()
parser.add_argument("command",
help="Positional argument defining the command to execute.",
@ -47,8 +47,8 @@ def add_arguments():
default=[]
)
args = parser.parse_args()
return vars(args)
pargs = parser.parse_args(args)
return vars(pargs)
def load_config(configfile):

View File

@ -2,6 +2,7 @@ from unittest.mock import MagicMock
import pytest
from freqtrade_client import FtRestClient
from freqtrade_client.ft_client import add_arguments, main_exec
def get_rest_client():
@ -92,3 +93,16 @@ def test_FtRestClient_call_explicit_methods(method, args):
exec = getattr(client, method)
exec(*args)
assert mock.call_count == 1
def test_ft_client(capsys):
with pytest.raises(SystemExit):
args = add_arguments(['-V'])
args = add_arguments(['--show'])
assert isinstance(args, dict)
assert args['show'] is True
with pytest.raises(SystemExit):
main_exec(args)
captured = capsys.readouterr()
assert 'Possible commands' in captured.out