'Test edit lun.'

@mock.patch('six.moves.http_client.HTTPConnection')
def test_edit_lun(self, mock_http_connection):

    mock_http_connection.return_value.getresponse.side_effect = [FakeLoginResponse(), FakeGetBasicInfoResponse(), FakeLoginResponse(), FakeLunInfoResponse()]
    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')
    fake_lun = {'LUNName': 'fakeLunName', 'LUNCapacity': 100, 'LUNIndex': 'fakeLunIndex', 'LUNThinAllocate': False, 'LUNPath': 'fakeLunPath', 'LUNStatus': 'fakeLunStatus'}
    self.driver.api_executor.edit_lun(fake_lun)
    fake_params = {}
    fake_params['func'] = 'edit_lun'
    fake_params['LUNName'] = 'fakeLunName'
    fake_params['LUNCapacity'] = 100
    fake_params['LUNIndex'] = 'fakeLunIndex'
    fake_params['LUNThinAllocate'] = False
    fake_params['LUNPath'] = 'fakeLunPath'
    fake_params['LUNStatus'] = 'fakeLunStatus'
    fake_params['sid'] = 'fakeSid'
    sanitized_params = {}
    for key in fake_params:
        value = fake_params[key]
        if (value is not None):
            sanitized_params[key] = six.text_type(value)
    sanitized_params = urllib.parse.urlencode(sanitized_params)
    edit_lun_url = ('/cgi-bin/disk/iscsi_lun_setting.cgi?%s' % sanitized_params)
    expected_call_list = [mock.call('POST', login_url, global_sanitized_params, header), mock.call('GET', get_basic_info_url), mock.call('POST', login_url, global_sanitized_params, header), mock.call('GET', edit_lun_url)]
    self.assertEqual(expected_call_list, mock_http_connection.return_value.request.call_args_list)
