mock.sentinel.instance_name

Here are the examples of the python api mock.sentinel.instance_name taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

11 Examples 7

Example 1

Project: compute-hyperv
Source File: test_migrationops.py
View license
    def test_revert_migration_files(self):
        instance_path = (
            self._migrationops._pathutils.get_instance_dir.return_value)
        get_revert_dir = (
            self._migrationops._pathutils.get_instance_migr_revert_dir)

        self._migrationops._revert_migration_files(
            instance_name=mock.sentinel.instance_name)

        self._migrationops._pathutils.get_instance_dir.assert_called_once_with(
            mock.sentinel.instance_name, create_dir=False, remove_dir=True)
        get_revert_dir.assert_called_with(mock.sentinel.instance_name)
        self._migrationops._pathutils.rename.assert_called_once_with(
            get_revert_dir.return_value, instance_path)

Example 2

Project: compute-hyperv
Source File: test_eventhandler.py
View license
    def test_handle_serial_console_instance_running(self):
        self._event_handler._handle_serial_console_workers(
            mock.sentinel.instance_name,
            constants.HYPERV_VM_STATE_ENABLED)
        serialops = self._event_handler._serial_console_ops
        serialops.start_console_handler.assert_called_once_with(
            mock.sentinel.instance_name)

Example 3

Project: compute-hyperv
Source File: test_eventhandler.py
View license
    def test_handle_serial_console_instance_stopped(self):
        self._event_handler._handle_serial_console_workers(
            mock.sentinel.instance_name,
            constants.HYPERV_VM_STATE_DISABLED)
        serialops = self._event_handler._serial_console_ops
        serialops.stop_console_handler.assert_called_once_with(
            mock.sentinel.instance_name)

Example 4

View license
    def test_stop_console_handler(self):
        mock_console_handler = self._setup_console_handler_mock()

        self._serialops.stop_console_handler(mock.sentinel.instance_name)

        mock_console_handler.stop.assert_called_once_with()
        handler = serialconsoleops._console_handlers.get(
                mock.sentinel.instance_name)
        self.assertIsNone(handler)

Example 5

View license
    def test_get_serial_console(self):
        mock_console_handler = self._setup_console_handler_mock()

        ret_val = self._serialops.get_serial_console(
            mock.sentinel.instance_name)

        self.assertEqual(mock_console_handler.get_serial_console(),
                         ret_val)

Example 6

Project: compute-hyperv
Source File: test_volumeops.py
View license
    def test_fix_instance_volume_disk_paths_empty_bdm(self):
        self._volumeops.fix_instance_volume_disk_paths(
            mock.sentinel.instance_name,
            block_device_info={})
        self.assertFalse(
            self._volumeops._vmutils.get_vm_physical_disk_mapping.called)

Example 7

Project: compute-hyperv
Source File: test_migrationops.py
View license
    def _check_migrate_disk_files(self, shared_storage=False):
        instance_path = 'fake/instance/path'
        dest_instance_path = 'remote/instance/path'
        self._migrationops._pathutils.get_instance_dir.side_effect = (
            instance_path, dest_instance_path)
        get_revert_dir = (
            self._migrationops._pathutils.get_instance_migr_revert_dir)
        check_shared_storage = (
            self._migrationops._pathutils.check_dirs_shared_storage)
        check_shared_storage.return_value = shared_storage
        self._migrationops._pathutils.exists.return_value = True

        fake_disk_files = [os.path.join(instance_path, disk_name)
                           for disk_name in
                           ['root.vhd', 'configdrive.vhd', 'configdrive.iso',
                            'eph0.vhd', 'eph1.vhdx']]

        expected_get_dir = [mock.call(mock.sentinel.instance_name),
                            mock.call(mock.sentinel.instance_name,
                                      mock.sentinel.dest_path)]
        expected_move_calls = [mock.call(instance_path,
                                         get_revert_dir.return_value)]

        self._migrationops._migrate_disk_files(
            instance_name=mock.sentinel.instance_name,
            disk_files=fake_disk_files,
            dest=mock.sentinel.dest_path)

        self._migrationops._pathutils.exists.assert_called_once_with(
            dest_instance_path)
        check_shared_storage.assert_called_once_with(
            instance_path, dest_instance_path)
        get_revert_dir.assert_called_with(mock.sentinel.instance_name,
                                          remove_dir=True, create_dir=True)
        if shared_storage:
            fake_dest_path = '%s_tmp' % instance_path
            expected_move_calls.append(mock.call(fake_dest_path,
                                                 instance_path))
            self._migrationops._pathutils.rmtree.assert_called_once_with(
                fake_dest_path)
        else:
            fake_dest_path = dest_instance_path

        self._migrationops._pathutils.makedirs.assert_called_once_with(
            fake_dest_path)
        check_remove_dir = self._migrationops._pathutils.check_remove_dir
        check_remove_dir.assert_called_once_with(fake_dest_path)

        self._migrationops._pathutils.get_instance_dir.assert_has_calls(
            expected_get_dir)
        self._migrationops._pathutils.copy.assert_has_calls(
            mock.call(fake_disk_file, fake_dest_path)
            for fake_disk_file in fake_disk_files)
        self.assertEqual(len(fake_disk_files),
                         self._migrationops._pathutils.copy.call_count)
        self._migrationops._pathutils.move_folder_files.assert_has_calls(
            expected_move_calls)

Example 8

Project: compute-hyperv
Source File: test_volumeops.py
View license
    def _test_get_disk_ctrl_and_slot(self, disk_bus=constants.CTRL_TYPE_IDE):
        ctrl, slot = self._base_vol_driver._get_disk_ctrl_and_slot(
            mock.sentinel.instance_name,
            disk_bus)

        vmutils = self._base_vol_driver._vmutils
        if disk_bus == constants.CTRL_TYPE_IDE:
            expected_ctrl = vmutils.get_vm_ide_controller.return_value
            expected_slot = 0

            vmutils.get_vm_ide_controller.assert_called_once_with(
                mock.sentinel.instance_name, 0)
        else:
            expected_ctrl = vmutils.get_vm_scsi_controller.return_value
            expected_slot = vmutils.get_free_controller_slot.return_value

            vmutils.get_vm_scsi_controller.assert_called_once_with(
                mock.sentinel.instance_name)
            vmutils.get_free_controller_slot(
                vmutils.get_vm_scsi_controller.return_value)

        self.assertEqual(expected_ctrl, ctrl)
        self.assertEqual(expected_slot, slot)

Example 9

View license
    def test_get_serial_console_exception(self):
        self.assertRaises(exception.ConsoleTypeUnavailable,
                          self._serialops.get_serial_console,
                          mock.sentinel.instance_name)

Example 10

View license
    def test_get_console_output_secure_vm(self):
        self._serialops._vmutils.is_secure_vm.return_value = True
        self.assertRaises(exception.ConsoleNotAvailable,
                          self._serialops.get_console_output,
                          mock.sentinel.instance_name)

Example 11

Project: compute-hyperv
Source File: test_volumeops.py
View license
    def test_get_disk_ctrl_and_slot_unknown(self):
        self.assertRaises(exception.Invalid,
                          self._base_vol_driver._get_disk_ctrl_and_slot,
                          mock.sentinel.instance_name,
                          'fake bus')