Skip to content

Commit ec9809e

Browse files
committed
add more tests
1 parent b44d968 commit ec9809e

File tree

249 files changed

+3131
-245
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

249 files changed

+3131
-245
lines changed

tests/robotcode/language_server/robotframework/parts/data/goto.robot

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,28 @@ first
4141

4242
firstresource.do something in a resource
4343
# ^^^^^^^^^^^^^^^^^^^^^^^^^^ Keyword from resource
44-
# ^^^^^^^^^^^^^ Namespace from resource
44+
# ^^^^^^^^^^^^^ Namespace from resource
45+
a simple keyword
46+
# ^^^^^^^^^^^^^^^^ call a simple keyword
47+
an unknown keyword
48+
# ^^^^^^^^^^^^^^^^^^ unknown keyword
49+
50+
second
51+
[Setup] Log hello setup
52+
# ^^^ a keyword in setup
53+
[Teardown] BuiltIn.Log hello teardown
54+
# ^^^ a keyword in teardown
55+
# ^^^^^^^ a namespace in teardown
56+
57+
a templated Test
58+
[Template] BuiltIn.Log
59+
# ^^^ a keyword in template
60+
# ^^^^^^^ a namespace in template
61+
hello
62+
world
63+
64+
65+
*** Keywords ***
66+
a simple keyword
67+
#^^^^^^^^^^^^^^^ a simple keyword
68+
Log hello

tests/robotcode/language_server/robotframework/parts/data/hover.robot

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ ${A VAR} i'm a var
2121
first
2222
[Setup] Log Hello ${A VAR}
2323
# ^^^ Keyword in Setup
24-
[Teardown] Log Hello ${A VAR}
25-
# ^^^ Keyword in Teardown
24+
[Teardown] BuiltIn.Log Hello ${A VAR}
25+
# ^^^ Keyword in Teardown
26+
# ^^^^^^^ Namespace in Teardown
2627

2728
Log Hello ${A VAR}
2829
# ^^^ Keyword from Library
@@ -51,6 +52,13 @@ first
5152
# ^^^^^^^^^^^^^^^^^^^^^^^^^^ KeywordCall from resource with Namespace
5253
# ^^^^^^^^^^^^^ Namespace from resource
5354

55+
second
56+
#^^^^^ Test Case
57+
[Template] BuiltIn.Log
58+
# ^^^ Keyword in Template
59+
# ^^^^^^^ Namespace in Template
60+
hello
61+
world
5462

5563
*** Keywords ***
5664
a keyword

tests/robotcode/language_server/robotframework/parts/test_goto.py

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,29 @@
1818
)
1919

2020

21+
def split(
22+
result: Union[Location, LocationLink, List[Location], List[LocationLink], None]
23+
) -> Union[Location, LocationLink, List[Location], List[LocationLink], None]:
24+
if result is None:
25+
return None
26+
if isinstance(result, Location):
27+
return Location((Uri(result.uri).to_path().name), result.range)
28+
if isinstance(result, LocationLink):
29+
return LocationLink(
30+
result.origin_selection_range,
31+
(Uri(result.target_uri).to_path().name),
32+
result.target_range,
33+
result.target_selection_range,
34+
)
35+
if isinstance(result, list) and len(result) > 0 and isinstance(result[0], LocationLink):
36+
return cast("List[LocationLink]", [split(v) for v in result])
37+
38+
if isinstance(result, list) and len(result) > 0 and isinstance(result[0], Location):
39+
return cast("List[Location]", [split(v) for v in result])
40+
41+
return result
42+
43+
2144
@pytest.mark.parametrize(
2245
("test_document", "data"),
2346
generate_tests_from_source_document(Path(Path(__file__).parent, "data/goto.robot")),
@@ -26,7 +49,7 @@
2649
)
2750
@pytest.mark.usefixtures("protocol")
2851
@pytest.mark.asyncio
29-
async def test(
52+
async def test_definition(
3053
data_regression: DataRegressionFixture,
3154
protocol: RobotLanguageServerProtocol,
3255
test_document: TextDocument,
@@ -39,26 +62,28 @@ async def test(
3962
Position(line=data.line, character=data.character),
4063
)
4164

42-
def split(
43-
result: Union[Location, LocationLink, List[Location], List[LocationLink], None]
44-
) -> Union[Location, LocationLink, List[Location], List[LocationLink], None]:
45-
if result is None:
46-
return None
47-
if isinstance(result, Location):
48-
return Location((Uri(result.uri).to_path().name), result.range)
49-
if isinstance(result, LocationLink):
50-
return LocationLink(
51-
result.origin_selection_range,
52-
(Uri(result.target_uri).to_path().name),
53-
result.target_range,
54-
result.target_selection_range,
55-
)
56-
if isinstance(result, list) and len(result) > 0 and isinstance(result[0], LocationLink):
57-
return cast("List[LocationLink]", [split(v) for v in result])
65+
data_regression.check({"data": data, "result": split(result)})
5866

59-
if isinstance(result, list) and len(result) > 0 and isinstance(result[0], Location):
60-
return cast("List[Location]", [split(v) for v in result])
6167

62-
return result
68+
@pytest.mark.parametrize(
69+
("test_document", "data"),
70+
generate_tests_from_source_document(Path(Path(__file__).parent, "data/goto.robot")),
71+
indirect=["test_document"],
72+
ids=generate_test_id,
73+
)
74+
@pytest.mark.usefixtures("protocol")
75+
@pytest.mark.asyncio
76+
async def test_implementation(
77+
data_regression: DataRegressionFixture,
78+
protocol: RobotLanguageServerProtocol,
79+
test_document: TextDocument,
80+
data: GeneratedTestData,
81+
) -> None:
82+
83+
result = await protocol.robot_goto.collect_implementation(
84+
protocol.robot_goto,
85+
test_document,
86+
Position(line=data.line, character=data.character),
87+
)
6388

6489
data_regression.check({"data": data, "result": split(result)})

0 commit comments

Comments
 (0)