Files
python/meshtastic/tests/conftest.py
Steve Holden a07e853f69 Refactor to remove pylint issues.
Since one of pylint's complains was that the globals module was
shadowing the built-in, and since the name `config` was already
is use in several modules, globals.py was renamed as mt_config.py.
All tests now pass, and the only remaining local pylint errors
relate to the protobuf code, I'm hoping this will make the PR
valid.
2024-04-10 17:42:44 +01:00

61 lines
1.4 KiB
Python

"""Common pytest code (place for fixtures)."""
import argparse
from unittest.mock import MagicMock
import pytest
from meshtastic import mt_config
from ..mesh_interface import MeshInterface
@pytest.fixture
def reset_mt_config():
"""Fixture to reset mt_config."""
parser = None
parser = argparse.ArgumentParser(add_help=False)
mt_config.reset()
mt_config.parser = parser
@pytest.fixture
def iface_with_nodes():
"""Fixture to setup some nodes."""
nodesById = {
"!9388f81c": {
"num": 2475227164,
"user": {
"id": "!9388f81c",
"longName": "Unknown f81c",
"shortName": "?1C",
"macaddr": "RBeTiPgc",
"hwModel": "TBEAM",
},
"position": {},
"lastHeard": 1640204888,
}
}
nodesByNum = {
2475227164: {
"num": 2475227164,
"user": {
"id": "!9388f81c",
"longName": "Unknown f81c",
"shortName": "?1C",
"macaddr": "RBeTiPgc",
"hwModel": "TBEAM",
},
"position": {"time": 1640206266},
"lastHeard": 1640206266,
}
}
iface = MeshInterface(noProto=True)
iface.nodes = nodesById
iface.nodesByNum = nodesByNum
myInfo = MagicMock()
iface.myInfo = myInfo
iface.myInfo.my_node_num = 2475227164
return iface