From b5a806dec766301632dd4ccad169cba598f3bbd1 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 4 Jan 2020 11:30:21 +0100 Subject: [PATCH] Fix typo and add tests for create_plotconfig --- freqtrade/plot/plotting.py | 2 +- tests/test_plotting.py | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/freqtrade/plot/plotting.py b/freqtrade/plot/plotting.py index a79ec6b87..1c8ad552f 100644 --- a/freqtrade/plot/plotting.py +++ b/freqtrade/plot/plotting.py @@ -165,7 +165,7 @@ def create_plotconfig(indicators1: List[str], indicators2: List[str], plot_confi if not indicators1: indicators1 = ['sma', 'ema3', 'ema5'] if not indicators2: - indicators1 = ['macd', 'macdsignal'] + indicators2 = ['macd', 'macdsignal'] # Create subplot configuration if plot_config is not available. plot_config = { diff --git a/tests/test_plotting.py b/tests/test_plotting.py index 048f9d60c..908c90a0a 100644 --- a/tests/test_plotting.py +++ b/tests/test_plotting.py @@ -13,6 +13,7 @@ from freqtrade.data.btanalysis import create_cum_profit, load_backtest_data from freqtrade.exceptions import OperationalException from freqtrade.plot.plot_utils import start_plot_dataframe, start_plot_profit from freqtrade.plot.plotting import (add_indicators, add_profit, + create_plotconfig, generate_candlestick_graph, generate_plot_filename, generate_profit_graph, init_plotscript, @@ -372,3 +373,26 @@ def test_plot_profit(default_conf, mocker, testdatadir, caplog): assert profit_mock.call_args_list[0][0][0] == default_conf['pairs'] assert store_mock.call_args_list[0][1]['auto_open'] is True + + +@pytest.mark.parametrize("ind1,ind2,plot_conf,exp", [ + ([], [], {}, + {'main_plot': {'sma': {}, 'ema3': {}, 'ema5': {}}, + 'subplots': {'Other': {'macd': {}, 'macdsignal': {}}}}), + (['sma', 'ema3'], ['macd'], {}, + {'main_plot': {'sma': {}, 'ema3': {}}, 'subplots': {'Other': {'macd': {}}}} + ), + ([], [], {'main_plot': {'sma': {}}}, + {'main_plot': {'sma': {}}, 'subplots': {}}), + ([], [], {'subplots': {'RSI': {'rsi': {'color': 'red'}}}}, + {'main_plot': {}, 'subplots': {'RSI': {'rsi': {'color': 'red'}}}}), +]) +def test_create_plotconfig(ind1, ind2, plot_conf, exp): + + res = create_plotconfig(ind1, ind2, plot_conf) + assert 'main_plot' in res + assert 'subplots' in res + assert isinstance(res['main_plot'], dict) + assert isinstance(res['subplots'], dict) + + assert res == exp