Files
community.general/tests/unit/plugins/modules/test_composer.py
Alexei Znamensky a4bba99203 composer - make create-project idempotent, add force parameter (#11689)
* composer - make create-project idempotent, add force parameter

Adds a check for an existing composer.json in working_dir before running
create-project, so the task is skipped rather than failing on second run.
A new force parameter allows bypassing this check when needed.

Fixes #725.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* changelog fragment: rename to PR number, add PR URL

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 08:17:23 +13:00

26 lines
769 B
Python

# Author: Alexei Znamensky (russoz@gmail.com)
#
# Copyright (c) Alexei Znamensky (russoz@gmail.com)
#
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
from __future__ import annotations
from ansible_collections.community.general.plugins.modules import composer
from .uthelper import RunCommandMock, TestCaseMock, UTHelper
class OsPathExistsMock(TestCaseMock):
name = "os_path_exists"
def setup(self, mocker):
mocker.patch("os.path.exists", return_value=self.mock_specs.get("return_value", False))
def check(self, test_case, results):
pass
UTHelper.from_module(composer, __name__, mocks=[RunCommandMock, OsPathExistsMock])