Skip to content

Commit

Permalink
Improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dwoz committed Oct 29, 2024
1 parent 22dc2e3 commit 4f21b45
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions tests/pytests/unit/transport/test_tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -698,6 +698,8 @@ def publish_payload(payload):
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
Expand All @@ -707,17 +709,21 @@ 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,
pub_host="127.0.0.1",
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
Expand All @@ -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
Expand Down

0 comments on commit 4f21b45

Please sign in to comment.