def __push_cib_full(self, cib_to_push, wait=False): cmd_runner = self.cmd_runner() self.__do_push_cib( cmd_runner, lambda: replace_cib_configuration(cmd_runner, cib_to_push), wait )
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)
def test_error(self): xml = "<xml/>" expected_stdout = "expected output" expected_stderr = "expected stderr" expected_retval = 1 mock_runner = get_runner( 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_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_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 )
def push_cib_full(self, custom_cib=None, wait=False): if custom_cib is None and self.__loaded_cib_diff_source is None: raise AssertionError("CIB has not been loaded") if custom_cib is not None and self.__loaded_cib_diff_source is not None: raise AssertionError("CIB has been loaded, cannot push custom CIB") cmd_runner = self.cmd_runner() cib_to_push = ( self.__loaded_cib_to_modify if custom_cib is None else custom_cib ) self.__do_push_cib( cmd_runner, lambda: replace_cib_configuration(cmd_runner, cib_to_push), wait )
def __push_cib_full(self, cib_to_push, wait_timeout: int): self.__do_push_cib( lambda: replace_cib_configuration(self.cmd_runner(), cib_to_push), wait_timeout, )