-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor timeout code so that it can be unit tested.
Added unit test for timeout adjustment.
- Loading branch information
1 parent
7164d74
commit fab46b5
Showing
2 changed files
with
65 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import pytest | ||
|
||
from porter.main import Porter | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"timeout_scenarios", | ||
[ | ||
(None, 10, 10), | ||
(1, 10, 1), | ||
(5, 10, 5), | ||
(9, 10, 9), | ||
(10, 10, 10), | ||
(11, 10, 10), | ||
(20, 10, 10), | ||
(25, 10, 10), | ||
( | ||
Porter.MAX_GET_URSULAS_TIMEOUT - 1, | ||
Porter.MAX_GET_URSULAS_TIMEOUT, | ||
Porter.MAX_GET_URSULAS_TIMEOUT - 1, | ||
), | ||
( | ||
Porter.MAX_GET_URSULAS_TIMEOUT + 1, | ||
Porter.MAX_GET_URSULAS_TIMEOUT, | ||
Porter.MAX_GET_URSULAS_TIMEOUT, | ||
), | ||
( | ||
Porter.MAX_DECRYPTION_TIMEOUT / 2, | ||
Porter.MAX_DECRYPTION_TIMEOUT, | ||
Porter.MAX_DECRYPTION_TIMEOUT / 2, | ||
), | ||
( | ||
Porter.MAX_DECRYPTION_TIMEOUT * 2, | ||
Porter.MAX_DECRYPTION_TIMEOUT, | ||
Porter.MAX_DECRYPTION_TIMEOUT, | ||
), | ||
], | ||
) | ||
def test_porter_configure_timeout_defined_results(porter, timeout_scenarios): | ||
provided_timeout, max_timeout, expected_timeout = timeout_scenarios | ||
resultant_timeout = porter._configure_timeout( | ||
operation="test", timeout=provided_timeout, max_timeout=max_timeout | ||
) | ||
assert resultant_timeout == expected_timeout |