コード例 #1
0
    def test_completion_return_root_node_when_empty_context(
        self,
        fake_tree: XsdTree,
        fake_empty_context,
        fake_definitions_provider: DocumentDefinitionsProvider,
    ) -> None:
        service = XmlCompletionService(fake_tree, fake_definitions_provider)

        actual = service.get_node_completion(fake_empty_context)

        assert len(actual.items) == 1
        assert actual.items[0].label == fake_tree.root.name
コード例 #2
0
    def test_return_valid_completion_with_node_context(
        self,
        fake_tree: XsdTree,
        fake_context_on_root_node,
        fake_definitions_provider: DocumentDefinitionsProvider,
    ) -> None:
        service = XmlCompletionService(fake_tree, fake_definitions_provider)

        actual = service.get_node_completion(fake_context_on_root_node)

        assert len(actual.items) == 2
        assert actual.items[0].label == fake_tree.root.children[0].name
        assert actual.items[1].label == "expand"
コード例 #3
0
    def test_completion_node_reached_max_occurs_return_expected(
        self,
        fake_tree: XsdTree,
        fake_xml_doc: XmlDocument,
        fake_definitions_provider: DocumentDefinitionsProvider,
    ) -> None:
        fake_root = XmlElement()
        fake_root.name = fake_tree.root.name
        fake_root.end_tag_open_offset = 10
        fake_root.end_tag_close_offset = 15
        fake_child = XmlElement()
        fake_child.name = "child"
        fake_child.parent = fake_root
        fake_child = XmlElement()
        fake_child.parent = fake_root
        fake_context = XmlContext(fake_xml_doc, fake_tree.root, fake_root)
        service = XmlCompletionService(fake_tree, fake_definitions_provider)

        actual = service.get_node_completion(fake_context)

        assert len(actual.items) == 1
        assert actual.items[0].label == "expand"