From 53714fc5a9f20ca89bc0162b41cba63aba154868 Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Fri, 12 Jan 2018 18:26:26 +0000 Subject: [PATCH] Add a unit test for kayobe seed service deploy --- kayobe/cli/commands.py | 3 +- kayobe/tests/unit/cli/test_commands.py | 40 ++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/kayobe/cli/commands.py b/kayobe/cli/commands.py index a2f340dc2..0f9b7fbe5 100644 --- a/kayobe/cli/commands.py +++ b/kayobe/cli/commands.py @@ -461,7 +461,8 @@ class SeedServiceDeploy(KollaAnsibleMixin, KayobeAnsibleMixin, VaultMixin, playbooks = _build_playbook_list("kolla-ansible") self.run_kayobe_playbooks(parsed_args, playbooks, tags="config") - self.run_kayobe_playbook(parsed_args, "ansible/kolla-bifrost.yml") + playbooks = _build_playbook_list("kolla-bifrost") + self.run_kayobe_playbooks(parsed_args, playbooks) self.run_kolla_ansible_seed(parsed_args, "deploy-bifrost") playbooks = _build_playbook_list( "seed-introspection-rules", "dell-switch-bmp") diff --git a/kayobe/tests/unit/cli/test_commands.py b/kayobe/tests/unit/cli/test_commands.py index d89d8b9fe..bc528afa6 100644 --- a/kayobe/tests/unit/cli/test_commands.py +++ b/kayobe/tests/unit/cli/test_commands.py @@ -387,6 +387,46 @@ class TestCase(unittest.TestCase): ] self.assertEqual(expected_calls, mock_run.call_args_list) + @mock.patch.object(commands.KayobeAnsibleMixin, + "run_kayobe_playbooks") + @mock.patch.object(commands.KollaAnsibleMixin, + "run_kolla_ansible_seed") + def test_service_deploy(self, mock_kolla_run, mock_run): + command = commands.SeedServiceDeploy(TestApp(), []) + parser = command.get_parser("test") + parsed_args = parser.parse_args([]) + + result = command.run(parsed_args) + self.assertEqual(0, result) + + expected_calls = [ + mock.call( + mock.ANY, + ["ansible/kolla-ansible.yml"], + tags="config", + ), + mock.call( + mock.ANY, + ["ansible/kolla-bifrost.yml"], + ), + mock.call( + mock.ANY, + [ + "ansible/seed-introspection-rules.yml", + "ansible/dell-switch-bmp.yml", + ], + ), + ] + self.assertEqual(expected_calls, mock_run.call_args_list) + + expected_calls = [ + mock.call( + mock.ANY, + "deploy-bifrost", + ), + ] + self.assertEqual(expected_calls, mock_kolla_run.call_args_list) + @mock.patch.object(commands.KayobeAnsibleMixin, "run_kayobe_config_dump") @mock.patch.object(commands.KayobeAnsibleMixin,