-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some tests for DocumentSymbolsProvider
- Loading branch information
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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("<tool></tool>") | ||
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("<tool><command></command></tool>") | ||
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("<tool><command executable='true'></command></tool>") | ||
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('<tool id="TEST"></tool>') | ||
provider = DocumentSymbolsProvider() | ||
symbols = provider.get_document_symbols(xml_document) | ||
assert len(symbols) == 1 | ||
element_symbol = symbols[0] | ||
assert element_symbol.detail == "TEST" |