mirror of
https://github.com/meshtastic/python.git
synced 2026-02-25 11:10:14 -05:00
add unit tests for setOwner()
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"""Meshtastic unit tests for node.py"""
|
||||
|
||||
import re
|
||||
import logging
|
||||
|
||||
from unittest.mock import patch, MagicMock
|
||||
import pytest
|
||||
@@ -32,3 +33,51 @@ def test_node_reqquestConfig():
|
||||
with patch('meshtastic.admin_pb2.AdminMessage', return_value=amesg):
|
||||
anode = Node(mo, 'bar')
|
||||
anode.requestConfig()
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_setOwner_and_team(caplog):
|
||||
"""Test setOwner"""
|
||||
anode = Node('foo', 'bar', noProto=True)
|
||||
with caplog.at_level(logging.DEBUG):
|
||||
anode.setOwner(long_name ='Test123', short_name='123', team=1)
|
||||
assert re.search(r'p.set_owner.long_name:Test123:', caplog.text, re.MULTILINE)
|
||||
assert re.search(r'p.set_owner.short_name:123:', caplog.text, re.MULTILINE)
|
||||
assert re.search(r'p.set_owner.is_licensed:False', caplog.text, re.MULTILINE)
|
||||
assert re.search(r'p.set_owner.team:1', caplog.text, re.MULTILINE)
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_setOwner_no_short_name(caplog):
|
||||
"""Test setOwner"""
|
||||
anode = Node('foo', 'bar', noProto=True)
|
||||
with caplog.at_level(logging.DEBUG):
|
||||
anode.setOwner(long_name ='Test123')
|
||||
assert re.search(r'p.set_owner.long_name:Test123:', caplog.text, re.MULTILINE)
|
||||
assert re.search(r'p.set_owner.short_name:Tst:', caplog.text, re.MULTILINE)
|
||||
assert re.search(r'p.set_owner.is_licensed:False', caplog.text, re.MULTILINE)
|
||||
assert re.search(r'p.set_owner.team:0', caplog.text, re.MULTILINE)
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_setOwner_no_short_name_and_long_name_is_short(caplog):
|
||||
"""Test setOwner"""
|
||||
anode = Node('foo', 'bar', noProto=True)
|
||||
with caplog.at_level(logging.DEBUG):
|
||||
anode.setOwner(long_name ='Tnt')
|
||||
assert re.search(r'p.set_owner.long_name:Tnt:', caplog.text, re.MULTILINE)
|
||||
assert re.search(r'p.set_owner.short_name:Tnt:', caplog.text, re.MULTILINE)
|
||||
assert re.search(r'p.set_owner.is_licensed:False', caplog.text, re.MULTILINE)
|
||||
assert re.search(r'p.set_owner.team:0', caplog.text, re.MULTILINE)
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_setOwner_no_short_name_and_long_name_has_words(caplog):
|
||||
"""Test setOwner"""
|
||||
anode = Node('foo', 'bar', noProto=True)
|
||||
with caplog.at_level(logging.DEBUG):
|
||||
anode.setOwner(long_name ='A B C', is_licensed=True)
|
||||
assert re.search(r'p.set_owner.long_name:A B C:', caplog.text, re.MULTILINE)
|
||||
assert re.search(r'p.set_owner.short_name:ABC:', caplog.text, re.MULTILINE)
|
||||
assert re.search(r'p.set_owner.is_licensed:True', caplog.text, re.MULTILINE)
|
||||
assert re.search(r'p.set_owner.team:0', caplog.text, re.MULTILINE)
|
||||
|
||||
Reference in New Issue
Block a user