Exemplo n.º 1
0
    def test_merge_nodes(self):
        """
        Tests if merging two nodes works as expected
        """

        target = {
            "description": "some desc",
            "type": "sensor",
            "uuid": "e36a1d8c-4d06-4c22-ba69-e8b39434a7a3"
        }

        source = {
            "description": "some desc",
            "type": "sensor",
            "uuid": "2cc90035-e1c2-43bf-a394-1a439addc8ad",
            "datatype": "uint8",
            "unit": "km",
            "min": 0,
            "max": 100
        }

        node_target = VSSNode("MyNode", target)
        node_source = VSSNode("Private", source)
        self.assertEqual("e36a1d8c-4d06-4c22-ba69-e8b39434a7a3",
                         node_target.uuid)
        self.assertFalse(node_target.has_data_type())
        self.assertEqual("2cc90035-e1c2-43bf-a394-1a439addc8ad",
                         node_source.uuid)

        node_target.merge(node_source)
        self.assertEqual("2cc90035-e1c2-43bf-a394-1a439addc8ad",
                         node_target.uuid)
        self.assertTrue(node_target.has_data_type())
        self.assertEqual(VSSDataType.UINT8, node_target.data_type)
        self.assertEqual(Unit.KILOMETER, node_target.unit)
        self.assertEqual(0, node_target.min)
        self.assertEqual(100, node_target.max)
Exemplo n.º 2
0
 def test_simple_construction(self):
     """
     Test minimal object construction.
     """
     source = {
         "description": "some desc",
         "type": "sensor",
         "uuid": "26d6e362-a422-11ea-bb37-0242ac130002"
     }
     node = VSSNode("test", source)
     self.assertIsNotNone(node)
     self.assertEqual("some desc", node.description)
     self.assertEqual(VSSType.SENSOR, node.type)
     self.assertEqual("26d6e362-a422-11ea-bb37-0242ac130002", node.uuid)
     self.assertFalse(node.has_unit())
     self.assertFalse(node.has_data_type())
     self.assertFalse(node.is_private())