@@ -57,7 +57,6 @@ def test_resolve_manifest_repo_uses_workspace_deps(tmp_path: Path) -> None:
5757
5858
5959def test_resolve_ed2k_server_exe_defaults_to_output_root (tmp_path : Path , monkeypatch ) -> None :
60- module = load_suite_module ()
6160 workspace = tmp_path / "workspaces" / "workspace"
6261 output_root = tmp_path .parent / f"{ tmp_path .name } -output"
6362 monkeypatch .setenv ("EMULEBB_WORKSPACE_ROOT" , str (tmp_path ))
@@ -69,7 +68,6 @@ def test_resolve_ed2k_server_exe_defaults_to_output_root(tmp_path: Path, monkeyp
6968
7069
7170def test_build_or_skip_ed2k_server_binary_honors_explicit_exe_without_manifest (tmp_path : Path ) -> None :
72- module = load_suite_module ()
7371 workspace = tmp_path / "vm" / "workspace"
7472 server_exe = tmp_path / "harness" / "tools" / "goed2k-server.exe"
7573 server_exe .parent .mkdir (parents = True )
@@ -328,7 +326,6 @@ def test_write_server_met_creates_single_server_with_numeric_and_dynamic_ip(tmp_
328326
329327
330328def test_build_server_config_uses_workspace_artifact_paths (tmp_path : Path ) -> None :
331- module = load_suite_module ()
332329 config_path = tmp_path / "state" / "artifacts" / "server" / "config.json"
333330 catalog_path = tmp_path / "state" / "artifacts" / "server" / "catalog.json"
334331
@@ -354,7 +351,6 @@ def test_build_server_config_uses_workspace_artifact_paths(tmp_path: Path) -> No
354351
355352
356353def test_build_server_config_allows_protocol_overrides (tmp_path : Path ) -> None :
357- module = load_suite_module ()
358354 config_path = tmp_path / "server" / "config.json"
359355 catalog_path = tmp_path / "server" / "catalog.json"
360356
@@ -376,7 +372,6 @@ def test_build_server_config_allows_protocol_overrides(tmp_path: Path) -> None:
376372
377373
378374def test_build_server_config_allows_admin_bind_override (tmp_path : Path ) -> None :
379- module = load_suite_module ()
380375 config_path = tmp_path / "server" / "config.json"
381376 catalog_path = tmp_path / "server" / "catalog.json"
382377
@@ -410,7 +405,6 @@ def test_build_server_config_rejects_missing_ed2k_bind(tmp_path: Path) -> None:
410405
411406
412407def test_build_server_config_allows_ed2k_bind_override (tmp_path : Path ) -> None :
413- module = load_suite_module ()
414408 config_path = tmp_path / "server" / "config.json"
415409 catalog_path = tmp_path / "server" / "catalog.json"
416410
@@ -1162,6 +1156,71 @@ def fake_wait_for(resolve, *_args):
11621156 assert ("POST" , "/api/v1/servers/10.1.2.3:4661/operations/connect" ) in calls
11631157
11641158
1159+ def test_add_and_connect_server_waits_past_transitional_connect_response (monkeypatch ) -> None :
1160+ module = load_suite_module ()
1161+ calls : list [tuple [str , str ]] = []
1162+ status_payloads = [
1163+ {
1164+ "connected" : False ,
1165+ "connecting" : True ,
1166+ "currentServer" : None ,
1167+ "serverCount" : 1 ,
1168+ },
1169+ {
1170+ "connected" : True ,
1171+ "connecting" : False ,
1172+ "currentServer" : {"address" : "10.1.2.3" , "port" : 4661 , "name" : "local" },
1173+ "serverCount" : 1 ,
1174+ },
1175+ ]
1176+
1177+ def fake_http_request (_base_url , path , * , method = "GET" , ** _kwargs ):
1178+ calls .append ((method , path ))
1179+ if path == "/api/v1/servers" :
1180+ return {"status" : 200 , "json" : [{"address" : "10.1.2.3" , "port" : 4661 , "name" : "local" }]}
1181+ if path == "/api/v1/servers/10.1.2.3:4661/operations/connect" :
1182+ payload = {
1183+ "connected" : False ,
1184+ "connecting" : True ,
1185+ "currentServer" : None ,
1186+ "serverCount" : 1 ,
1187+ }
1188+ return {
1189+ "status" : 200 ,
1190+ "content_type" : "application/json; charset=utf-8" ,
1191+ "json" : payload ,
1192+ "raw_json" : {"data" : payload , "meta" : {"apiVersion" : "v1" }},
1193+ }
1194+ if path == "/api/v1/status" :
1195+ payload = status_payloads .pop (0 )
1196+ return {
1197+ "status" : 200 ,
1198+ "content_type" : "application/json; charset=utf-8" ,
1199+ "json" : payload ,
1200+ "raw_json" : {"data" : payload , "meta" : {"apiVersion" : "v1" }},
1201+ }
1202+ raise AssertionError (path )
1203+
1204+ def fake_wait_for (resolve , * _args ):
1205+ return resolve () or resolve ()
1206+
1207+ monkeypatch .setattr (module .rest_smoke , "http_request" , fake_http_request )
1208+ monkeypatch .setattr (module .rest_smoke , "compact_http_result" , lambda result : {"status" : result ["status" ], "json" : result ["json" ]})
1209+ monkeypatch .setattr (module .live_common , "wait_for" , fake_wait_for )
1210+
1211+ result = module .add_and_connect_server (
1212+ "http://127.0.0.1:4711" ,
1213+ "key" ,
1214+ address = "10.1.2.3" ,
1215+ port = 4661 ,
1216+ timeout_seconds = 2.0 ,
1217+ )
1218+
1219+ assert result ["connect" ]["json" ]["connecting" ] is True
1220+ assert result ["connected" ]["observations" ][- 1 ]["connected" ] is True
1221+ assert calls .count (("GET" , "/api/v1/status" )) == 2
1222+
1223+
11651224def test_wait_for_completed_file_timeout_carries_diagnostic_observations (tmp_path : Path ) -> None :
11661225 module = load_suite_module ()
11671226 snapshots = [{"transfer" : {"status" : 200 , "json" : {"state" : "downloading" }}}]
0 commit comments