diff --git a/.gitignore b/.gitignore index 33103d9..9edda3c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ +.coverage +.env +.mypy_cache coverage.xml +htmlcov diff --git a/Dockerfile b/Dockerfile index a6c9e70..da6ffa2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.9-slim +FROM python:3.9 EXPOSE 4785 diff --git a/tests/start.py b/tests/start.py index 8eef22e..79ac0a8 100755 --- a/tests/start.py +++ b/tests/start.py @@ -14,17 +14,16 @@ BOT_URL = 'http://localhost:4785' MATRIX_URL, MATRIX_ID, MATRIX_PW = (environ[v] for v in ['MATRIX_URL', 'MATRIX_ID', 'MATRIX_PW']) -def check_json(url: str, key: str) -> bool: - """Ensure a service at a given url answers with valid json containing a certain key.""" - try: - data = httpx.get(url).json() - return key in data - except httpx.ConnectError: - return False - - def wait_available(url: str, key: str, timeout: int = 10) -> bool: """Wait until a service answer correctly or timeout.""" + def check_json(url: str, key: str) -> bool: + """Ensure a service at a given url answers with valid json containing a certain key.""" + try: + data = httpx.get(url).json() + return key in data + except httpx.ConnectError: + return False + start = time() while True: if check_json(url, key): @@ -38,7 +37,7 @@ def run_and_test(): if not wait_available(f'{MATRIX_URL}/_matrix/client/r0/login', 'flows'): return False - # Try to register an user for the bot. + # Try to register a user for the bot. with open('/srv/homeserver.yaml') as f: secret = yaml.safe_load(f.read()).get("registration_shared_secret", None) request_registration(MATRIX_ID, MATRIX_PW, MATRIX_URL, secret, admin=True)