Split ne_session_factory into templates, CLI hop detection, and connect paths.

Keep the facade for callers, retarget unit-test patches to ne_session_connect, and fix the ConnectHandler coverage case to use a non-Cisco device type.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-08-02 17:15:57 +08:00
parent 96b76294b4
commit 58cdbe6165
7 changed files with 994 additions and 904 deletions

View file

@ -20,10 +20,10 @@ class InteractiveNetmikoTests(unittest.TestCase):
def test_build_non_interactive_uses_connect_handler(self) -> None:
fake = MagicMock(name="conn")
with patch("netx_api.ne_session_factory.ConnectHandler", return_value=fake) as ch:
with patch("netx_api.ne_session_connect.ConnectHandler", return_value=fake) as ch:
out = _build_netmiko_connection(
{
"device_type": "cisco_ios",
"device_type": "linux",
"host": "1.1.1.1",
"username": "u",
"password": "p",
@ -42,7 +42,7 @@ class InteractiveNetmikoTests(unittest.TestCase):
"username": "u",
"password": "p",
}
with patch("netx_api.ne_session_factory._connect_direct") as direct:
with patch("netx_api.ne_session_connect._connect_direct") as direct:
direct.return_value = MagicMock()
open_netmiko_connection(creds, interactive=True)
direct.assert_called_once()