forked from selfcustody/krux
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
1,852 additions
and
1,792 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,33 @@ | ||
from .shared_mocks import mock_context | ||
import pytest | ||
|
||
|
||
def test_auto_shutdown(m5stickv, mocker): | ||
from krux.auto_shutdown import auto_shutdown, seconds_counter | ||
|
||
ctx = mock_context(mocker) | ||
auto_shutdown.add_ctx(ctx) | ||
|
||
# Set the timeout to a value that will cause a shutdown in 2 seconds | ||
auto_shutdown.time_out = 1 | ||
|
||
# Call the seconds_counter method to simulate the timer callback | ||
# Check if SystemExit is raised | ||
with pytest.raises(SystemExit): | ||
# Mocking timer calls: | ||
# Decrement the time_out value to 0 | ||
seconds_counter("dummy timer argument") | ||
# Next timer call will shutdown the device | ||
seconds_counter("dummy timer argument") | ||
|
||
|
||
def test_feed(m5stickv, mocker): | ||
from krux.auto_shutdown import auto_shutdown | ||
from krux.krux_settings import Settings | ||
|
||
auto_shutdown.time_out = 1000 | ||
|
||
# Call the feed method to reset the timeout | ||
auto_shutdown.feed() | ||
# Check if the timeout is reset to the value set in the settings | ||
assert auto_shutdown.time_out == Settings().security.auto_shutdown * 60 |
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