mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-07-27 19:57:02 +00:00
pybricks.messaging: Add tests.
This commit is contained in:
@@ -15,6 +15,7 @@ PYBRICKS_CODE_PACKAGES = {
|
||||
"pybricks",
|
||||
"pybricks.hubs",
|
||||
"pybricks.iodevices",
|
||||
"pybricks.messaging",
|
||||
"pybricks.parameters",
|
||||
"pybricks.pupdevices",
|
||||
"pybricks.robotics",
|
||||
@@ -490,6 +491,7 @@ def initialize():
|
||||
"pybricks.ev3dev.speaker",
|
||||
"pybricks.hubs",
|
||||
"pybricks.iodevices",
|
||||
"pybricks.messaging",
|
||||
"pybricks.parameters",
|
||||
"pybricks.pupdevices",
|
||||
"pybricks.robotics",
|
||||
|
||||
@@ -61,6 +61,7 @@ def test_from_pybricks_import():
|
||||
assert [c["insertText"] for c in completions] == [
|
||||
"hubs",
|
||||
"iodevices",
|
||||
"messaging",
|
||||
"parameters",
|
||||
"pupdevices",
|
||||
"robotics",
|
||||
@@ -75,6 +76,7 @@ def test_from_pybricks_dot():
|
||||
assert [c["insertText"] for c in completions] == [
|
||||
"hubs",
|
||||
"iodevices",
|
||||
"messaging",
|
||||
"parameters",
|
||||
"pupdevices",
|
||||
"robotics",
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Copyright (c) 2026 The Pybricks Authors
|
||||
|
||||
"""
|
||||
Tests for correct code completion of the messaging module.
|
||||
"""
|
||||
|
||||
import json
|
||||
|
||||
import pytest
|
||||
from pybricks_jedi import CompletionItem, complete
|
||||
|
||||
|
||||
def test_from_pybricks_messaging_import():
|
||||
code = "from pybricks.messaging import "
|
||||
completions: list[CompletionItem] = json.loads(complete(code, 1, len(code) + 1))
|
||||
assert [c["insertText"] for c in completions] == [
|
||||
"AppData",
|
||||
"BLERadio",
|
||||
"BluetoothMailboxClient",
|
||||
"BluetoothMailboxServer",
|
||||
"Connection",
|
||||
"LogicMailbox",
|
||||
"Mailbox",
|
||||
"NumericMailbox",
|
||||
"TextMailbox",
|
||||
]
|
||||
|
||||
|
||||
def test_ble_radio_dot():
|
||||
code = "\n".join(
|
||||
[
|
||||
"from pybricks.messaging import BLERadio",
|
||||
"ble = BLERadio()",
|
||||
"ble.",
|
||||
]
|
||||
)
|
||||
completions: list[CompletionItem] = json.loads(complete(code, 3, 5))
|
||||
assert [c["insertText"] for c in completions] == [
|
||||
"broadcast",
|
||||
"observe",
|
||||
"signal_strength",
|
||||
"version",
|
||||
]
|
||||
|
||||
|
||||
def test_app_data_dot():
|
||||
code = "\n".join(
|
||||
[
|
||||
"from pybricks.messaging import AppData",
|
||||
"app = AppData([(0, 4)])",
|
||||
"app.",
|
||||
]
|
||||
)
|
||||
completions: list[CompletionItem] = json.loads(complete(code, 3, 5))
|
||||
assert [c["insertText"] for c in completions] == [
|
||||
"close",
|
||||
"configure",
|
||||
"get_bytes",
|
||||
"write_bytes",
|
||||
]
|
||||
@@ -458,3 +458,8 @@ class AppData:
|
||||
|
||||
This is also called automatically when the object is garbage collected.
|
||||
"""
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
del MaybeAwaitable
|
||||
del T
|
||||
|
||||
Reference in New Issue
Block a user