'Test create volume from snapshot positive.'

@mock.patch.object(qnap.QnapISCSIDriver, '_get_volume_metadata')
@mock.patch.object(qnap.QnapISCSIDriver, '_extend_lun')
@mock.patch.object(qnap.QnapISCSIDriver, '_gen_random_name')
@mock.patch('cinder.volume.drivers.qnap.QnapAPIExecutor')
def test_create_volume_from_snapshot_positive_volsize_more_snapshotvolsize(self, mock_api_executor, mock_gen_random_name, mock_extend_lun, mock_get_volume_metadata):

    fake_volume = VolumeClass('fakeDisplayName', 'fakeId', 100, 'fakeLunName')
    fake_snapshot = SnapshotClass(fake_volume, 90)
    mock_api_executor.return_value.get_basic_info.return_value = ('ES1640dc    ', 'ES1640dc    ', '1.1.3')
    mock_gen_random_name.return_value = 'fakeLun'
    mock_api_executor.return_value.get_lun_info.side_effect = [None, self.get_lun_info_return_value()]
    mock_api_executor.return_value.clone_snapshot.return_value = None
    mock_api_executor.return_value.create_snapshot_api.return_value = 'fakeSnapshotId'
    mock_extend_lun.return_value = None
    self.driver = qnap.QnapISCSIDriver(configuration=create_configuration('admin', 'qnapadmin', 'http://1.2.3.4:8080', '1.2.3.4', 'Pool1', True))
    self.driver.do_setup('context')
    self.driver.create_volume_from_snapshot(fake_volume, fake_snapshot)
    expected_call_list = [mock.call(LUNName='fakeLun'), mock.call(LUNName='fakeLun')]
    self.assertEqual(expected_call_list, mock_api_executor.return_value.get_lun_info.call_args_list)
    mock_api_return = mock_api_executor.return_value
    mock_api_return.clone_snapshot.assert_called_once_with('fakeSnapshotId', 'fakeLun')
    mock_extend_lun.assert_called_once_with(fake_volume, 'fakeLunNaa')
