Skip to content

Commit

Permalink
Reuse pytests parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Taragolis committed Nov 4, 2022
1 parent 756cff6 commit d9379e8
Showing 1 changed file with 20 additions and 36 deletions.
56 changes: 20 additions & 36 deletions tests/providers/amazon/aws/secrets/test_systems_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,24 @@
from airflow.providers.amazon.aws.secrets.systems_manager import SystemsManagerParameterStoreBackend
from tests.test_utils.config import conf_vars

URI_CONNECTION = pytest.param(
"postgres://my-login:my-pass@my-host:5432/my-schema?param1=val1&param2=val2", id="uri-connection"
)
JSON_CONNECTION = pytest.param(
json.dumps(
{
"conn_type": "postgres",
"login": "my-login",
"password": "my-pass",
"host": "my-host",
"port": 5432,
"schema": "my-schema",
"extra": {"param1": "val1", "param2": "val2"},
}
),
id="json-connection",
)


class TestSsmSecrets:
@mock.patch(
Expand All @@ -38,24 +56,7 @@ def test_aws_ssm_get_connection(self, mock_get_value):
assert conn.host == "host"

@mock_ssm
@pytest.mark.parametrize(
"ssm_value",
[
"postgres://my-login:my-pass@my-host:5432/my-schema?param1=val1&param2=val2",
json.dumps(
{
"conn_type": "postgres",
"login": "my-login",
"password": "my-pass",
"host": "my-host",
"port": 5432,
"schema": "my-schema",
"extra": {"param1": "val1", "param2": "val2"},
}
),
],
ids=["uri-conn", "json-conn"],
)
@pytest.mark.parametrize("ssm_value", [JSON_CONNECTION, URI_CONNECTION])
def test_get_conn_value(self, ssm_value):
param = {
"Name": "/airflow/connections/test_postgres",
Expand All @@ -80,24 +81,7 @@ def test_get_conn_value(self, ssm_value):
assert test_conn.extra_dejson == {"param1": "val1", "param2": "val2"}

@mock_ssm
@pytest.mark.parametrize(
"ssm_value",
[
"postgres://my-login:my-pass@my-host:5432/my-schema?param1=val1&param2=val2",
json.dumps(
{
"conn_type": "postgres",
"login": "my-login",
"password": "my-pass",
"host": "my-host",
"port": 5432,
"schema": "my-schema",
"extra": {"param1": "val1", "param2": "val2"},
}
),
],
ids=["uri-conn", "json-conn"],
)
@pytest.mark.parametrize("ssm_value", [JSON_CONNECTION, URI_CONNECTION])
def test_deprecated_get_conn_uri(self, ssm_value):
param = {
"Name": "/airflow/connections/test_postgres",
Expand Down

0 comments on commit d9379e8

Please sign in to comment.