示例#1
0
    def test_unmount_when_drive_locked_raise_exception(self):
        tape_drive = self.create_tape_drive()
        tape_drive.locked = True
        tape_drive.save(update_fields=['locked'])
        self.create_storage_medium(tape_drive)

        with self.assertRaises(TapeDriveLockedError):
            unmount_tape_from_drive(tape_drive.pk)
示例#2
0
    def test_unmount_when_unmount_tape_raise_exception(self,
                                                       mock_unmount_tape):
        mock_unmount_tape.side_effect = BaseException

        tape_drive = self.create_tape_drive()
        storage_medium = self.create_storage_medium(tape_drive)

        with self.assertRaises(BaseException):
            unmount_tape_from_drive(tape_drive.pk)

        # Refresh from DB
        storage_medium.refresh_from_db()
        storage_medium.tape_slot.refresh_from_db()
        tape_drive.refresh_from_db()

        mock_unmount_tape.assert_called_once_with("robot_device", 12, 2)
        self.assertEqual(tape_drive.locked, False)
        self.assertEqual(storage_medium.status, 100)
        self.assertEqual(tape_drive.locked, False)
        self.assertEqual(tape_drive.status, 100)
        self.assertEqual(storage_medium.tape_slot.status, 100)
示例#3
0
    def test_unmount_success(self, mock_unmount_tape):
        mock_unmount_tape.return_value = "dummy_output"

        tape_drive = self.create_tape_drive()
        storage_medium = self.create_storage_medium(tape_drive)

        before = timezone.now()
        res = unmount_tape_from_drive(tape_drive.pk)
        after = timezone.now()

        storage_medium.refresh_from_db()
        tape_drive.refresh_from_db()

        mock_unmount_tape.assert_called_once_with("robot_device", 12, 2)
        self.assertEqual(tape_drive.locked, False)
        self.assertEqual(storage_medium.tape_drive, None)
        self.assertTrue(before <= tape_drive.last_change <= after)
        self.assertEqual(res, "dummy_output")
示例#4
0
    def test_unmount_when_no_medium_exists_should_raise_exception(self):
        tape_drive = self.create_tape_drive()

        with self.assertRaisesRegexp(ValueError,
                                     "No tape in tape drive to unmount"):
            unmount_tape_from_drive(tape_drive.pk)
示例#5
0
 def run(self, drive=None):
     return unmount_tape_from_drive(drive)
示例#6
0
def UnmountTape(self, drive_id):
    return unmount_tape_from_drive(drive_id)
示例#7
0
 def run(self, drive_id):
     return unmount_tape_from_drive(drive_id)