From 614a90c0eb4bcd877ff3dd7c320df351142f459d Mon Sep 17 00:00:00 2001 From: Mike Kinney Date: Thu, 30 Dec 2021 22:59:01 -0800 Subject: [PATCH] unit test a few more lines --- meshtastic/tcp_interface.py | 2 -- meshtastic/tests/test_tcp_interface.py | 9 +++++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/meshtastic/tcp_interface.py b/meshtastic/tcp_interface.py index 25e5ab8..204872d 100644 --- a/meshtastic/tcp_interface.py +++ b/meshtastic/tcp_interface.py @@ -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 diff --git a/meshtastic/tests/test_tcp_interface.py b/meshtastic/tests/test_tcp_interface.py index 432caef..2848087 100644 --- a/meshtastic/tests/test_tcp_interface.py +++ b/meshtastic/tests/test_tcp_interface.py @@ -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