From 74cd0e6721aa597defd0614064a39ac7fc314ba5 Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Wed, 2 Oct 2024 10:44:59 -0600 Subject: [PATCH] test_run: Add test_main_interactive Signed-off-by: Zack Cerza --- teuthology/test/test_run.py | 42 +++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/teuthology/test/test_run.py b/teuthology/test/test_run.py index c2bcff4ab..fbb74403a 100644 --- a/teuthology/test/test_run.py +++ b/teuthology/test/test_run.py @@ -216,6 +216,48 @@ def test_main(self, m_report_outcome, m_run_tasks, m_fetch_tasks_if_needed, m_ge assert fake_ctx["config"]["os_type"] == "os_type" assert fake_ctx["config"]["os_version"] == "os_version" + @patch("teuthology.run.set_up_logging") + @patch("teuthology.run.setup_config") + @patch("teuthology.run.get_user") + @patch("teuthology.run.write_initial_metadata") + @patch("teuthology.report.try_push_job_info") + @patch("teuthology.run.get_machine_type") + @patch("teuthology.run.get_summary") + @patch("yaml.safe_dump") + @patch("teuthology.run.validate_tasks") + @patch("teuthology.run.get_initial_tasks") + @patch("teuthology.run.fetch_tasks_if_needed") + @patch("teuthology.run.run_tasks") + @patch("teuthology.run.report_outcome") + def test_main_interactive( + self, + m_report_outcome, + m_run_tasks, + m_fetch_tasks_if_needed, + m_get_initial_tasks, + m_validate_tasks, + m_safe_dump, + m_get_summary, + m_get_machine_type, + m_try_push_job_info, + m_write_initial_metadata, + m_get_user, + m_setup_config, + m_set_up_logging, + ): + config = {"job_id": 1} + m_setup_config.return_value = config + m_get_machine_type.return_value = "machine_type" + doc = scripts_run.__doc__ + args = docopt.docopt(doc, [ + "--interactive-on-error", + "path/to/config.yml", + ]) + run.main(args) + args, kwargs = m_run_tasks.call_args + fake_ctx = kwargs["ctx"]._conf + assert fake_ctx['interactive_on_error'] is True + def test_get_teuthology_command(self): doc = scripts_run.__doc__ args = docopt.docopt(doc, [