def test_error(self): xml = "<xml/>" expected_stdout = "expected output" expected_stderr = "expected stderr" 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.replace_cib_configuration( mock_runner, XmlManipulation.from_str(xml).tree ) , ( Severity.ERROR, report_codes.CIB_PUSH_ERROR, { "reason": expected_stderr, "pushed_cib": expected_stdout, } ) ) mock_runner.run.assert_called_once_with( [ self.path("cibadmin"), "--replace", "--verbose", "--xml-pipe", "--scope", "configuration" ], stdin_string=xml )
def test_cib_upgraded(self): xml = "<xml/>" expected_stdout = "expected output" expected_stderr = "" expected_retval = 0 mock_runner = mock.MagicMock(spec_set=CommandRunner) mock_runner.run.return_value = (expected_stdout, expected_stderr, expected_retval) lib.replace_cib_configuration(mock_runner, XmlManipulation.from_str(xml).tree, True) mock_runner.run.assert_called_once_with( [self.path("cibadmin"), "--replace", "--verbose", "--xml-pipe"], stdin_string=xml)
def test_cib_upgraded(self): xml = "<xml/>" expected_output = "expected output" expected_retval = 0 mock_runner = mock.MagicMock(spec_set=CommandRunner) mock_runner.run.return_value = (expected_output, expected_retval) lib.replace_cib_configuration( mock_runner, XmlManipulation.from_str(xml).tree, True ) mock_runner.run.assert_called_once_with( [self.path("cibadmin"), "--replace", "--verbose", "--xml-pipe"], stdin_string=xml )
def test_success(self): xml = "<xml/>" expected_stdout = "expected output" expected_stderr = "" expected_retval = 0 mock_runner = get_runner(expected_stdout, expected_stderr, expected_retval) lib.replace_cib_configuration(mock_runner, XmlManipulation.from_str(xml).tree) mock_runner.run.assert_called_once_with([ self.path("cibadmin"), "--replace", "--verbose", "--xml-pipe", "--scope", "configuration" ], stdin_string=xml)