-
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #135 from goToMain/osdp_pd_status
Add support for PD online status
- Loading branch information
Showing
7 changed files
with
135 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Run Tests | ||
|
||
`make check` on cmake builds will invoke pytest correctly. During development, | ||
it might be useful to run an individual test (instead of everything). To do so, | ||
|
||
``` | ||
PYTHONPATH=../../build/python/ python3 -m pytest -vv -s test_events.py::test_event_input | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# | ||
# Copyright (c) 2023 Siddharth Chandrasekaran <[email protected]> | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
import time | ||
import pytest | ||
|
||
from testlib import * | ||
|
||
pd_cap = PDCapabilities([ | ||
(Capability.OutputControl, 1, 1), | ||
(Capability.LEDControl, 1, 1), | ||
(Capability.AudibleControl, 1, 1), | ||
(Capability.TextOutput, 1, 1), | ||
]) | ||
|
||
pd_info = [ | ||
PDInfo(101, scbk=KeyStore.gen_key(), name='chn-0'), | ||
] | ||
|
||
# TODO remove this. | ||
pd_addr = pd_info[0].address | ||
pd = PeripheralDevice(pd_info[0], pd_cap, log_level=LogLevel.Debug) | ||
cp = ControlPanel(pd_info) | ||
|
||
@pytest.fixture(scope='module', autouse=True) | ||
def setup_test(): | ||
pd.start() | ||
cp.start() | ||
cp.sc_wait_all() | ||
yield | ||
teardown_test() | ||
|
||
def teardown_test(): | ||
cp.teardown() | ||
pd.teardown() | ||
|
||
def test_cp_status(): | ||
assert cp.online_wait(pd.address) | ||
pd.stop() | ||
assert cp.online_wait(pd.address) == False | ||
pd.start() | ||
assert cp.online_wait(pd.address) | ||
|
||
def test_cp_sc_status(): | ||
assert cp.sc_wait(pd.address) | ||
pd.stop() | ||
assert cp.sc_wait(pd.address) == False | ||
pd.start() | ||
assert cp.sc_wait(pd.address) | ||
|
||
def test_pd_status(): | ||
cp.stop() | ||
time.sleep(1) | ||
assert pd.is_online() == False | ||
cp.start() | ||
assert cp.sc_wait(pd.address) | ||
assert pd.is_online() | ||
|
||
def test_pd_sc_status(): | ||
cp.stop() | ||
time.sleep(1) | ||
assert pd.is_sc_active() == False | ||
cp.start() | ||
assert cp.sc_wait(pd.address) | ||
assert pd.is_sc_active() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters