Skip to content

Commit

Permalink
jedi/tests: Make PrimeHub the same as InventorHub.
Browse files Browse the repository at this point in the history
  • Loading branch information
laurensvalk committed Nov 22, 2022
1 parent ef57dbf commit 7dd3eda
Showing 1 changed file with 13 additions and 110 deletions.
123 changes: 13 additions & 110 deletions jedi/tests/test_complete_inventor_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,113 +27,16 @@ def _create_snippet(line: str) -> str:
return "\n".join((IMPORT, CREATE_INSTANCE, line))


def test_hub_dot():
line = "hub."
code = _create_snippet(line)
completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1))
assert [c["insertText"] for c in completions] == [
"battery",
"buttons",
"charger",
"display",
"imu",
"light",
"speaker",
"system",
]


def test_hub_dot_battery_dot():
line = "hub.battery."
code = _create_snippet(line)
completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1))
assert [c["insertText"] for c in completions] == [
"current",
"voltage",
]


def test_hub_dot_buttons_dot():
line = "hub.buttons."
code = _create_snippet(line)
completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1))
assert [c["insertText"] for c in completions] == [
"pressed",
]


def test_hub_dot_charger_dot():
line = "hub.charger."
code = _create_snippet(line)
completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1))
assert [c["insertText"] for c in completions] == [
"connected",
"current",
"status",
]


def test_hub_dot_display_dot():
line = "hub.display."
code = _create_snippet(line)
completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1))
assert [c["insertText"] for c in completions] == [
"animate",
"char",
"image",
"number",
"off",
"orientation",
"pixel",
"text",
]


def test_hub_dot_imu_dot():
line = "hub.imu."
code = _create_snippet(line)
completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1))
assert [c["insertText"] for c in completions] == [
"acceleration",
"angular_velocity",
"heading",
"reset_heading",
"tilt",
"up",
]


def test_hub_dot_light_dot():
line = "hub.light."
code = _create_snippet(line)
completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1))
assert [c["insertText"] for c in completions] == [
"animate",
"blink",
"off",
"on",
]


def test_hub_dot_speaker_dot():
line = "hub.speaker."
code = _create_snippet(line)
completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1))
assert [c["insertText"] for c in completions] == [
"beep",
"play_notes",
"volume",
]


def test_hub_dot_system_dot():
line = "hub.system."
code = _create_snippet(line)
completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1))
assert [c["insertText"] for c in completions] == [
"name",
"reset_reason",
"set_stop_button",
"shutdown",
"storage",
]
# Everything else is the same as the Prime Hub.

from test_complete_prime_hub import ( # noqa F401

This comment has been minimized.

Copy link
@dlech

dlech Nov 22, 2022

Member

These aren't actually the same test. The deleted ones tested

from pybricks.hubs import InventorHub
hub.

but the imported ones test

from pybricks.hubs import Primehub
hub.

There is not much use in running the exact same tests twice.

I haven't ever got around to it, but we can do a better job reducing code duplication for all hubs by using @pytest.mark.parametrize like we do for signatures, etc.

test_hub_dot,
test_hub_dot_battery_dot,
test_hub_dot_buttons_dot,
test_hub_dot_charger_dot,
test_hub_dot_display_dot,
test_hub_dot_imu_dot,
test_hub_dot_light_dot,
test_hub_dot_speaker_dot,
test_hub_dot_system_dot,
)

0 comments on commit 7dd3eda

Please sign in to comment.