From c61437a21526f4873e6dee8d035b4a480aebec48 Mon Sep 17 00:00:00 2001 From: Roshan Sah Date: Fri, 14 Aug 2026 18:48:09 +0530 Subject: [PATCH] test(ftp): verify no FTP connection on import or initialization --- pysus/tests/api/ftp/test_client.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pysus/tests/api/ftp/test_client.py b/pysus/tests/api/ftp/test_client.py index 501edf25..0f22c4fb 100644 --- a/pysus/tests/api/ftp/test_client.py +++ b/pysus/tests/api/ftp/test_client.py @@ -207,3 +207,24 @@ def simulate_retrlines(cmd, callback): mock_ftp_internal.cwd.assert_called_once_with("/test/path") mock_ftp_internal.retrlines.assert_called_once() + + +def test_ftp_init_does_not_connect(): + """Verify that instantiating FTP does not open an FTP connection.""" + with patch("pysus.api.ftp.client.FTPLib") as mock_ftplib: + client = FTP() + assert client.ftp is None + mock_ftplib.assert_not_called() + + +def test_import_does_not_connect_ftp(): + """Verify importing pysus modules does not connect to FTP server.""" + with patch("ftplib.FTP") as mock_ftplib: + import pysus # noqa: F401 + import pysus.api # noqa: F401 + import pysus.api.ftp # noqa: F401 + from pysus.api.client import PySUS + + pysus_instance = PySUS() + assert pysus_instance._ftp is None + mock_ftplib.assert_not_called()