From 3ee9c856411f9f1af6ce1403f04941c8da9a26a0 Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Thu, 12 Oct 2023 18:23:05 +0200 Subject: [PATCH] Add some tests for DocumentSymbolsProvider --- server/galaxyls/tests/unit/test_symbols.py | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 server/galaxyls/tests/unit/test_symbols.py diff --git a/server/galaxyls/tests/unit/test_symbols.py b/server/galaxyls/tests/unit/test_symbols.py new file mode 100644 index 0000000..0cfd128 --- /dev/null +++ b/server/galaxyls/tests/unit/test_symbols.py @@ -0,0 +1,44 @@ +from galaxyls.services.symbols import DocumentSymbolsProvider +from galaxyls.tests.unit.utils import TestUtils + +FIELD_SYMBOL_KIND = 8 # SymbolKind.Field +PROPERTY_SYMBOL_KIND = 7 # SymbolKind.Property + + +def test_get_document_symbols(): + xml_document = TestUtils.from_source_to_xml_document("") + provider = DocumentSymbolsProvider() + symbols = provider.get_document_symbols(xml_document) + assert len(symbols) == 1 + assert symbols[0].name == "tool" + assert symbols[0].kind == FIELD_SYMBOL_KIND + assert len(symbols[0].children) == 0 + + +def test_get_element_children_symbols(): + xml_document = TestUtils.from_source_to_xml_document("") + provider = DocumentSymbolsProvider() + symbols = provider.get_document_symbols(xml_document) + element_symbol = symbols[0] + children_symbols = element_symbol.children + assert len(children_symbols) == 1 + assert children_symbols[0].name == "command" + assert children_symbols[0].kind == FIELD_SYMBOL_KIND + + +def test_get_attribute_symbol_definition(): + xml_document = TestUtils.from_source_to_xml_document("") + provider = DocumentSymbolsProvider() + symbols = provider.get_document_symbols(xml_document) + attribute_symbol = symbols[0].children[0].children[0] + assert attribute_symbol.name == "executable" + assert attribute_symbol.kind == PROPERTY_SYMBOL_KIND + + +def test_get_element_symbol_detail(): + xml_document = TestUtils.from_source_to_xml_document('') + provider = DocumentSymbolsProvider() + symbols = provider.get_document_symbols(xml_document) + assert len(symbols) == 1 + element_symbol = symbols[0] + assert element_symbol.detail == "TEST"