From 365105fe90c552e795a9f790b320409a60e4fbef Mon Sep 17 00:00:00 2001 From: Torsten Kilias Date: Tue, 28 Nov 2023 15:29:03 +0100 Subject: [PATCH] Fix skip checker in ci_tests --- tests/ci_tests/test_deploying_autopilot.py | 6 ++---- tests/ci_tests/test_polling_autopilot.py | 6 ++---- tests/ci_tests/test_predicting_autopilot.py | 9 +++------ tests/ci_tests/test_training_autopilot.py | 10 +++------- tests/ci_tests/utils/checkers.py | 6 ++++++ 5 files changed, 16 insertions(+), 21 deletions(-) diff --git a/tests/ci_tests/test_deploying_autopilot.py b/tests/ci_tests/test_deploying_autopilot.py index fdf9aa0..6067da8 100644 --- a/tests/ci_tests/test_deploying_autopilot.py +++ b/tests/ci_tests/test_deploying_autopilot.py @@ -1,13 +1,12 @@ import time from datetime import datetime -import pytest - from tests.ci_tests.fixtures.prepare_environment_fixture import CITestEnvironment from tests.ci_tests.utils import parameters from tests.ci_tests.utils.autopilot_deployment import AutopilotTestDeployment from tests.ci_tests.utils.autopilot_polling import AutopilotTestPolling from tests.ci_tests.utils.autopilot_training import AutopilotTestTraining +from tests.ci_tests.utils.checkers import skip_if_aws_credentials_not_set from tests.ci_tests.utils.cleanup import cleanup from tests.ci_tests.utils.parameters import cls_model_setup_params from tests.ci_tests.utils.queries import DatabaseQueries @@ -53,8 +52,7 @@ def _deploy_endpoint(job_name, endpoint_name, model_setup_params, ci_test_env: C assert endpoint_name in list(map(lambda x: x[0], all_scripts)) -@pytest.mark.skipif("is_aws_credentials_not_set() == True", - reason="AWS credentials are not set") +@skip_if_aws_credentials_not_set def test_deploy_autopilot_endpoint(setup_ci_test_environment): curr_datetime = datetime.now().strftime("%y%m%d%H%M%S") model_name = ''.join((cls_model_setup_params.model_type, curr_datetime)) diff --git a/tests/ci_tests/test_polling_autopilot.py b/tests/ci_tests/test_polling_autopilot.py index ccac8e8..834e97f 100644 --- a/tests/ci_tests/test_polling_autopilot.py +++ b/tests/ci_tests/test_polling_autopilot.py @@ -1,14 +1,12 @@ from datetime import datetime -import pytest - from tests.ci_tests.utils.autopilot_polling import AutopilotTestPolling from tests.ci_tests.utils.autopilot_training import AutopilotTestTraining +from tests.ci_tests.utils.checkers import skip_if_aws_credentials_not_set from tests.ci_tests.utils.parameters import cls_model_setup_params -@pytest.mark.skipif("is_aws_credentials_not_set() == True", - reason="AWS credentials are not set") +@skip_if_aws_credentials_not_set def test_poll_autopilot_job(setup_ci_test_environment): curr_datetime = datetime.now().strftime("%y%m%d%H%M%S") model_name = ''.join((cls_model_setup_params.model_type, curr_datetime)) diff --git a/tests/ci_tests/test_predicting_autopilot.py b/tests/ci_tests/test_predicting_autopilot.py index 7093c80..97c462f 100644 --- a/tests/ci_tests/test_predicting_autopilot.py +++ b/tests/ci_tests/test_predicting_autopilot.py @@ -1,14 +1,13 @@ import time from datetime import datetime -import pytest - from tests.ci_tests.fixtures.prepare_environment_fixture import CITestEnvironment from tests.ci_tests.utils import parameters from tests.ci_tests.utils.autopilot_deployment import AutopilotTestDeployment from tests.ci_tests.utils.autopilot_polling import AutopilotTestPolling from tests.ci_tests.utils.autopilot_prediction import AutopilotTestPrediction from tests.ci_tests.utils.autopilot_training import AutopilotTestTraining +from tests.ci_tests.utils.checkers import skip_if_aws_credentials_not_set from tests.ci_tests.utils.cleanup import cleanup from tests.ci_tests.utils.parameters import cls_model_setup_params, \ reg_model_setup_params @@ -54,8 +53,7 @@ def _make_prediction(job_name, endpoint_name, model_setup_params, ci_test_env: C assert predictions -@pytest.mark.skipif("is_aws_credentials_not_set() == True", - reason="AWS credentials are not set") +@skip_if_aws_credentials_not_set def test_predict_autopilot_regression_job(setup_ci_test_environment): curr_datetime = datetime.now().strftime("%y%m%d%H%M%S") model_name = ''.join((reg_model_setup_params.model_type, curr_datetime)) @@ -74,8 +72,7 @@ def test_predict_autopilot_regression_job(setup_ci_test_environment): db_conn=setup_ci_test_environment) -@pytest.mark.skipif("is_aws_credentials_not_set() == True", - reason="AWS credentials are not set") +@skip_if_aws_credentials_not_set def test_predict_autopilot_classification_job(setup_ci_test_environment): curr_datetime = datetime.now().strftime("%y%m%d%H%M%S") model_name = ''.join((cls_model_setup_params.model_type, curr_datetime)) diff --git a/tests/ci_tests/test_training_autopilot.py b/tests/ci_tests/test_training_autopilot.py index 324f546..6836772 100644 --- a/tests/ci_tests/test_training_autopilot.py +++ b/tests/ci_tests/test_training_autopilot.py @@ -1,17 +1,14 @@ from datetime import datetime -import pytest - from tests.ci_tests.fixtures.prepare_environment_fixture import CITestEnvironment from tests.ci_tests.utils.autopilot_training import AutopilotTestTraining -from tests.ci_tests.utils.checkers import is_aws_credentials_not_set +from tests.ci_tests.utils.checkers import skip_if_aws_credentials_not_set from tests.ci_tests.utils.parameters import reg_model_setup_params, \ cls_model_setup_params from tests.ci_tests.utils.queries import DatabaseQueries -@pytest.mark.skipif(is_aws_credentials_not_set() == True, - reason="AWS credentials are not set") +@skip_if_aws_credentials_not_set def test_train_autopilot_regression_job(setup_ci_test_environment): curr_datetime = datetime.now().strftime("%y%m%d%H%M%S") model_name = ''.join((reg_model_setup_params.model_type, curr_datetime)) @@ -25,8 +22,7 @@ def test_train_autopilot_regression_job(setup_ci_test_environment): job_name, reg_model_setup_params, setup_ci_test_environment) -@pytest.mark.skipif(is_aws_credentials_not_set() == True, - reason="AWS credentials are not set") +@skip_if_aws_credentials_not_set def test_train_autopilot_classification_job(setup_ci_test_environment): curr_datetime = datetime.now().strftime("%y%m%d%H%M%S") model_name = ''.join((cls_model_setup_params.model_type, curr_datetime)) diff --git a/tests/ci_tests/utils/checkers.py b/tests/ci_tests/utils/checkers.py index 2b66816..0877c03 100644 --- a/tests/ci_tests/utils/checkers.py +++ b/tests/ci_tests/utils/checkers.py @@ -1,5 +1,7 @@ import os +import pytest + def is_aws_credentials_not_set(): return not ( @@ -7,3 +9,7 @@ def is_aws_credentials_not_set(): "AWS_SECRET_ACCESS_KEY" in os.environ and "AWS_DEFAULT_REGION" in os.environ ) + + +skip_if_aws_credentials_not_set = pytest.mark.skipif(is_aws_credentials_not_set() == True, + reason="AWS credentials are not set")