Harden JoinQuant browser smoke automation

This commit is contained in:
Yuxuan Yan
2026-07-04 19:27:48 +08:00
parent 5fada75d23
commit efa9d24c73
4 changed files with 206 additions and 19 deletions
+24
View File
@@ -514,6 +514,28 @@ def test_wrapper_strategy_generation_smoke(tmp_path):
assert "order_target_value" in text
def test_wrapper_strategy_can_embed_target_csvs(tmp_path):
targets_dir = tmp_path / "targets"
targets_dir.mkdir()
(targets_dir / "20260701.csv").write_text(
"date,portfolio_name,symbol_id,jq_symbol,target_shares,target_value,export_mode\n"
"2026-07-01,run1,sh600000,600000.XSHG,1000,10000,target_shares\n",
encoding="utf-8",
)
path = write_wrapper_strategy(
portfolio_name="run1",
mode="target_shares",
out_path=tmp_path / "wrapper_embedded.py",
embedded_targets_dir=targets_dir,
)
text = path.read_text()
assert '"20260701.csv"' in text
assert "600000.XSHG" in text
assert "if file_name in _EMBEDDED_TARGETS" in text
def test_build_fixed_share_positions_excludes_final_executionless_date():
data = pd.DataFrame({
"symbol_id": ["sh600000", "sh600000", "sh600000"],
@@ -558,6 +580,8 @@ def test_browser_config_template_and_placeholder_resolution(tmp_path):
"/tmp/20240111.csv",
]
assert resolve_template("save:{expected_joinquant_csvs.fills}", context) == "save:/tmp/jq_fills.csv"
script = "(arg) => { return new Event('change', {bubbles: true}); }"
assert resolve_template(script, context) == script
def test_load_env_file_handles_quotes_without_shell_sourcing(tmp_path):