-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix await_done in RunnerSingleThread (#423)
* Fix await_done in RunnerSingleThread * codestyle * do not change timeout in ConnectionObserver during await_done * fix runner timeout for ConnectionObserver * fix * prearation for 1.32.2
- Loading branch information
1 parent
c6248a9
commit 5038303
Showing
6 changed files
with
41 additions
and
11 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
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 |
---|---|---|
|
@@ -3,17 +3,18 @@ | |
Testing of uptime command. | ||
""" | ||
__author__ = 'Marcin Usielski' | ||
__copyright__ = 'Copyright (C) 2018-2019, Nokia' | ||
__copyright__ = 'Copyright (C) 2018-2021, Nokia' | ||
__email__ = '[email protected]' | ||
|
||
import pytest | ||
import time | ||
from moler.exceptions import CommandFailure | ||
from moler.exceptions import CommandTimeout | ||
from moler.cmd.unix.uptime import Uptime | ||
|
||
|
||
def test_calling_uptime_returns_result_parsed_from_command_output(buffer_connection, | ||
command_output_and_expected_result): | ||
from moler.cmd.unix.uptime import Uptime | ||
command_output, expected_result = command_output_and_expected_result | ||
buffer_connection.remote_inject_response([command_output]) | ||
uptime_cmd = Uptime(connection=buffer_connection.moler_connection) | ||
|
@@ -30,28 +31,53 @@ def test_calling_uptime_fails_unsupported_format(buffer_connection, command_unsu | |
uptime_cmd() | ||
|
||
|
||
def test_calling_uptime_timeout_with_long_timeout(buffer_connection): | ||
uptime_cmd = Uptime(connection=buffer_connection.moler_connection) | ||
long_timeout = 300 | ||
uptime_cmd.terminating_timeout = 0.2 | ||
uptime_cmd.start(timeout=long_timeout) | ||
uptime_cmd.timeout = long_timeout | ||
start_time = time.time() | ||
with pytest.raises(CommandTimeout): | ||
uptime_cmd.await_done(timeout=1) | ||
end_time = time.time() | ||
duration = end_time - start_time | ||
assert duration < long_timeout/10 | ||
|
||
|
||
def test_calling_uptime_timeout_with_short_timeout(buffer_connection): | ||
uptime_cmd = Uptime(connection=buffer_connection.moler_connection) | ||
short_timeout = 7 | ||
uptime_cmd.terminating_timeout = 0.2 | ||
uptime_cmd.start(timeout=short_timeout) | ||
start_time = time.time() | ||
with pytest.raises(CommandTimeout): | ||
uptime_cmd.await_done() | ||
end_time = time.time() | ||
duration = end_time - start_time | ||
assert duration < short_timeout + 1 | ||
assert duration >= short_timeout | ||
|
||
|
||
def test_calling_uptime_timeout(buffer_connection): | ||
from moler.cmd.unix.uptime import Uptime | ||
uptime_cmd = Uptime(connection=buffer_connection.moler_connection) | ||
uptime_cmd.terminating_timeout = 0.2 | ||
uptime_cmd.timeout = 0.2 | ||
with pytest.raises(CommandTimeout): | ||
uptime_cmd() | ||
|
||
|
||
def test_uptime_returns_proper_command_string(buffer_connection): | ||
from moler.cmd.unix.uptime import Uptime | ||
uptime_cmd = Uptime(buffer_connection.moler_connection) | ||
assert "uptime" == uptime_cmd.command_string | ||
|
||
|
||
def test_uptime_sends_with_enter(buffer_connection): | ||
from moler.cmd.unix.uptime import Uptime | ||
uptime_cmd = Uptime(buffer_connection.moler_connection) | ||
uptime_cmd.send_command() | ||
|
||
|
||
def test_uptime_sends_without_enter(buffer_connection): | ||
from moler.cmd.unix.uptime import Uptime | ||
uptime_cmd = Uptime(buffer_connection.moler_connection) | ||
uptime_cmd.newline_after_command_string = False | ||
uptime_cmd.send_command() | ||
|