From df6316508c1994b8f7d7ccf2db98837906521827 Mon Sep 17 00:00:00 2001 From: Prashant Tiwari Date: Fri, 10 May 2024 09:36:09 +0100 Subject: [PATCH] Test refactor. --- .../test_conda_store_scaling.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tests/tests_deployment/test_conda_store_scaling.py b/tests/tests_deployment/test_conda_store_scaling.py index 669f92dd4..e41ffbde2 100644 --- a/tests/tests_deployment/test_conda_store_scaling.py +++ b/tests/tests_deployment/test_conda_store_scaling.py @@ -39,10 +39,7 @@ def patched_secret_token(configuration): elevated_token = str(uuid.uuid4()) # Get secret - api_response = api_instance.read_namespaced_secret(name, namespace) - api_response_data = api_response.data - secret_data = api_response_data["config.json"] - secret_config = json.loads(base64.b64decode(secret_data)) + api_response, secret_config = get_conda_secret(api_instance, name, namespace) # Update secret permissions = { @@ -70,10 +67,7 @@ def patched_secret_token(configuration): yield elevated_token, _api_client # Get update secret - api_response = api_instance.read_namespaced_secret(name, namespace) - api_response_data = api_response.data - secret_data = api_response_data["config.json"] - secret_config = json.loads(base64.b64decode(secret_data)) + api_response, secret_config = get_conda_secret(api_instance, name, namespace) # Update secret secret_config["service-tokens"].pop(elevated_token) @@ -94,6 +88,14 @@ def patched_secret_token(configuration): api_instance.delete_namespaced_pod(server_pod.metadata.name, namespace) +def get_conda_secret(api_instance, name, namespace): + api_response = api_instance.read_namespaced_secret(name, namespace) + api_response_data = api_response.data + secret_data = api_response_data["config.json"] + secret_config = json.loads(base64.b64decode(secret_data)) + return api_response, secret_config + + @pytest.mark.filterwarnings("ignore::urllib3.exceptions.InsecureRequestWarning") @pytest.mark.filterwarnings("ignore::pytest.PytestUnraisableExceptionWarning") class TestCondaStoreWorkerHPA(TestCase):