예제 #1
0
파일: test_utils.py 프로젝트: blin/zabby
    def test_does_not_raise_exception_if_poll_eventually_succeed(self):
        self.process.poll.side_effect = [None, 0]

        wait_step = 0.1
        sh(COMMAND, timeout=10.0, wait_step=wait_step)()

        self.mock_time.sleep.assert_called_with(wait_step)
예제 #2
0
파일: test_utils.py 프로젝트: Bregor/zabby
    def test_does_not_raise_exception_if_poll_eventually_succeed(self):
        self.process.poll.side_effect = [None, 0]

        wait_step = 0.1
        sh(COMMAND, timeout=10.0, wait_step=wait_step)()

        self.mock_time.sleep.assert_called_with(wait_step)
예제 #3
0
파일: test_utils.py 프로젝트: blin/zabby
    def test_command_errors_are_logged(self, mock_logging):
        mock_logger = Mock()
        mock_logging.getLogger.return_value = mock_logger
        self.process.communicate.return_value = (STDOUT, STDERR)

        sh(COMMAND)()
        mock_logger.warn.assert_called_once_with(ANY)
예제 #4
0
파일: test_utils.py 프로젝트: Bregor/zabby
    def test_command_errors_are_logged(self, mock_logging):
        mock_logger = Mock()
        mock_logging.getLogger.return_value = mock_logger
        self.process.communicate.return_value = ('', STDERR)

        sh(COMMAND)()
        mock_logger.warn.assert_called_once_with(ANY)
예제 #5
0
파일: test_utils.py 프로젝트: blin/zabby
 def test_function_runs_command_when_called(self):
     sh(COMMAND)()
     command = self.mock_popen.call_args[0][0]
     assert_equal(command, COMMAND)
     self.process.communicate.assert_called_once_with()
예제 #6
0
파일: test_utils.py 프로젝트: blin/zabby
 def test_returns_a_function(self):
     f = sh(COMMAND)
     assert_is_instance(f, FunctionType)
예제 #7
0
파일: test_utils.py 프로젝트: blin/zabby
    def test_raises_exception_if_command_does_not_produce_output(self):
        self.process.communicate.return_value = ('', '')

        f = sh(COMMAND)
        assert_raises(OperatingSystemError, f)
예제 #8
0
파일: test_utils.py 프로젝트: blin/zabby
 def test_communicate_with_completed_process(self):
     sh(COMMAND)()
     self.process.communicate.assert_called_once_with()
예제 #9
0
파일: test_utils.py 프로젝트: blin/zabby
    def test_raises_exception_if_poll_never_succeed(self):
        self.process.poll.return_value = None

        command = sh(COMMAND, timeout=10.0)
        assert_raises(OperatingSystemError, command)
예제 #10
0
파일: test_utils.py 프로젝트: blin/zabby
 def test_calling_command_that_accepts_arguments_without_them(self):
     f = sh(COMMAND_WITH_ARGUMENTS)
     assert_raises(WrongArgumentError, f)
예제 #11
0
파일: test_utils.py 프로젝트: blin/zabby
 def test_function_accepts_arguments(self):
     sh(COMMAND)(ARGUMENT)
예제 #12
0
파일: test_utils.py 프로젝트: Bregor/zabby
 def test_function_accepts_arguments(self):
     sh(COMMAND)(ARGUMENT)
예제 #13
0
파일: test_utils.py 프로젝트: Bregor/zabby
 def test_command_output_is_returned(self):
     result = sh(COMMAND)()
     assert_true(not result.endswith('\n'))
     assert_in(result, STDOUT)
예제 #14
0
파일: test_utils.py 프로젝트: Bregor/zabby
 def test_function_runs_command_when_called(self):
     sh(COMMAND)()
     command = self.mock_popen.call_args[0][0]
     assert_equal(command, COMMAND)
     self.process.communicate.assert_called_once_with()
예제 #15
0
파일: test_utils.py 프로젝트: Bregor/zabby
 def test_returns_a_function(self):
     f = sh(COMMAND)
     assert_is_instance(f, FunctionType)
