From 95b7ac360e44095a86887f54c9b9b06fc6a3ed17 Mon Sep 17 00:00:00 2001 From: James Harmison Date: Tue, 17 Oct 2023 20:05:25 -0400 Subject: [PATCH] tests: add a test of the opposite of expected behavior --- tests/unit/plugins/modules/test_start_compose.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/unit/plugins/modules/test_start_compose.py b/tests/unit/plugins/modules/test_start_compose.py index c7887e7c..d7617c1c 100644 --- a/tests/unit/plugins/modules/test_start_compose.py +++ b/tests/unit/plugins/modules/test_start_compose.py @@ -68,6 +68,22 @@ def test_start_compose_submitted_queue(): assert "Compose submitted to queue" in str(exit_json_obj) +def test_start_compose_submitted_duplicate_allowed(): + module = mock_module(args) + weldr = mock_weldr() + + # Have to change the version of the return status to match the "running" + # blueprints in the mock. + get_blueprint_info_mock = deepcopy(get_blueprint_info_mock_global) + get_blueprint_info_mock["blueprints"][0]["version"] = "0.0.5" + weldr.api.get_blueprints_info = Mock(return_value=get_blueprint_info_mock) + + with pytest.raises(AnsibleExitJson) as exit_json_obj: + start_compose(module, weldr=weldr) + # We expect this to work unless we set allow_duplicate to False + assert "Compose submitted to queue" in str(exit_json_obj) + + def test_start_compose_submitted_duplicate(): args["allow_duplicate"] = False module = mock_module(args)