From c839068abdad5f6aa06c0d6f7c4ed3e76b0672d6 Mon Sep 17 00:00:00 2001 From: Andrew Schoen Date: Tue, 9 Dec 2014 10:16:34 -0600 Subject: [PATCH] write a test for teuthology.run that makes sure that all fields needed in fake_ctx for the tasks to operate are present Signed-off-by: Andrew Schoen --- teuthology/test/test_run.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/teuthology/test/test_run.py b/teuthology/test/test_run.py index 460249585..e6b49ec91 100644 --- a/teuthology/test/test_run.py +++ b/teuthology/test/test_run.py @@ -162,6 +162,11 @@ class TestRun(object): "--suite-path", "some/suite/dir", "path/to/config.yml", ]) + m_get_user.return_value = "the_owner" + m_get_summary.return_value = dict(success=True, owner="the_owner", description="the_description") + m_validate_tasks.return_value = ['task3'] + m_get_initial_tasks.return_value = ['task1', 'task2'] + m_fetch_tasks_if_needed.return_value = "some/suite/dir" run.main(args) m_set_up_logging.assert_called_with(True, "some/archive/dir") m_setup_config.assert_called_with(["path/to/config.yml"]) @@ -177,5 +182,14 @@ class TestRun(object): m_get_summary.assert_called_with("the_owner", "the_description") m_get_initial_tasks.assert_called_with(True, config, "machine_type") m_fetch_tasks_if_needed.assert_called_with(config) - assert m_run_tasks.called assert m_report_outcome.called + args, kwargs = m_run_tasks.call_args + fake_ctx = kwargs["ctx"]._conf + # fields that must be in ctx for the tasks to behave + expected_ctx = ["verbose", "archive", "description", "owner", "lock", "machine_type", "os_type", "os_version", + "block", "name", "suite_path", "config", "summary"] + for key in expected_ctx: + assert key in fake_ctx + assert isinstance(fake_ctx["config"], dict) + assert isinstance(fake_ctx["summary"], dict) + assert "tasks" in fake_ctx["config"] -- 2.47.3