X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=test%2Fintegration%2Ftestlib%2Fcheck.py;h=1d1dfb0f8767e7bbfbe7790b26f81b469cf4bbc7;hb=a5c6c6ea1ab657d83a4d8b064ac9bfa9c16adf63;hp=77865b1a3332b7a6ed734ab789e409f2a8495db6;hpb=5a76af7839d3239a16a6a3f9dabe05768799de89;p=tinc diff --git a/test/integration/testlib/check.py b/test/integration/testlib/check.py index 77865b1a..1d1dfb0f 100755 --- a/test/integration/testlib/check.py +++ b/test/integration/testlib/check.py @@ -20,6 +20,12 @@ def true(value: T.Any) -> None: raise ValueError(f'expected "{value}" to be truthy', value) +def port(value: int) -> None: + """Check that value resembles a port.""" + if not isinstance(value, int) or value < 1 or value > 65535: + raise ValueError(f'expected "{value}" to be be a port') + + def equals(expected: Val, actual: Val) -> None: """Check that the two values are equal.""" if expected != actual: @@ -32,6 +38,12 @@ def has_prefix(text: T.AnyStr, prefix: T.AnyStr) -> None: raise ValueError(f"expected {text!r} to start with {prefix!r}") +def greater(value: Num, than: Num) -> None: + """Check that value is greater than the other value.""" + if value <= than: + raise ValueError(f"value {value} must be greater than {than}") + + def in_range(value: Num, gte: Num, lte: Num) -> None: """Check that value lies in the range [min, max].""" if not gte >= value >= lte: