mirror of
https://github.com/meshtastic/python.git
synced 2026-01-16 19:58:04 -05:00
13
README.md
13
README.md
@@ -156,10 +156,21 @@ If you need to build a new release you'll need:
|
||||
|
||||
```
|
||||
apt install pandoc
|
||||
sudo pip3 install markdown pdoc3 webencodings pyparsing twine autopep8 pylint
|
||||
sudo pip3 install markdown pdoc3 webencodings pyparsing twine autopep8 pylint pytest
|
||||
```
|
||||
|
||||
To lint, run:
|
||||
```
|
||||
pylint meshtastic
|
||||
```
|
||||
|
||||
To test, first install this code locally, then run pytest:
|
||||
```
|
||||
pip3 install .
|
||||
pytest
|
||||
```
|
||||
Possible options for testing:
|
||||
* for more verbosity, add "-v" or even "-vv" like this: pytest -vv
|
||||
* to run just unit tests: pytest -munit
|
||||
* to run just integration tests: pytest -mint
|
||||
* if you want to add another classification of tests, then look in pytest.ini
|
||||
|
||||
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
|
||||
37
meshtastic/test/test_node.py
Normal file
37
meshtastic/test/test_node.py
Normal file
@@ -0,0 +1,37 @@
|
||||
"""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_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'
|
||||
5
pytest.ini
Normal file
5
pytest.ini
Normal file
@@ -0,0 +1,5 @@
|
||||
[pytest]
|
||||
|
||||
markers =
|
||||
unit: marks tests as unit tests
|
||||
int: marks tests as integration tests
|
||||
Reference in New Issue
Block a user