Update user_dir fixture to return user_data path
This commit is contained in:
+4
-2
@@ -412,9 +412,11 @@ def patch_gc(mocker) -> None:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def patched_user_dir(mocker, tmpdir) -> None:
|
def user_dir(mocker, tmpdir) -> Path:
|
||||||
|
user_dir = Path(tmpdir) / "user_data"
|
||||||
mocker.patch('freqtrade.configuration.configuration.create_userdata_dir',
|
mocker.patch('freqtrade.configuration.configuration.create_userdata_dir',
|
||||||
return_value=Path(tmpdir) / "user_data")
|
return_value=user_dir)
|
||||||
|
return user_dir
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
|
|||||||
@@ -16,18 +16,18 @@ if sys.version_info < (3, 9):
|
|||||||
pytest.skip("StrategyUpdater is not compatible with Python 3.8", allow_module_level=True)
|
pytest.skip("StrategyUpdater is not compatible with Python 3.8", allow_module_level=True)
|
||||||
|
|
||||||
|
|
||||||
def test_strategy_updater_start(tmpdir, capsys) -> None:
|
def test_strategy_updater_start(user_dir, capsys) -> None:
|
||||||
# Effective test without mocks.
|
# Effective test without mocks.
|
||||||
teststrats = Path(__file__).parent / 'strategy/strats'
|
teststrats = Path(__file__).parent / 'strategy/strats'
|
||||||
tmpdirp = Path(tmpdir) / "strategies"
|
tmpdirp = Path(user_dir) / "strategies"
|
||||||
tmpdirp.mkdir()
|
tmpdirp.mkdir(parents=True, exist_ok=True)
|
||||||
shutil.copy(teststrats / 'strategy_test_v2.py', tmpdirp)
|
shutil.copy(teststrats / 'strategy_test_v2.py', tmpdirp)
|
||||||
old_code = (teststrats / 'strategy_test_v2.py').read_text()
|
old_code = (teststrats / 'strategy_test_v2.py').read_text()
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
"strategy-updater",
|
"strategy-updater",
|
||||||
"--userdir",
|
"--userdir",
|
||||||
str(tmpdir),
|
str(user_dir),
|
||||||
"--strategy-list",
|
"--strategy-list",
|
||||||
"StrategyTestV2"
|
"StrategyTestV2"
|
||||||
]
|
]
|
||||||
@@ -36,9 +36,9 @@ def test_strategy_updater_start(tmpdir, capsys) -> None:
|
|||||||
|
|
||||||
start_strategy_update(pargs)
|
start_strategy_update(pargs)
|
||||||
|
|
||||||
assert Path(tmpdir / "strategies_orig_updater").exists()
|
assert Path(user_dir / "strategies_orig_updater").exists()
|
||||||
# Backup file exists
|
# Backup file exists
|
||||||
assert Path(tmpdir / "strategies_orig_updater" / 'strategy_test_v2.py').exists()
|
assert Path(user_dir / "strategies_orig_updater" / 'strategy_test_v2.py').exists()
|
||||||
# updated file exists
|
# updated file exists
|
||||||
new_file = Path(tmpdirp / 'strategy_test_v2.py')
|
new_file = Path(tmpdirp / 'strategy_test_v2.py')
|
||||||
assert new_file.exists()
|
assert new_file.exists()
|
||||||
|
|||||||
Reference in New Issue
Block a user