コード例 #1
0
ファイル: test_tape.py プロジェクト: haniffm/ESSArch_Core
    def test_is_tape_drive_online_non_zero_returncode(self, mock_popen):
        attrs = {'communicate.return_value': ('output', 'error'), 'returncode': 1}
        mock_popen.return_value.configure_mock(**attrs)

        with self.assertRaises(RobotException):
            is_tape_drive_online("device_to_verify")

        cmd = 'mt -f device_to_verify status'
        mock_popen.assert_called_once_with(cmd, shell=True, stderr=PIPE, stdout=PIPE)
コード例 #2
0
ファイル: test_tape.py プロジェクト: haniffm/ESSArch_Core
    def test_is_tape_drive_online_output_not_containing_ONLINE(self, mock_popen):
        attrs = {'communicate.return_value': ('the drive is offline', 'error'), 'returncode': 0}
        mock_popen.return_value.configure_mock(**attrs)

        self.assertEqual(is_tape_drive_online("device_to_verify"), False)

        cmd = 'mt -f device_to_verify status'
        mock_popen.assert_called_once_with(cmd, shell=True, stderr=PIPE, stdout=PIPE)
コード例 #3
0
    def test_is_tape_drive_online_output_contains_ONLINE(self, mock_popen):
        attrs = {'communicate.return_value': ('the drive is ONLINE now', 'error'), 'returncode': 0}
        mock_popen.return_value.configure_mock(**attrs)

        self.assertTrue(is_tape_drive_online("device_to_verify"))

        cmd = 'mt -f device_to_verify status'
        mock_popen.assert_called_once_with(cmd, shell=True, stderr=PIPE, stdout=PIPE, universal_newlines=True)
コード例 #4
0
    def run(self, drive=None):
        """
        Checks if the given tape drive is online

        Args:
            drive: Which drive to check

        Returns:
            True if the drive is online, false otherwise
        """

        return is_tape_drive_online(drive)