@@ -57,7 +57,6 @@ def test_MeshInterface(capsys, reset_globals):
5757def test_getMyUser (reset_globals , iface_with_nodes ):
5858 """Test getMyUser()"""
5959 iface = iface_with_nodes
60-
6160 iface .myInfo .my_node_num = 2475227164
6261 myuser = iface .getMyUser ()
6362 assert myuser is not None
@@ -459,3 +458,88 @@ def test_generatePacketId(capsys, reset_globals):
459458 assert re .search (r'Not connected yet, can not generate packet' , out , re .MULTILINE )
460459 assert err == ''
461460 assert pytest_wrapped_e .type == Exception
461+
462+
463+ @pytest .mark .unit
464+ def test_fixupPosition_empty_pos (capsys , reset_globals ):
465+ """Test _fixupPosition()"""
466+ iface = MeshInterface (noProto = True )
467+ pos = {}
468+ newpos = iface ._fixupPosition (pos )
469+ assert newpos == pos
470+
471+
472+ @pytest .mark .unit
473+ def test_fixupPosition_no_changes_needed (capsys , reset_globals ):
474+ """Test _fixupPosition()"""
475+ iface = MeshInterface (noProto = True )
476+ pos = {"latitude" : 101 , "longitude" : 102 }
477+ newpos = iface ._fixupPosition (pos )
478+ assert newpos == pos
479+
480+
481+ @pytest .mark .unit
482+ def test_fixupPosition (capsys , reset_globals ):
483+ """Test _fixupPosition()"""
484+ iface = MeshInterface (noProto = True )
485+ pos = {"latitudeI" : 1010000000 , "longitudeI" : 1020000000 }
486+ newpos = iface ._fixupPosition (pos )
487+ assert newpos == {"latitude" : 101.0 ,
488+ "latitudeI" : 1010000000 ,
489+ "longitude" : 102.0 ,
490+ "longitudeI" : 1020000000 }
491+
492+
493+ @pytest .mark .unit
494+ def test_nodeNumToId (capsys , reset_globals , iface_with_nodes ):
495+ """Test _nodeNumToId()"""
496+ iface = iface_with_nodes
497+ iface .myInfo .my_node_num = 2475227164
498+ someid = iface ._nodeNumToId (2475227164 )
499+ assert someid == '!9388f81c'
500+
501+
502+ @pytest .mark .unit
503+ def test_nodeNumToId_not_found (capsys , reset_globals , iface_with_nodes ):
504+ """Test _nodeNumToId()"""
505+ iface = iface_with_nodes
506+ iface .myInfo .my_node_num = 2475227164
507+ someid = iface ._nodeNumToId (123 )
508+ assert someid is None
509+
510+
511+ @pytest .mark .unit
512+ def test_nodeNumToId_to_all (capsys , reset_globals , iface_with_nodes ):
513+ """Test _nodeNumToId()"""
514+ iface = iface_with_nodes
515+ iface .myInfo .my_node_num = 2475227164
516+ someid = iface ._nodeNumToId (0xffffffff )
517+ assert someid == '^all'
518+
519+
520+ @pytest .mark .unit
521+ def test_getOrCreateByNum_minimal (capsys , reset_globals , iface_with_nodes ):
522+ """Test _getOrCreateByNum()"""
523+ iface = iface_with_nodes
524+ iface .myInfo .my_node_num = 2475227164
525+ tmp = iface ._getOrCreateByNum (123 )
526+ assert tmp == {'num' : 123 }
527+
528+
529+ @pytest .mark .unit
530+ def test_getOrCreateByNum_not_found (capsys , reset_globals , iface_with_nodes ):
531+ """Test _getOrCreateByNum()"""
532+ iface = iface_with_nodes
533+ iface .myInfo .my_node_num = 2475227164
534+ with pytest .raises (Exception ) as pytest_wrapped_e :
535+ iface ._getOrCreateByNum (0xffffffff )
536+ assert pytest_wrapped_e .type == Exception
537+
538+
539+ @pytest .mark .unit
540+ def test_getOrCreateByNum (capsys , reset_globals , iface_with_nodes ):
541+ """Test _getOrCreateByNum()"""
542+ iface = iface_with_nodes
543+ iface .myInfo .my_node_num = 2475227164
544+ tmp = iface ._getOrCreateByNum (2475227164 )
545+ assert tmp ['num' ] == 2475227164
0 commit comments