projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add tests for sign/verify commands
[tinc]
/
test
/
integration
/
testlib
/
check.py
diff --git
a/test/integration/testlib/check.py
b/test/integration/testlib/check.py
index
77865b1
..
524ca62
100755
(executable)
--- a/
test/integration/testlib/check.py
+++ b/
test/integration/testlib/check.py
@@
-1,6
+1,8
@@
"""Simple assertions which print the expected and received values on failure."""
"""Simple assertions which print the expected and received values on failure."""
+import os.path
import typing as T
import typing as T
+from pathlib import Path
from .log import log
from .log import log
@@
-20,6
+22,12
@@
def true(value: T.Any) -> None:
raise ValueError(f'expected "{value}" to be truthy', value)
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:
def equals(expected: Val, actual: Val) -> None:
"""Check that the two values are equal."""
if expected != actual:
@@
-32,6
+40,12
@@
def has_prefix(text: T.AnyStr, prefix: T.AnyStr) -> None:
raise ValueError(f"expected {text!r} to start with {prefix!r}")
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:
def in_range(value: Num, gte: Num, lte: Num) -> None:
"""Check that value lies in the range [min, max]."""
if not gte >= value >= lte:
@@
-74,3
+88,9
@@
def files_eq(path0: str, path1: str) -> None:
if content0 != content1:
raise ValueError(f"expected files {path0} and {path1} to match")
if content0 != content1:
raise ValueError(f"expected files {path0} and {path1} to match")
+
+
+def file_exists(path: T.Union[str, Path]) -> None:
+ """Check that file or directory exists."""
+ if not os.path.exists(path):
+ raise ValueError("expected path '{path}' to exist")