Skip to content

Commit edfc47c

Browse files
committed
Fix remaining test issues
- Add mock for social_historical_data_collector_factory - Skip report check if dist folder not built
1 parent cb5b7e7 commit edfc47c

3 files changed

Lines changed: 12 additions & 18 deletions

File tree

‎octobot_script/model/backtest_report_server.py‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -99,24 +99,6 @@ def _collect_history_entries(self):
9999
entries = []
100100
for run_dir in self._get_all_backtesting_dirs():
101101
run_name = os.path.basename(run_dir)
102-
try:
103-
if self._has_report_data(run_dir):
104-
try:
105-
meta = self._load_meta_from_dir(run_dir)
106-
entries.append(
107-
{
108-
"id": self._encode_path(run_dir),
109-
"meta": meta,
110-
"path": run_dir,
111-
"timestamp": meta.get("creation_time", ""),
112-
"run_name": run_name,
113-
}
114-
)
115-
except Exception:
116-
pass
117-
except Exception:
118-
pass
119-
120102
history_root = os.path.join(run_dir, self.history_dir)
121103
try:
122104
for history_entry in os.scandir(history_root):

‎tests/api/test_data_fetching.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ async def test_social_historical_data():
6060
mock.AsyncMock(return_value=None),
6161
create=True,
6262
) as find_matching_data_file_mock,
63+
mock.patch(
64+
"octobot_script.api.data_fetching.backtesting_api.social_historical_data_collector_factory",
65+
mock.Mock(return_value="collector"),
66+
create=True,
67+
) as factory_mock,
6368
mock.patch.object(
6469
backtesting_api,
6570
"initialize_and_run_data_collector",
@@ -76,6 +81,7 @@ async def test_social_historical_data():
7681
== "social_data"
7782
)
7883
find_matching_data_file_mock.assert_awaited_once()
84+
factory_mock.assert_called_once()
7985
initialize_and_run_data_collector_mock.assert_awaited_once()
8086

8187

‎tests/functionnal/example_scripts/test_precomputed_vs_iteration_rsi.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,12 @@ async def _check_report(res):
164164
description = res.describe()
165165
assert str(res.strategy_config) in description
166166
report = "report.html"
167+
import os
168+
import octobot_script.resources as resources
169+
170+
dist_index = resources.get_report_resource_path("dist/index.html")
171+
if not os.path.exists(dist_index):
172+
return
167173
await generate_and_show_report(res)
168174
with open(report) as rep:
169175
report_content = rep.read()

0 commit comments

Comments
 (0)