mirror of
https://github.com/meshtastic/python.git
synced 2025-12-31 03:47:55 -05:00
48 lines
1.1 KiB
Python
48 lines
1.1 KiB
Python
"""Meshtastic unit tests for node.py"""
|
|
import re
|
|
import subprocess
|
|
import platform
|
|
|
|
import pytest
|
|
|
|
from meshtastic.node import pskToString
|
|
from meshtastic.__init__ import MeshInterface
|
|
|
|
@pytest.mark.unit
|
|
def test_pskToString_empty_string():
|
|
"""Test pskToString empty string"""
|
|
assert pskToString('') == 'unencrypted'
|
|
|
|
|
|
@pytest.mark.unit
|
|
def test_pskToString_string():
|
|
"""Test pskToString string"""
|
|
assert pskToString('hunter123') == 'secret'
|
|
|
|
|
|
@pytest.mark.unit
|
|
def test_pskToString_one_byte_zero_value():
|
|
"""Test pskToString one byte that is value of 0"""
|
|
assert pskToString(bytes([0x00])) == 'unencrypted'
|
|
|
|
|
|
@pytest.mark.unit
|
|
def test_pskToString_one_byte_non_zero_value():
|
|
"""Test pskToString one byte that is non-zero"""
|
|
assert pskToString(bytes([0x01])) == 'default'
|
|
|
|
|
|
@pytest.mark.unit
|
|
def test_pskToString_many_bytes():
|
|
"""Test pskToString many bytes"""
|
|
assert pskToString(bytes([0x02, 0x01])) == 'secret'
|
|
|
|
|
|
@pytest.mark.unit
|
|
def test_MeshInterface():
|
|
"""Test that we instantiate a MeshInterface"""
|
|
iface = MeshInterface(noProto=True)
|
|
iface.showInfo()
|
|
iface.localNode.showInfo()
|
|
iface.close()
|