def test_standard_not_specified(self, mock_list_agents, mock_list_standards): agents_ocf = [ "Delay", "Dummy", "Stateful", ] agents_service = [ "corosync", "pacemaker", "pcsd", ] mock_list_standards.return_value = ["ocf:test", "service"] mock_list_agents.side_effect = [agents_ocf, agents_service] self.assertEqual( lib.list_agents_for_standard_and_provider(self.lib_env), sorted(agents_ocf + agents_service, key=lambda x: x.lower())) mock_list_standards.assert_called_once_with("mock_runner") self.assertEqual(2, len(mock_list_agents.mock_calls)) mock_list_agents.assert_has_calls([ mock.call("mock_runner", "ocf:test"), mock.call("mock_runner", "service"), ])
def test_standard_not_specified( self, mock_list_agents, mock_list_standards ): agents_ocf = [ "Delay", "Dummy", "Stateful", ] agents_service = [ "corosync", "pacemaker", "pcsd", ] mock_list_standards.return_value = ["ocf:test", "service"] mock_list_agents.side_effect = [agents_ocf, agents_service] self.assertEqual( lib.list_agents_for_standard_and_provider(self.lib_env), sorted(agents_ocf + agents_service, key=lambda x: x.lower()) ) mock_list_standards.assert_called_once_with("mock_runner") self.assertEqual(2, len(mock_list_agents.mock_calls)) mock_list_agents.assert_has_calls([ mock.call("mock_runner", "ocf:test"), mock.call("mock_runner", "service"), ])
def test_standard_provider_not_specified(self): agents_pacemaker = ["Delay", "Dummy", "Stateful"] agents_heartbeat = ["Delay"] agents_service = ["corosync", "pacemaker", "pcsd"] self.config.runner.pcmk.list_agents_standards( "\n".join(["service", "stonith", "ocf"]) ) self.config.runner.pcmk.list_agents_ocf_providers( "\n".join(["heartbeat", "pacemaker"]) ) self.config.runner.pcmk.list_agents_for_standard_and_provider( "ocf:heartbeat", "\n".join(agents_heartbeat), name="runner.pcmk.list_agents_ocf_providers.heartbeat", ) self.config.runner.pcmk.list_agents_for_standard_and_provider( "ocf:pacemaker", "\n".join(agents_pacemaker), name="runner.pcmk.list_agents_ocf_providers.pacemaker", ) self.config.runner.pcmk.list_agents_for_standard_and_provider( "service", "\n".join(agents_service), name="runner.pcmk.list_agents_ocf_providers.service", ) self.assertEqual( lib.list_agents_for_standard_and_provider( self.env_assist.get_env() ), sorted( agents_pacemaker + agents_heartbeat + agents_service, key=str.lower, ), )
def _assert_standard_provider_specified(self, standard): agents = ["Delay", "Stateful", "Delay", "Dummy"] self.config.runner.pcmk.list_agents_for_standard_and_provider( "ocf:pacemaker", "\n".join(agents)) self.assertEqual( lib.list_agents_for_standard_and_provider( self.env_assist.get_env(), standard), sorted(set(agents)), )
def test_standard_specified(self, mock_list_agents, mock_list_standards): agents = [ "Delay", "Dummy", "Stateful", ] mock_list_agents.return_value = agents self.assertEqual( lib.list_agents_for_standard_and_provider(self.lib_env, "ocf:test"), agents) mock_list_agents.assert_called_once_with("mock_runner", "ocf:test") mock_list_standards.assert_not_called()
def test_standard_specified(self, mock_list_agents, mock_list_standards): agents = [ "Delay", "Dummy", "Stateful", ] mock_list_agents.return_value = agents self.assertEqual( lib.list_agents_for_standard_and_provider(self.lib_env, "ocf:test"), agents ) mock_list_agents.assert_called_once_with("mock_runner", "ocf:test") mock_list_standards.assert_not_called()