'Test _extend_lun method.'

@mock.patch.object(qnap.QnapISCSIDriver, '_get_lun_naa_from_volume_metadata')
@mock.patch('cinder.volume.drivers.qnap.QnapAPIExecutor')
def test_extend_lun(self, mock_api_executor, mock_get_lun_naa_from_volume_metadata):

    fake_volume = VolumeClass('fakeDisplayName', 'fakeId', 100, 'fakeLunName')
    mock_api_executor.return_value.get_basic_info.return_value = ('ES1640dc    ', 'ES1640dc    ', '1.1.3')
    mock_get_lun_naa_from_volume_metadata.return_value = 'fakeLunNaa'
    mock_api_executor.return_value.get_lun_info.return_value = self.get_lun_info_return_value()
    mock_api_executor.return_value.edit_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._extend_lun(fake_volume, '')
    mock_api_return = mock_api_executor.return_value
    mock_api_return.get_lun_info.assert_called_once_with(LUNNAA='fakeLunNaa')
    expect_lun = {'LUNName': 'fakeLunName', 'LUNCapacity': fake_volume['size'], 'LUNIndex': 'fakeLunIndex', 'LUNThinAllocate': 'fakeLunThinAllocate', 'LUNPath': 'fakeLunPath', 'LUNStatus': '1'}
    mock_api_return.edit_lun.assert_called_once_with(expect_lun)
