From f8ad2ae922ab50fcd734711a82da294bc3d75b76 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 9 Dec 2023 11:24:11 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20[pre-commit.ci]=20Auto=20format?= =?UTF-8?q?=20from=20pre-commit.com=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../profiles/athena/test_athena_access_key.py | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/tests/profiles/athena/test_athena_access_key.py b/tests/profiles/athena/test_athena_access_key.py index c3b708174..eaaef2802 100644 --- a/tests/profiles/athena/test_athena_access_key.py +++ b/tests/profiles/athena/test_athena_access_key.py @@ -15,14 +15,17 @@ token="my_aws_assumed_token", ) + class MockAwsGenericHook: def get_connection() -> ReadOnlyCredentials: return mock_assumed_credentials + with patch( "airflow.providers.amazon.aws.hooks.base_aws.AwsGenericHook", return_value=MockAwsGenericHook, ): + @pytest.fixture() def mock_athena_assume_role_conn(): # type: ignore """ @@ -48,7 +51,6 @@ def mock_athena_assume_role_conn(): # type: ignore with patch("airflow.hooks.base.BaseHook.get_connection", return_value=conn): yield conn - @pytest.fixture() def mock_athena_conn(): # type: ignore """ @@ -74,7 +76,6 @@ def mock_athena_conn(): # type: ignore with patch("airflow.hooks.base.BaseHook.get_connection", return_value=conn): yield conn - def test_athena_connection_claiming() -> None: """ Tests that the Athena profile mapping claims the correct connection type. @@ -102,8 +103,6 @@ def test_athena_connection_claiming() -> None: ), } - - # if we're missing any of the values, it shouldn't claim for key in potential_values: values = potential_values.copy() @@ -123,7 +122,6 @@ def test_athena_connection_claiming() -> None: profile_mapping = AthenaAccessKeyProfileMapping(conn, {}) assert profile_mapping.can_claim_connection() - def test_athena_profile_mapping_selected( mock_athena_conn: Connection, ) -> None: @@ -131,13 +129,11 @@ def test_athena_profile_mapping_selected( Tests that the correct profile mapping is selected for Athena. """ - profile_mapping = get_automatic_profile_mapping( mock_athena_conn.conn_id, ) assert isinstance(profile_mapping, AthenaAccessKeyProfileMapping) - def test_athena_profile_args( mock_athena_conn: Connection, ) -> None: @@ -145,7 +141,6 @@ def test_athena_profile_args( Tests that the profile values get set correctly for Athena. """ - profile_mapping = get_automatic_profile_mapping( mock_athena_conn.conn_id, ) @@ -161,7 +156,6 @@ def test_athena_profile_args( "schema": mock_athena_conn.extra_dejson.get("schema"), } - def test_athena_profile_args_overrides( mock_athena_conn: Connection, ) -> None: @@ -169,10 +163,13 @@ def test_athena_profile_args_overrides( Tests that you can override the profile values for Athena. """ - profile_mapping = get_automatic_profile_mapping( mock_athena_conn.conn_id, - profile_args={"schema": "my_custom_schema", "database": "my_custom_db", "aws_session_token": "override_token"}, + profile_args={ + "schema": "my_custom_schema", + "database": "my_custom_db", + "aws_session_token": "override_token", + }, ) assert profile_mapping.profile_args == { @@ -192,7 +189,6 @@ def test_athena_profile_args_overrides( "schema": "my_custom_schema", } - def test_athena_profile_env_vars( mock_athena_conn: Connection, ) -> None: @@ -200,7 +196,6 @@ def test_athena_profile_env_vars( Tests that the environment variables get set correctly for Athena. """ - profile_mapping = get_automatic_profile_mapping( mock_athena_conn.conn_id, ) @@ -210,13 +205,11 @@ def test_athena_profile_env_vars( "COSMOS_CONN_AWS_AWS_SESSION_TOKEN": mock_athena_conn.extra_dejson.get("aws_session_token"), } - def test_athena_profile_assume_role(mock_athena_assume_role_conn: Connection) -> None: """ Tests that the profile values get set correctly for Athena. """ - profile_mapping = get_automatic_profile_mapping( mock_athena_assume_role_conn.conn_id, )