mirror of
https://github.com/meshtastic/python.git
synced 2026-08-02 01:57:12 -04:00
add simple unit test
This commit is contained in:
BIN
meshtastic/test/.test_node.py.swp
Normal file
BIN
meshtastic/test/.test_node.py.swp
Normal file
Binary file not shown.
30
meshtastic/test/test_int.py
Normal file
30
meshtastic/test/test_int.py
Normal file
@@ -0,0 +1,30 @@
|
||||
"""Meshtastic integration tests"""
|
||||
import re
|
||||
import subprocess
|
||||
import platform
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.int
|
||||
def test_int_no_args():
|
||||
"""Test without any args"""
|
||||
return_value, out = subprocess.getstatusoutput('meshtastic')
|
||||
assert re.match(r'usage: meshtastic', out)
|
||||
assert return_value == 1
|
||||
|
||||
|
||||
@pytest.mark.int
|
||||
def test_int_version():
|
||||
"""Test '--version'."""
|
||||
return_value, out = subprocess.getstatusoutput('meshtastic --version')
|
||||
assert re.match(r'[0-9]+\.[0-9]+\.[0-9]', out)
|
||||
assert return_value == 0
|
||||
|
||||
|
||||
@pytest.mark.int
|
||||
def test_int_help():
|
||||
"""Test '--help'."""
|
||||
return_value, out = subprocess.getstatusoutput('meshtastic --help')
|
||||
assert re.match(r'usage: meshtastic ', out)
|
||||
assert return_value == 0
|
||||
16
meshtastic/test/test_node.py
Normal file
16
meshtastic/test/test_node.py
Normal file
@@ -0,0 +1,16 @@
|
||||
"""Meshtastic unit tests for node.py"""
|
||||
import re
|
||||
import subprocess
|
||||
import platform
|
||||
|
||||
import pytest
|
||||
|
||||
from meshtastic.node import pskToString
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_pskToString():
|
||||
"""Test pskToString"""
|
||||
assert pskToString('') == 'unencrypted'
|
||||
assert pskToString(bytes([0x00])) == 'unencrypted'
|
||||
assert pskToString(bytes([0x01])) == 'default'
|
||||
assert pskToString(bytes([0x02, 0x01])) == 'secret'
|
||||
Reference in New Issue
Block a user