plot-scripts use user_data_dir

This commit is contained in:
Matthias
2019-07-21 15:49:52 +02:00
parent da755d1c83
commit eab82fdec7
5 changed files with 11 additions and 7 deletions

View File

@@ -33,4 +33,4 @@ def create_userdata_dir(directory: str) -> str:
if not subfolder.is_dir():
subfolder.mkdir(parents=False)
# TODO: convert this to return Path
return str(folder.resolve())
return folder

View File

@@ -308,7 +308,7 @@ def generate_plot_filename(pair, ticker_interval) -> str:
return file_name
def store_plot_file(fig, filename: str, auto_open: bool = False) -> None:
def store_plot_file(fig, filename: str, folder: Path, auto_open: bool = False) -> None:
"""
Generate a plot html file from pre populated fig plotly object
:param fig: Plotly Figure to plot
@@ -317,7 +317,7 @@ def store_plot_file(fig, filename: str, auto_open: bool = False) -> None:
:return: None
"""
Path("user_data/plots").mkdir(parents=True, exist_ok=True)
folder.mkdir(parents=True, exist_ok=True)
plot(fig, filename=str(Path('user_data/plots').joinpath(filename)),
plot(fig, filename=str(folder.joinpath(filename)),
auto_open=auto_open)

View File

@@ -1,5 +1,6 @@
from copy import deepcopy
from pathlib import Path
from unittest.mock import MagicMock
import plotly.graph_objs as go
@@ -209,7 +210,8 @@ def test_generate_Plot_filename():
def test_generate_plot_file(mocker, caplog):
fig = generage_empty_figure()
plot_mock = mocker.patch("freqtrade.plot.plotting.plot", MagicMock())
store_plot_file(fig, filename="freqtrade-plot-UNITTEST_BTC-5m.html")
store_plot_file(fig, filename="freqtrade-plot-UNITTEST_BTC-5m.html",
folder=Path("user_data/plots"))
assert plot_mock.call_count == 1
assert plot_mock.call_args[0][0] == fig