示例#1
0
    def test_string_tyle(self):
        """
        Tests string style conversion
        """
        source = {
            "description": "some desc",
            "type": "sensor",
            "uuid": "26d6e362-a422-11ea-bb37-0242ac130002"
        }
        node = VSSNode("test", source)

        self.assertEqual("TEST",
                         node.qualified_name(".", StringStyle.UPPER_CASE))
        self.assertEqual("Test",
                         node.qualified_name(".", StringStyle.CAPITAL_CASE))
        self.assertEqual("test",
                         node.qualified_name(".", StringStyle.LOWER_CASE))

        source = {
            "description": "some desc",
            "type": "sensor",
            "uuid": "26d6e362-a422-11ea-bb37-0242ac130002"
        }
        node = VSSNode("LongerTestName", source)
        self.assertEqual("LONGERTESTNAME",
                         node.qualified_name(".", StringStyle.UPPER_CASE))
        self.assertEqual("LongerTestName",
                         node.qualified_name(".", StringStyle.CAPITAL_CASE))
        self.assertEqual("longertestname",
                         node.qualified_name(".", StringStyle.LOWER_CASE))
        self.assertEqual("longer_test_name",
                         node.qualified_name(".", StringStyle.SNAKE_CASE))
        self.assertEqual("longerTestName",
                         node.qualified_name(".", StringStyle.CAMEL_BACK))
示例#2
0
    def test_private_attribute(self):
        """
        Test if private attribute construction is correctly working.
        """
        source_root = {
            "description": "High-level vehicle data.",
            "type": "branch",
            "uuid": "f6750f15-ba2f-4eab-adcc-19a500982293"
        }
        source_private = {
            "description": "Private vehicle data.",
            "type": "branch",
            "uuid": "5fb3f710-ed60-426b-a083-015cc7c7bc1b"
        }
        source_private_element = {
            "description": "Private vehicle data.",
            "type": "sensor",
            "datatype": "string",
            "uuid": "9101bbea-aeb6-4b0e-8cec-d8b126e77898"
        }
        node_root = VSSNode("Vehicle", source_root)
        node_private = VSSNode("Private", source_private, node_root)
        node_private_element = VSSNode("Element", source_private_element,
                                       node_private)

        self.assertTrue(node_private_element.is_private())
        self.assertEqual(
            "Vehicle.Private.Element",
            node_private_element.qualified_name('.', StringStyle.NONE))
示例#3
0
def to_gql_type(node: VSSNode, additional_leaf_fields: list) -> GraphQLObjectType:
    return GraphQLObjectType(
        name=node.qualified_name("_"),
        fields=leaf_fields(node, additional_leaf_fields) if hasattr(node, "datatype") else branch_fields(node,additional_leaf_fields),
        description=node.description,
    )