예제 #16
0
파일: test_utils.py 프로젝트: blin/zabby
 def test_communicate_with_timed_out_process(self):
     self.process.poll.return_value = None
     command = sh(COMMAND, timeout=10.0)
     assert_raises(OperatingSystemError, command)
     self.process.communicate.assert_called_once_with()
예제 #17
0
파일: test_utils.py 프로젝트: blin/zabby
 def test_command_output_is_returned(self):
     result = sh(COMMAND)()
     assert_true(not result.endswith('\n'))
     assert_in(result, STDOUT)
예제 #18
0
파일: test_utils.py 프로젝트: Bregor/zabby
 def test_function_inserts_arguments_into_command(self):
     sh(COMMAND_WITH_ARGUMENTS)(ARGUMENT)
     command = self.mock_popen.call_args[0][0]
     assert_in(ARGUMENT, command)
예제 #19
0
파일: test_utils.py 프로젝트: Bregor/zabby
 def test_calling_command_that_accepts_arguments_without_them(self):
     f = sh(COMMAND_WITH_ARGUMENTS)
     assert_raises(WrongArgumentError, f)
예제 #20
0
파일: test_utils.py 프로젝트: blin/zabby
 def test_function_inserts_arguments_into_command(self):
     sh(COMMAND_WITH_ARGUMENTS)(ARGUMENT)
     command = self.mock_popen.call_args[0][0]
     assert_in(ARGUMENT, command)
예제 #21
0
파일: test_utils.py 프로젝트: blin/zabby
    def test_raises_exception_if_command_does_not_produce_output(self):
        self.process.communicate.return_value = ('', '')

        f = sh(COMMAND)
        assert_raises(OperatingSystemError, f)
예제 #22
0
파일: test_utils.py 프로젝트: blin/zabby
    def test_calling_command_without_timeout_does_not_poll(self):
        sh(COMMAND, timeout=None)()

        assert_false(self.process.poll.called)
예제 #23
0
파일: test_utils.py 프로젝트: blin/zabby
 def test_communicate_with_completed_process(self):
     sh(COMMAND)()
     self.process.communicate.assert_called_once_with()
예제 #24
0
파일: test_utils.py 프로젝트: Bregor/zabby
    def test_calling_command_without_timeout_does_not_poll(self):
        sh(COMMAND, timeout=None)()

        assert_false(self.process.poll.called)
예제 #25
0
파일: test_utils.py 프로젝트: blin/zabby
    def test_raises_exception_if_command_produces_errors(self):
        self.process.communicate.return_value = (STDOUT, STDERR)

        f = sh(COMMAND, raise_on_nonempty_err=True)
        assert_raises(OperatingSystemError, f)
예제 #26
0
파일: test_utils.py 프로젝트: blin/zabby
    def test_raises_exception_if_command_produces_errors(self):
        self.process.communicate.return_value = (STDOUT, STDERR)

        f = sh(COMMAND, raise_on_nonempty_err=True)
        assert_raises(OperatingSystemError, f)
예제 #27
0
파일: test_utils.py 프로젝트: Bregor/zabby
    def test_raises_exception_if_poll_never_succeed(self):
        self.process.poll.return_value = None

        command = sh(COMMAND, timeout=10.0)
        assert_raises(OperatingSystemError, command)
예제 #28
0
파일: test_utils.py 프로젝트: blin/zabby
 def test_communicate_with_timed_out_process(self):
     self.process.poll.return_value = None
     command = sh(COMMAND, timeout=10.0)
     assert_raises(OperatingSystemError, command)
     self.process.communicate.assert_called_once_with()
예제 #29
0
 def test_result_is_equal_to_coreutils_md5sum(self):
     coreutils_md5sum = sh('md5sum {0}')(self.FILE_PATH).split()[0]
     zabby_md5sum = file.md5sum(self.FILE_PATH)
     assert_equal(coreutils_md5sum, zabby_md5sum)