From 5eb5a4035c0422f968ec3c076af1538e8728df9d Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Mon, 28 Oct 2024 17:16:06 -0700 Subject: [PATCH] Improve tests --- tests/pytests/unit/transport/test_tcp.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/tests/pytests/unit/transport/test_tcp.py b/tests/pytests/unit/transport/test_tcp.py index 4066abbd5a1..3ecc9bedf8f 100644 --- a/tests/pytests/unit/transport/test_tcp.py +++ b/tests/pytests/unit/transport/test_tcp.py @@ -687,7 +687,7 @@ async def test_pub_server_publish_payload_closed_stream(master_opts, io_loop): assert server.clients == set() -async def test_pub_server_pull_path_no_perms(master_opts, io_loop): +async def test_pub_server_paths_no_perms(master_opts, io_loop): def publish_payload(payload): return payload @@ -698,6 +698,8 @@ async def test_pub_server_pull_path_no_perms(master_opts, io_loop): pull_host="127.0.0.1", pull_port=5152, ) + assert pubserv.pull_path is None + assert pubserv.pub_path is None with patch("os.chmod") as p: await pubserv.publisher(publish_payload) assert p.call_count == 0 @@ -707,7 +709,7 @@ async def test_pub_server_publisher_pull_path_perms(master_opts, io_loop, tmp_pa def publish_payload(payload): return payload - pull_path = tmp_path / "pull.ipc" + pull_path = str(tmp_path / "pull.ipc") pull_path_perms = 0o664 pubserv = salt.transport.tcp.PublishServer( master_opts, @@ -715,9 +717,13 @@ async def test_pub_server_publisher_pull_path_perms(master_opts, io_loop, tmp_pa pub_port=5151, pull_host=None, pull_port=None, - pull_path=str(pull_path), + pull_path=pull_path, pull_path_perms=pull_path_perms, ) + assert pubserv.pull_path == pull_path + assert pubserv.pull_path_perms == pull_path_perms + assert pubserv.pull_host is None + assert pubserv.pull_port is None with patch("os.chmod") as p: await pubserv.publisher(publish_payload) assert p.call_count == 1 @@ -728,18 +734,22 @@ async def test_pub_server_publisher_pub_path_perms(master_opts, io_loop, tmp_pat def publish_payload(payload): return payload - pub_path = tmp_path / "pub.ipc" + pub_path = str(tmp_path / "pub.ipc") pub_path_perms = 0o664 pubserv = salt.transport.tcp.PublishServer( master_opts, pub_host=None, pub_port=None, - pub_path=str(pub_path), + pub_path=pub_path, pub_path_perms=pub_path_perms, pull_host="127.0.0.1", pull_port=5151, pull_path=None, ) + assert pubserv.pub_path == pub_path + assert pubserv.pub_path_perms == pub_path_perms + assert pubserv.pub_host is None + assert pubserv.pub_port is None with patch("os.chmod") as p: await pubserv.publisher(publish_payload) assert p.call_count == 1