~ubuntu-branches/ubuntu/vivid/horizon/vivid

« back to all changes in this revision

Viewing changes to openstack_dashboard/test/api_tests/neutron_tests.py

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2015-03-30 11:12:29 UTC
  • mfrom: (0.14.1) (0.12.2) (76.1.7 vivid-proposed)
  • Revision ID: package-import@ubuntu.com-20150330111229-08du2zlqf9khi4k5
Tags: 1:2015.1~b3-0ubuntu1
* New upstream milestone release:
  - d/control: All version requirements with upstream, drop dependency
    on lockfile.
  - Refresh xstatic assets.
  - d/p/*: Refresh.
* d/pydist-overrides: Add overrides for oslo packages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#    License for the specific language governing permissions and limitations
13
13
#    under the License.
14
14
 
 
15
import uuid
 
16
 
15
17
from django.test.utils import override_settings
16
18
 
 
19
from neutronclient.common import exceptions as neutron_exc
 
20
 
17
21
from openstack_dashboard import api
18
22
from openstack_dashboard import policy
19
23
from openstack_dashboard.test import helpers as test
392
396
 
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)
 
399
 
 
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
 
408
        # are expected.
 
409
 
 
410
        ports = [{'id': str(uuid.uuid4()),
 
411
                  'name': 'port%s' % i,
 
412
                  'admin_state_up': True}
 
413
                 for i in range(10)]
 
414
        port_ids = [port['id'] for port in ports]
 
415
 
 
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]})
 
422
        self.mox.ReplayAll()
 
423
 
 
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])