unit test a few more lines

This commit is contained in:
Mike Kinney
2021-12-30 22:59:01 -08:00
parent 9adbed4be6
commit 614a90c0eb
2 changed files with 9 additions and 2 deletions

View File

@@ -17,8 +17,6 @@ class TCPInterface(StreamInterface):
hostname {string} -- Hostname/IP address of the device to connect to
"""
# Instead of wrapping as a stream, we use the native socket API
# self.stream = sock.makefile('rw')
self.stream = None
self.hostname = hostname

View File

@@ -13,6 +13,7 @@ def test_TCPInterface(capsys):
"""Test that we can instantiate a TCPInterface"""
with patch('socket.socket') as mock_socket:
iface = TCPInterface(hostname='localhost', noProto=True)
iface.myConnect()
iface.showInfo()
iface.localNode.showInfo()
out, err = capsys.readouterr()
@@ -24,3 +25,11 @@ def test_TCPInterface(capsys):
assert err == ''
assert mock_socket.called
iface.close()
@pytest.mark.unit
def test_TCPInterface_without_connecting(capsys):
"""Test that we can instantiate a TCPInterface with connectNow as false"""
with patch('socket.socket'):
iface = TCPInterface(hostname='localhost', noProto=True, connectNow=False)
assert iface.socket is None