@@ -54,8 +54,8 @@ def test_netmiko_exec_on_linux_ssh():
5454
5555 result = rpc .execute (req )
5656
57- assert target . command in result
58- assert "netpulse-e2e" in result [ target . command ]
57+ res = next ( x for x in result if x . command == target . command )
58+ assert "netpulse-e2e" in res . output
5959
6060
6161def test_netmiko_exec_on_srlinux (monkeypatch ):
@@ -87,9 +87,9 @@ def test_netmiko_exec_on_srlinux(monkeypatch):
8787 except Exception as exc :
8888 pytest .skip (f"SR Linux auth/connection failed: { exc } " )
8989
90- assert target . command in result
91- assert isinstance (result [ target . command ] , str )
92- assert result [ target . command ] .strip ()
90+ res = next ( x for x in result if x . command == target . command )
91+ assert isinstance (res . output , str )
92+ assert res . output .strip ()
9393
9494
9595def test_netmiko_config_on_srlinux (monkeypatch ):
@@ -126,7 +126,7 @@ def test_netmiko_config_on_srlinux(monkeypatch):
126126 pytest .skip (f"SR Linux auth/connection failed: { exc } " )
127127
128128 assert isinstance (result , list )
129- assert result and all (isinstance (item , str ) for item in result )
129+ assert result and all (isinstance (res . output , str ) for res in result )
130130
131131
132132def test_netmiko_reuses_persisted_session (monkeypatch ):
@@ -175,8 +175,8 @@ def spy_set(cls, session, conn_args):
175175 command = cmd ,
176176 )
177177 result = rpc .execute (req )
178- assert cmd in result
179- assert "reuse" in result [ cmd ]
178+ res = next ( x for x in result if x . command == cmd )
179+ assert "reuse" in res . output
180180
181181 non_none_sets = [s for s in set_calls if s ]
182182 assert len (non_none_sets ) == 1 , "persisted session should be set once"
@@ -219,14 +219,14 @@ def test_api_exec_netmiko_pinned(node_worker, api_server, wait_for_job):
219219
220220 assert resp .status_code == 201 , resp .text
221221 body = resp .json ()
222- job = body [ "data" ]
222+ job = body
223223 assert job ["queue" ] == f"HostQ_{ target .host } "
224224
225225 finished = wait_for_job (job_id = job ["id" ])
226226 assert finished ["status" ] == "finished"
227227 result = finished ["result" ]["retval" ]
228- assert cmd in result
229- assert "api-netmiko-e2e" in result [ cmd ]
228+ res = next ( x for x in result if x [ "command" ] == cmd )
229+ assert "api-netmiko-e2e" in res [ "output" ]
230230
231231
232232def test_api_netmiko_srl_render_and_parse (node_worker , api_server , wait_for_job ):
@@ -271,15 +271,14 @@ def test_api_netmiko_srl_render_and_parse(node_worker, api_server, wait_for_job)
271271 pytest .skip (f"API unreachable at { API_BASE } : { exc } " )
272272
273273 assert resp .status_code == 201 , resp .text
274- job = resp .json ()[ "data" ]
274+ job = resp .json ()
275275 assert job ["queue" ] == f"HostQ_{ target .host } "
276276
277277 finished = wait_for_job (job_id = job ["id" ], timeout = 120 )
278278 assert finished ["status" ] == "finished"
279279 retval = finished ["result" ]["retval" ]
280- assert isinstance (retval , dict ) and retval , "expected parsed output keyed by command"
281- rendered_cmd = next (iter (retval .keys ()))
282- parsed = retval [rendered_cmd ]
280+ res_dict = retval [0 ]
281+ parsed = res_dict .get ("parsed" )
283282 assert isinstance (parsed , list ), "TextFSM parser should return a list of records"
284283
285284
@@ -328,7 +327,7 @@ def test_api_netmiko_srl_bulk_exec(node_worker, api_server, wait_for_job):
328327 timeout = 15 ,
329328 )
330329 assert resp .status_code == 201 , resp .text
331- body = resp .json ()[ "data" ]
330+ body = resp .json ()
332331 succeeded = body ["succeeded" ]
333332 failed = body ["failed" ]
334333
@@ -339,6 +338,6 @@ def test_api_netmiko_srl_bulk_exec(node_worker, api_server, wait_for_job):
339338 finished = wait_for_job (job_id = job ["id" ], timeout = 120 )
340339 assert finished ["status" ] == "finished"
341340 retval = finished ["result" ]["retval" ]
342- assert isinstance ( retval , dict ) and retval , "expected command output per host"
343- # Since bulk returns list in order, ensure each job got output for the issued command.
344- assert cmd in retval
341+ res_dict = next (( x for x in retval if x [ " command" ] == cmd ), None )
342+ assert res_dict is not None , "expected command output per host"
343+ assert res_dict [ "output" ]
0 commit comments