mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Only warn when connect was called
This commit is contained in:
parent
50206c08c5
commit
75d62539db
2 changed files with 49 additions and 0 deletions
21
tests/pytests/unit/transport/test_base.py
Normal file
21
tests/pytests/unit/transport/test_base.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
"""
|
||||
Unit tests for salt.transport.base.
|
||||
"""
|
||||
import pytest
|
||||
|
||||
import salt.transport.base
|
||||
|
||||
pytestmark = [
|
||||
pytest.mark.core_test,
|
||||
]
|
||||
|
||||
|
||||
def test_unclosed_warning():
|
||||
|
||||
transport = salt.transport.base.Transport()
|
||||
assert transport._closing is False
|
||||
assert transport._connect_called is False
|
||||
transport.connect()
|
||||
assert transport._connect_called is True
|
||||
with pytest.warns(salt.transport.base.TransportWarning):
|
||||
del transport
|
|
@ -1498,3 +1498,31 @@ def test_pub_client_init(minion_opts, io_loop):
|
|||
client = salt.transport.zeromq.PublishClient(minion_opts, io_loop)
|
||||
client.send(b"asf")
|
||||
client.close()
|
||||
|
||||
|
||||
async def test_unclosed_request_client(minion_opts, io_loop):
|
||||
minion_opts["master_uri"] = "tcp://127.0.0.1:4506"
|
||||
client = salt.transport.zeromq.RequestClient(minion_opts, io_loop)
|
||||
await client.connect()
|
||||
try:
|
||||
assert client._closing is False
|
||||
with pytest.warns(salt.transport.base.TransportWarning):
|
||||
client.__del__()
|
||||
finally:
|
||||
client.close()
|
||||
|
||||
|
||||
async def test_unclosed_publish_client(minion_opts, io_loop):
|
||||
minion_opts["id"] = "minion"
|
||||
minion_opts["__role"] = "minion"
|
||||
minion_opts["master_ip"] = "127.0.0.1"
|
||||
minion_opts["zmq_filtering"] = True
|
||||
minion_opts["zmq_monitor"] = True
|
||||
client = salt.transport.zeromq.PublishClient(minion_opts, io_loop)
|
||||
await client.connect(2121)
|
||||
try:
|
||||
assert client._closing is False
|
||||
with pytest.warns(salt.transport.base.TransportWarning):
|
||||
client.__del__()
|
||||
finally:
|
||||
client.close()
|
||||
|
|
Loading…
Add table
Reference in a new issue