12
12
# License for the specific language governing permissions and limitations
13
13
# under the License.
15
17
from django.test.utils import override_settings
19
from neutronclient.common import exceptions as neutron_exc
17
21
from openstack_dashboard import api
18
22
from openstack_dashboard import policy
19
23
from openstack_dashboard.test import helpers as test
393
397
def test_get_router_ha_permission_without_l3_ha_extension(self):
394
398
self._test_get_router_ha_permission_with_policy_check(False)
400
def test_list_resources_with_long_filters(self):
401
# In this tests, port_list is called with id=[10 port ID]
402
# filter. It generates about 40*10 char length URI.
403
# Each port ID is converted to "id=<UUID>&" in URI and
404
# it means 40 chars (len(UUID)=36).
405
# If excess lenght is 220, it means 400-220=180 chars
406
# can be sent in the first request.
407
# As a result three API calls with 4, 4, 2 port ID
410
ports = [{'id': str(uuid.uuid4()),
411
'name': 'port%s' % i,
412
'admin_state_up': True}
414
port_ids = [port['id'] for port in ports]
416
neutronclient = self.stub_neutronclient()
417
uri_len_exc = neutron_exc.RequestURITooLong(excess=220)
418
neutronclient.list_ports(id=port_ids).AndRaise(uri_len_exc)
419
for i in range(0, 10, 4):
420
neutronclient.list_ports(id=port_ids[i:i + 4]) \
421
.AndReturn({'ports': ports[i:i + 4]})
424
ret_val = api.neutron.list_resources_with_long_filters(
425
api.neutron.port_list, 'id', port_ids,
426
request=self.request)
427
self.assertEqual(10, len(ret_val))
428
self.assertEqual(port_ids, [p.id for p in ret_val])