mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 02:12:01 +00:00
Improve test cov
This commit is contained in:
parent
0a0105c31e
commit
e971f043f4
|
@ -19,7 +19,7 @@ logging.basicConfig(
|
||||||
logger = logging.getLogger("ft_rest_client")
|
logger = logging.getLogger("ft_rest_client")
|
||||||
|
|
||||||
|
|
||||||
def add_arguments():
|
def add_arguments(args: Any = None):
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("command",
|
parser.add_argument("command",
|
||||||
help="Positional argument defining the command to execute.",
|
help="Positional argument defining the command to execute.",
|
||||||
|
@ -47,8 +47,8 @@ def add_arguments():
|
||||||
default=[]
|
default=[]
|
||||||
)
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
pargs = parser.parse_args(args)
|
||||||
return vars(args)
|
return vars(pargs)
|
||||||
|
|
||||||
|
|
||||||
def load_config(configfile):
|
def load_config(configfile):
|
||||||
|
|
|
@ -2,6 +2,7 @@ from unittest.mock import MagicMock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from freqtrade_client import FtRestClient
|
from freqtrade_client import FtRestClient
|
||||||
|
from freqtrade_client.ft_client import add_arguments, main_exec
|
||||||
|
|
||||||
|
|
||||||
def get_rest_client():
|
def get_rest_client():
|
||||||
|
@ -92,3 +93,16 @@ def test_FtRestClient_call_explicit_methods(method, args):
|
||||||
exec = getattr(client, method)
|
exec = getattr(client, method)
|
||||||
exec(*args)
|
exec(*args)
|
||||||
assert mock.call_count == 1
|
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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user