Skip to content

Commit 7601b1f

Browse files
committed
feat: add mark, so device test run only on ci with preconfigured mocked device
1 parent 1a78d4a commit 7601b1f

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

.github/workflows/poetry-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,4 @@ jobs:
6969
run: |
7070
source /opt/ros/${{ matrix.ros_distro }}/setup.bash
7171
source install/setup.bash
72-
poetry run pytest
72+
poetry run pytest -m "not billable"

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ profile = "black"
8585
[tool.pytest.ini_options]
8686
markers = [
8787
"billable: marks test as billable (deselect with '-m \"not billable\"')",
88+
"ci_only: marks test as cli only (deselect with '-m \"not ci_only\"')",
8889
]
89-
addopts = "-m 'not billable' --ignore=src"
90+
addopts = "-m 'not billable and not ci_only' --ignore=src"
9091
log_cli = true
9192
log_cli_level = "DEBUG"

tests/communication/test_sound_device_connector.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def device_config():
3737
}
3838

3939

40+
@pytest.mark.ci_only
4041
def test_configure(
4142
setup_mock_input_stream,
4243
device_config,
@@ -61,6 +62,7 @@ def test_configure(
6162
assert audio_input_device.configred_devices[device_id].dtype == "float32"
6263

6364

65+
@pytest.mark.ci_only
6466
def test_start_action_failed_init(
6567
setup_mock_input_stream,
6668
):
@@ -79,6 +81,7 @@ def test_start_action_failed_init(
7981
)
8082

8183

84+
@pytest.mark.ci_only
8285
def test_start_action(
8386
setup_mock_input_stream,
8487
device_config,
@@ -91,17 +94,22 @@ def test_start_action(
9194
feedback_callback = mock.MagicMock()
9295
finish_callback = mock.MagicMock()
9396

94-
recording_device = "0"
95-
audio_input_device.configure_device(recording_device, device_config)
97+
device = sd.query_devices(kind="input")
98+
if type(device) is dict:
99+
device_id = str(device["index"])
100+
elif isinstance(device, list):
101+
device_id = str(device[0]["index"]) # type: ignore
102+
else:
103+
assert False
104+
audio_input_device.configure_device(device_id, device_config)
96105

97106
stream_handle = audio_input_device.start_action(
98-
str(recording_device), feedback_callback, finish_callback
107+
device_id, feedback_callback, finish_callback
99108
)
100109

101110
assert mock_input_stream.call_count == 1
102111
init_args = mock_input_stream.call_args.kwargs
103-
assert init_args["device"] == int(recording_device)
104-
assert init_args["callback"] == feedback_callback
112+
assert init_args["device"] == int(device_id)
105113
assert init_args["finished_callback"] == finish_callback
106114

107115
assert audio_input_device.streams.get(stream_handle) is not None

0 commit comments

Comments
 (0)