Begin to rationalise test data.

Also refactor to silence some CI issues.
This commit is contained in:
Steve Holden
2024-04-10 14:25:17 +01:00
parent 067cddd354
commit 0d57449030
3 changed files with 18 additions and 9 deletions

View File

@@ -15,6 +15,7 @@ with rather more easily once the code is simplified by this change.
def reset():
"""
Restore the namespace to pristine condition.
"""
global args, parser, channel_index, logfile, tunnelInstance, camel_case
args = None
@@ -25,4 +26,11 @@ def reset():
# TODO: to migrate to camel_case for v1.3 change this value to True
camel_case = False
reset()
# These assignments are used instead of calling reset()
# purely to shut pylint up.
args = None
parser = None
channel_index = None
logfile = None
tunnelInstance = None
camel_case = False

View File

@@ -21,11 +21,12 @@ def test_MeshInterface(capsys):
"""Test that we can instantiate a MeshInterface"""
iface = MeshInterface(noProto=True)
nodes = {
"!9388f81c": {
"num": 2475227164,
NODE_ID = "!9388f81c"
NODE_NUM = 2475227164
node = {
"num": NODE_NUM,
"user": {
"id": "!9388f81c",
"id": NODE_ID,
"longName": "Unknown f81c",
"shortName": "?1C",
"macaddr": "RBeTiPgc",
@@ -34,10 +35,9 @@ def test_MeshInterface(capsys):
"position": {},
"lastHeard": 1640204888,
}
}
iface.nodesByNum = {2475227164: nodes["!9388f81c"]}
iface.nodes = nodes
iface.nodes = {NODE_ID: node}
iface.nodesByNum = {NODE_NUM: node}
myInfo = MagicMock()
iface.myInfo = myInfo

View File

@@ -1,5 +1,4 @@
"""Meshtastic unit tests for tunnel.py"""
from meshtastic import globals
import logging
import re
import sys
@@ -7,6 +6,8 @@ from unittest.mock import MagicMock, patch
import pytest
from meshtastic import globals
from ..tcp_interface import TCPInterface
from ..tunnel import Tunnel, onTunnelReceive