-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathtest_commands.py
41 lines (38 loc) · 1.09 KB
/
test_commands.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import pytest
from samsung_mdc import MDC, commands
@pytest.mark.parametrize('command,display_id,req,req_data,resp,resp_data', [
[
'power', 0,
[1], [1],
[1], [commands.POWER.POWER_STATE.ON]
],
[
'panel_on_time', 0,
[], [],
[2 ** 15], [128, 0]
],
[
'panel_on_time', 0,
[], [],
[2 ** 15], [0, 128, 0] # dynamic response length for newer models
],
[
'panel_on_time', 0,
[], [],
[2 ** 16 + 1], [1, 0, 1]
],
[
'network_ap_config', 0,
['ssid', 'passwd'], bytes([0, 4]) + b'ssid' + bytes([1, 6]) + b'passwd',
['ssid', 'passwd'], bytes([0, 4]) + b'ssid' + bytes([1, 6]) + b'passwd',
],
])
@pytest.mark.asyncio
async def test_command(
mdc_mock, command, display_id, req, req_data, resp, resp_data
):
command = MDC._commands[command]
mdc_mock.feed_response(command, display_id, resp_data)
result = await getattr(mdc_mock, command.name)(display_id, data=req)
mdc_mock.assert_request(command, display_id, req_data)
assert result == tuple(resp)