diff --git a/cloud.py b/cloud.py new file mode 100644 index 00000000..72d558fa --- /dev/null +++ b/cloud.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- + +# Copyright 2025 Cloudera, Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/pyproject.toml b/pyproject.toml index 426a8b37..4a7ba828 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ name = "cloud" dynamic = ["version"] description = "cloudera.cloud Ansible collection" readme = "README.md" -requires-python = ">=3.8" +requires-python = ">=3.9" # hatch-semver requires 3.9+ license = "Apache-2.0" keywords = [] authors = [ @@ -19,7 +19,6 @@ scheme = "semver" validate-bump = true [tool.hatch.envs.default] -python = "3.12" detached = true dependencies = [ "pre-commit", @@ -42,6 +41,46 @@ lint = [ "antsibull-docs lint-collection-docs --plugin-docs --validate-collection-refs=all --skip-rstcheck ." ] +[tool.hatch.envs.hatch-test] +matrix-name-format = "{variable}_{value}" +extra-dependencies = [ + "pytest", + "pytest-mock", + "molecule", + "molecule-plugins", + "molecule-plugins[ec2]", + # "ansible-core<2.17", # For RHEL 8 support + "cdpy @ git+https://github.com/cloudera-labs/cdpy@main#egg=cdpy", +] + +# Ansible 2.18 - Python >= 3.11 +[[tool.hatch.envs.hatch-test.matrix]] +python = ["3.13", "3.12", "3.11"] +ansible = ["2.18"] + +# Ansible 2.17 - Python >= 3.10 +[[tool.hatch.envs.hatch-test.matrix]] +python = ["3.13", "3.12", "3.11", "3.10"] +ansible = ["2.17"] + +# Ansible 2.16 - Python >= 3.10 +[[tool.hatch.envs.hatch-test.matrix]] +python = ["3.13", "3.12", "3.11", "3.10"] +ansible = ["2.16"] + +# Ansible 2.15 - Python <= 3.12 +[[tool.hatch.envs.hatch-test.matrix]] +python = ["3.12", "3.11", "3.10", "3.9"] +ansible = ["2.15"] + +[tool.hatch.envs.hatch-test.overrides] +matrix.ansible.dependencies = [ + { value = "ansible-core==2.18", if = ["2.18"] }, + { value = "ansible-core==2.17", if = ["2.17"] }, + { value = "ansible-core==2.16", if = ["2.16"] }, + { value = "ansible-core==2.15", if = ["2.15"] }, +] + [tool.hatch.envs.docs] python = "3.12" detached = true diff --git a/tests/unit/plugins/module_utils/cdp_client/test_create_encoded_authn_params_string.py b/tests/unit/plugins/module_utils/cdp_client/test_create_encoded_authn_params_string.py index 37d11c59..6fbedee4 100644 --- a/tests/unit/plugins/module_utils/cdp_client/test_create_encoded_authn_params_string.py +++ b/tests/unit/plugins/module_utils/cdp_client/test_create_encoded_authn_params_string.py @@ -229,11 +229,14 @@ def test_create_encoded_authn_params_string_base64_error(): auth_method = "ed25519v1" # Use unittest.mock directly with a more targeted approach - with unittest.mock.patch( - "ansible_collections.cloudera.cloud.plugins.module_utils.cdp_client.json.dumps", - ) as mock_dumps, unittest.mock.patch( - "ansible_collections.cloudera.cloud.plugins.module_utils.cdp_client.urlsafe_b64encode", - ) as mock_b64encode: + with ( + unittest.mock.patch( + "ansible_collections.cloudera.cloud.plugins.module_utils.cdp_client.json.dumps", + ) as mock_dumps, + unittest.mock.patch( + "ansible_collections.cloudera.cloud.plugins.module_utils.cdp_client.urlsafe_b64encode", + ) as mock_b64encode, + ): mock_dumps.return_value = ( '{"access_key_id": "test-key", "auth_method": "ed25519v1"}' )