mirror of
https://github.com/meshtastic/python.git
synced 2026-01-14 18:57:56 -05:00
add some tests
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
"""Meshtastic unit tests for node.py"""
|
||||
"""Meshtastic unit tests for mesh_interface.py"""
|
||||
|
||||
import re
|
||||
|
||||
@@ -9,7 +9,7 @@ from meshtastic.mesh_interface import MeshInterface
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_MeshInterface(capsys):
|
||||
"""Test that we instantiate a MeshInterface"""
|
||||
"""Test that we can instantiate a MeshInterface"""
|
||||
iface = MeshInterface(noProto=True)
|
||||
iface.showInfo()
|
||||
iface.localNode.showInfo()
|
||||
|
||||
14
meshtastic/test/test_stream_interface.py
Normal file
14
meshtastic/test/test_stream_interface.py
Normal file
@@ -0,0 +1,14 @@
|
||||
"""Meshtastic unit tests for stream_interface.py"""
|
||||
|
||||
|
||||
import pytest
|
||||
|
||||
from meshtastic.stream_interface import StreamInterface
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_StreamInterface():
|
||||
"""Test that we can instantiate a StreamInterface"""
|
||||
with pytest.raises(Exception) as pytest_wrapped_e:
|
||||
StreamInterface(noProto=True)
|
||||
assert pytest_wrapped_e.type == Exception
|
||||
26
meshtastic/test/test_tcp_interface.py
Normal file
26
meshtastic/test/test_tcp_interface.py
Normal file
@@ -0,0 +1,26 @@
|
||||
"""Meshtastic unit tests for tcp_interface.py"""
|
||||
|
||||
import re
|
||||
|
||||
from unittest.mock import patch
|
||||
import pytest
|
||||
|
||||
from meshtastic.tcp_interface import TCPInterface
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
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.showInfo()
|
||||
iface.localNode.showInfo()
|
||||
out, err = capsys.readouterr()
|
||||
assert re.search(r'Owner: None \(None\)', out, re.MULTILINE)
|
||||
assert re.search(r'Nodes', out, re.MULTILINE)
|
||||
assert re.search(r'Preferences', out, re.MULTILINE)
|
||||
assert re.search(r'Channels', out, re.MULTILINE)
|
||||
assert re.search(r'Primary channel URL', out, re.MULTILINE)
|
||||
assert err == ''
|
||||
assert mock_socket.called
|
||||
iface.close()
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Meshtastic unit tests for node.py"""
|
||||
"""Meshtastic unit tests for util.py"""
|
||||
|
||||
import re
|
||||
|
||||
|
||||
Reference in New Issue
Block a user