1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-03-22 05:09:12 +00:00

Stop re-defining the argument spec in unit tests (#11235)

* Stop re-defining the argument spec in unit tests.

* Shut up linter.
This commit is contained in:
Felix Fontein 2025-12-01 06:59:23 +01:00 committed by GitHub
parent 6365b5a981
commit fb2f34ba85
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 35 additions and 274 deletions

View file

@ -7,12 +7,11 @@ from __future__ import annotations
import pytest
from unittest.mock import Mock, patch
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import (
ModuleTestCase,
set_module_args,
)
from ansible_collections.community.general.plugins.modules.archive import get_archive, common_path
from ansible_collections.community.general.plugins.modules.archive import get_archive, common_path, create_module
class TestArchive(ModuleTestCase):
@ -27,19 +26,7 @@ class TestArchive(ModuleTestCase):
def test_archive_removal_safety(self):
with set_module_args(dict(path=["/foo", "/bar", "/baz"], dest="/foo/destination.tgz", remove=True)):
module = AnsibleModule(
argument_spec=dict(
path=dict(type="list", elements="path", required=True),
format=dict(type="str", default="gz", choices=["bz2", "gz", "tar", "xz", "zip"]),
dest=dict(type="path"),
exclude_path=dict(type="list", elements="path", default=[]),
exclusion_patterns=dict(type="list", elements="path"),
force_archive=dict(type="bool", default=False),
remove=dict(type="bool", default=False),
),
add_file_common_args=True,
supports_check_mode=True,
)
module = create_module()
self.os_path_isdir.side_effect = [True, False, False, True]