def test_success(self):
        expected_xml = "<xml />"
        expected_retval = 0
        mock_runner = mock.MagicMock(spec_set=CommandRunner)
        mock_runner.run.return_value = (expected_xml, expected_retval)

        real_xml = lib.get_cluster_status_xml(mock_runner)

        mock_runner.run.assert_called_once_with(self.crm_mon_cmd())
        self.assertEqual(expected_xml, real_xml)
Exemple #2
0
    def test_success(self):
        expected_stdout = "<xml />"
        expected_stderr = ""
        expected_retval = 0
        mock_runner = mock.MagicMock(spec_set=CommandRunner)
        mock_runner.run.return_value = (expected_stdout, expected_stderr,
                                        expected_retval)

        real_xml = lib.get_cluster_status_xml(mock_runner)

        mock_runner.run.assert_called_once_with(self.crm_mon_cmd())
        self.assertEqual(expected_stdout, real_xml)
Exemple #3
0
    def test_error(self):
        expected_stdout = "some info"
        expected_stderr = "some error"
        expected_retval = 1
        mock_runner = mock.MagicMock(spec_set=CommandRunner)
        mock_runner.run.return_value = (expected_stdout, expected_stderr,
                                        expected_retval)

        assert_raise_library_error(
            lambda: lib.get_cluster_status_xml(mock_runner),
            (Severity.ERROR, report_codes.CRM_MON_ERROR, {
                "reason": expected_stderr + "\n" + expected_stdout,
            }))

        mock_runner.run.assert_called_once_with(self.crm_mon_cmd())
    def test_error(self):
        expected_error = "some error"
        expected_retval = 1
        mock_runner = mock.MagicMock(spec_set=CommandRunner)
        mock_runner.run.return_value = (expected_error, expected_retval)

        assert_raise_library_error(
            lambda: lib.get_cluster_status_xml(mock_runner),
            (
                Severity.ERROR,
                report_codes.CRM_MON_ERROR,
                {
                    "return_value": expected_retval,
                    "stdout": expected_error,
                }
            )
        )

        mock_runner.run.assert_called_once_with(self.crm_mon_cmd())