From 9dc475ec6b900280f45b919d39675f89eeea4869 Mon Sep 17 00:00:00 2001 From: Andrew Biryukov Date: Thu, 14 Mar 2024 16:52:19 +0300 Subject: [PATCH] add test for ansible playbook bin path --- src/cotea_internal_error_case.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/cotea_internal_error_case.py b/src/cotea_internal_error_case.py index e495dc4..fd55350 100644 --- a/src/cotea_internal_error_case.py +++ b/src/cotea_internal_error_case.py @@ -10,6 +10,25 @@ def tearDown(self) -> None: # to clear previous execution context remove_modules_from_imported(module_name_like="cotea") + def test_incorrect_playbook_bin_path(self): + from cotea.runner import runner + from cotea.arguments_maker import argument_maker + + pb_path = "cotea_run_files/ok.yaml" + inv_path = "cotea_run_files/inv" + ansible_pb_bin = "/path/to/.venv/bin/ansible-playbook" + + arg_maker = argument_maker() + arg_maker.add_arg("-i", inv_path) + + try: + runner(pb_path, arg_maker, show_progress_bar=True, ansible_pb_bin=ansible_pb_bin) + except Exception as e: + self.assertTrue(str(e) == f"Ansible playbook bin {ansible_pb_bin} not found", + msg="Unexpected exception message") + else: + self.assertFalse(True, msg="Ansible is supposed to fail due to incorrect ansible playbook bin path") + def test_incorrect_playbook_path_case(self): from cotea.runner import runner from cotea.arguments_maker import argument_maker