From ccaf03d200e7ed6ca4cc4618c0620d445c50e62f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20S=C3=A1nchez=20de=20Le=C3=B3n=20Peque?= Date: Tue, 6 Aug 2019 16:31:20 +0200 Subject: [PATCH] Add test to close a connected socket --- osbrain/tests/test_agent.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/osbrain/tests/test_agent.py b/osbrain/tests/test_agent.py index 99abea5..2e1f83d 100644 --- a/osbrain/tests/test_agent.py +++ b/osbrain/tests/test_agent.py @@ -532,15 +532,28 @@ def test_has_socket(nsproxy): assert a0.has_socket('pub') -def test_close(nsproxy): +def test_close_bound(nsproxy): """ - Test that closing a socket removes it from the socket entry. + Test that closing a bound socket removes it from the socket entry. """ a0 = run_agent('a0') - a0.bind('PUB', alias='pub') + a0.bind('PUB', alias='bound') - a0.close('pub') - assert not a0.has_socket('pub') + a0.close('bound') + assert not a0.has_socket('bound') + + +def test_close_connected(nsproxy): + """ + Test that closing a connected socket removes it from the socket entry. + """ + a0 = run_agent('a0') + a1 = run_agent('a1') + pub = a0.bind('PUB', alias='pub') + a1.connect(pub, alias='connected', handler=echo_handler) + + a1.close('connected') + assert not a1.has_socket('connected') def test_close_socket_poller_cleanup(nsproxy):