From b4c874e244ba4d987b89fe921bd29e7ac131a7fe Mon Sep 17 00:00:00 2001 From: RhodeCode Admin Date: Thu, 20 Jul 2023 10:33:37 +0200 Subject: [PATCH] cleanups: typing + whitespaces --- rhodecode/api/tests/utils.py | 6 +++++- rhodecode/lib/str_utils.py | 2 +- setup.py | 1 - 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/rhodecode/api/tests/utils.py b/rhodecode/api/tests/utils.py index d5b21c5d..85537bab 100644 --- a/rhodecode/api/tests/utils.py +++ b/rhodecode/api/tests/utils.py @@ -83,10 +83,14 @@ def build_data(apikey, method, **kw): }) -def api_call(app, params, status=None): +def api_call(app, params, status=None, assert_no_error=False): response = app.post( API_URL, content_type='application/json', params=params, status=status, headers=[('Content-Type', 'application/json')]) + if assert_no_error: + err_resp = response.json.get('error') + if err_resp: + raise AssertionError(f'ERROR in response: {err_resp}') return response diff --git a/rhodecode/lib/str_utils.py b/rhodecode/lib/str_utils.py index 16719e56..a20e427e 100644 --- a/rhodecode/lib/str_utils.py +++ b/rhodecode/lib/str_utils.py @@ -62,7 +62,7 @@ def safe_float(val, default=None) -> float: return val -def base64_to_str(text) -> str: +def base64_to_str(text: str | bytes) -> str: return safe_str(base64.encodebytes(safe_bytes(text))).strip() diff --git a/setup.py b/setup.py index e507cd70..3fbd3acf 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify