def test_completion_on_macro_attribute_returns_expected( self, galaxy_xsd_tree: XsdTree, source_with_mark: str, expected_item_names: List[str], mocker: MockerFixture, ) -> None: position, source_without_mark = TestUtils.extract_mark_from_source( "^", source_with_mark) document = TestUtils.from_source_to_xml_document(source_without_mark) context_service = XmlContextService(galaxy_xsd_tree) context = context_service.get_xml_context(document, position) fake_completion_context = CompletionContext( trigger_kind=CompletionTriggerKind.Invoked) workspace = mocker.Mock() definitions_provider = DocumentDefinitionsProvider( MacroDefinitionsProvider(workspace)) completion_service = XmlCompletionService(galaxy_xsd_tree, definitions_provider) completion_result = completion_service.get_completion_at_context( context, fake_completion_context) assert completion_result assert sorted([item.label for item in completion_result.items ]) == sorted(expected_item_names)
def test_get_completion_at_context_inside_cdata_returns_none( self, fake_tree: XsdTree, fake_xml_doc: XmlDocument, fake_definitions_provider: DocumentDefinitionsProvider, ) -> None: fake_element = XmlCDATASection(0, 0) fake_context = XmlContext(fake_xml_doc, fake_tree.root, fake_element) fake_completion_context = CompletionContext(trigger_kind=CompletionTriggerKind.Invoked) service = XmlCompletionService(fake_tree, fake_definitions_provider) actual = service.get_completion_at_context(fake_context, fake_completion_context) assert not actual
def test_get_completion_at_context_with_open_tag_trigger_returns_expected_node( self, fake_tree: XsdTree, fake_xml_doc: XmlDocument, fake_definitions_provider: DocumentDefinitionsProvider, ) -> None: fake_context = XmlContext(fake_xml_doc, fake_tree.root, XmlElement()) fake_completion_context = CompletionContext(trigger_kind=CompletionTriggerKind.TriggerCharacter, trigger_character="<") service = XmlCompletionService(fake_tree, fake_definitions_provider) actual = service.get_completion_at_context(fake_context, fake_completion_context) assert actual assert len(actual.items) == 2 assert actual.items[0].label == "child" assert actual.items[0].kind == CompletionItemKind.Class assert actual.items[1].label == "expand" assert actual.items[1].kind == CompletionItemKind.Class