-
Notifications
You must be signed in to change notification settings - Fork 110
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
2 changed files
with
57 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,53 @@ | ||
import hypothesis.strategies as st | ||
from hypothesis import given | ||
from src.ert.shared.storage.key_utils import is_rate | ||
|
||
|
||
def nonempty_string_without_whitespace(): | ||
return st.text( | ||
st.characters(whitelist_categories=("Lu", "Ll", "Nd", "P")), min_size=1 | ||
) | ||
|
||
|
||
@given(key=nonempty_string_without_whitespace()) | ||
def test_is_rate_does_not_raise_error(key): | ||
print(key) | ||
is_rate_bool = is_rate(key) | ||
assert isinstance(is_rate_bool, bool) | ||
|
||
|
||
examples = [ | ||
("OPR", False), | ||
("WOPR:OP_4", True), | ||
("WGIR", True), | ||
("FOPT", False), | ||
("GGPT", False), | ||
("RWPT", False), | ||
("COPR", True), | ||
("LPR", False), | ||
("LWPR", False), | ||
("LCOPR", True), | ||
("RWGIR", True), | ||
("RTPR", True), | ||
("RXFR", True), | ||
("XXX", False), | ||
("YYYY", False), | ||
("ZZT", False), | ||
("SGPR", False), | ||
("AAPR", False), | ||
("JOPR", False), | ||
("ROPRT", True), | ||
("RNFT", False), | ||
("RFR", False), | ||
("RRFRT", True), | ||
("ROC", False), | ||
("BPR:123", False), | ||
("FWIR", True), | ||
] | ||
|
||
|
||
@given(st.sampled_from(examples)) | ||
def test_is_rate_determmines_rate_key(example): | ||
key, rate = example | ||
is_rate_bool = is_rate(key) | ||
assert is_rate_bool == rate |