Add test for this behaviour
This commit is contained in:
parent
03b5be91f7
commit
739901b606
@ -1,5 +1,7 @@
|
|||||||
# pragma pylint: disable=missing-docstring, C0103
|
# pragma pylint: disable=missing-docstring, C0103
|
||||||
import argparse
|
import argparse
|
||||||
|
from pathlib import Path
|
||||||
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
@ -177,6 +179,44 @@ def test_plot_profit_options() -> None:
|
|||||||
assert pargs["db_url"] == "sqlite:///whatever.sqlite"
|
assert pargs["db_url"] == "sqlite:///whatever.sqlite"
|
||||||
|
|
||||||
|
|
||||||
|
def test_config_notallowed(mocker) -> None:
|
||||||
|
mocker.patch.object(Path, "is_file", MagicMock(return_value=False))
|
||||||
|
args = [
|
||||||
|
'create-userdir',
|
||||||
|
]
|
||||||
|
pargs = Arguments(args).get_parsed_arg()
|
||||||
|
|
||||||
|
assert pargs["config"] is None
|
||||||
|
|
||||||
|
# When file exists:
|
||||||
|
mocker.patch.object(Path, "is_file", MagicMock(return_value=True))
|
||||||
|
args = [
|
||||||
|
'create-userdir',
|
||||||
|
]
|
||||||
|
pargs = Arguments(args).get_parsed_arg()
|
||||||
|
# config is not added even if it exists, since create-userdir is in the notallowed list
|
||||||
|
assert pargs["config"] is None
|
||||||
|
|
||||||
|
|
||||||
|
def test_config_notrequired(mocker) -> None:
|
||||||
|
mocker.patch.object(Path, "is_file", MagicMock(return_value=False))
|
||||||
|
args = [
|
||||||
|
'download-data',
|
||||||
|
]
|
||||||
|
pargs = Arguments(args).get_parsed_arg()
|
||||||
|
|
||||||
|
assert pargs["config"] is None
|
||||||
|
|
||||||
|
# When file exists:
|
||||||
|
mocker.patch.object(Path, "is_file", MagicMock(return_value=True))
|
||||||
|
args = [
|
||||||
|
'download-data',
|
||||||
|
]
|
||||||
|
pargs = Arguments(args).get_parsed_arg()
|
||||||
|
# config is added if it exists
|
||||||
|
assert pargs["config"] == ['config.json']
|
||||||
|
|
||||||
|
|
||||||
def test_check_int_positive() -> None:
|
def test_check_int_positive() -> None:
|
||||||
assert check_int_positive("3") == 3
|
assert check_int_positive("3") == 3
|
||||||
assert check_int_positive("1") == 1
|
assert check_int_positive("1") == 1
|
||||||
|
Loading…
Reference in New Issue
Block a user