"Fossies" - the Fresh Open Source Software Archive

Member "horizon-14.0.4/openstack_dashboard/test/unit/usage/test_quotas.py" (22 Oct 2019, 25927 Bytes) of package /linux/misc/openstack/horizon-14.0.4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 # Copyright 2012 United States Government as represented by the
    2 # Administrator of the National Aeronautics and Space Administration.
    3 # All Rights Reserved.
    4 #
    5 # Copyright 2012 Nebula, Inc.
    6 # Copyright (c) 2012 X.commerce, a business unit of eBay Inc.
    7 #
    8 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
    9 #    not use this file except in compliance with the License. You may obtain
   10 #    a copy of the License at
   11 #
   12 #         http://www.apache.org/licenses/LICENSE-2.0
   13 #
   14 #    Unless required by applicable law or agreed to in writing, software
   15 #    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
   16 #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   17 #    License for the specific language governing permissions and limitations
   18 #    under the License.
   19 
   20 from __future__ import absolute_import
   21 
   22 import collections
   23 
   24 from django.test.utils import override_settings
   25 from django.utils.translation import ugettext_lazy as _
   26 import mock
   27 
   28 from horizon import exceptions
   29 from openstack_dashboard import api
   30 from openstack_dashboard.api import cinder
   31 from openstack_dashboard.test import helpers as test
   32 from openstack_dashboard.usage import quotas
   33 
   34 
   35 class QuotaTests(test.APITestCase):
   36 
   37     def _mock_service_enabled(self, compute_enabled=True,
   38                               network_enabled=False, volume_enabled=True):
   39         services = {'network': network_enabled,
   40                     'compute': compute_enabled}
   41         self._service_call_count = collections.defaultdict(int)
   42 
   43         def fake_service_enabled(request, service):
   44             self._service_call_count[service] += 1
   45             return services[service]
   46 
   47         self.mock_is_service_enabled.side_effect = fake_service_enabled
   48         self.mock_is_volume_service_enabled.return_value = volume_enabled
   49 
   50     def _check_service_enabled(self, expected_count):
   51         expected_volume_count = expected_count.pop('volume', 0)
   52         self.assert_mock_multiple_calls_with_same_arguments(
   53             self.mock_is_volume_service_enabled, expected_volume_count,
   54             mock.call(test.IsHttpRequest()))
   55         self.assertEqual(expected_count, self._service_call_count)
   56         total_count = sum(expected_count.values())
   57         self.assertEqual(total_count, self.mock_is_service_enabled.call_count)
   58 
   59     def get_usages(self, with_volume=True, with_compute=True,
   60                    nova_quotas_enabled=True, tenant_id=None):
   61         usages = {}
   62         if with_compute:
   63             # These are all nova fields; the neutron ones are named slightly
   64             # differently and aren't included in here yet
   65             if nova_quotas_enabled:
   66                 usages.update({
   67                     'injected_file_content_bytes': {'quota': 1},
   68                     'metadata_items': {'quota': 1},
   69                     'injected_files': {'quota': 1},
   70                     'ram': {'available': 8976, 'used': 1024, 'quota': 10000},
   71                     'instances': {'available': 8, 'used': 2, 'quota': 10},
   72                     'cores': {'available': 8, 'used': 2, 'quota': 10},
   73                     'key_pairs': {'quota': 100},
   74                     'injected_file_path_bytes': {'quota': 255}
   75                 })
   76                 if tenant_id == 3:
   77                     usages.update({
   78                         'ram': {'available': 10000,
   79                                 'used': 0,
   80                                 'quota': 10000},
   81                         'instances': {'available': 10, 'used': 2, 'quota': 10},
   82                         'cores': {'available': 10, 'used': 2, 'quota': 10}
   83                     })
   84 
   85         if with_volume:
   86             usages.update({'volumes': {'available': 0, 'used': 4, 'quota': 1},
   87                            'snapshots': {'available': 0, 'used': 3,
   88                                          'quota': 1},
   89                            'gigabytes': {'available': 600, 'used': 400,
   90                                          'quota': 1000}})
   91         return usages
   92 
   93     def get_usages_from_limits(self, with_volume=True, with_compute=True,
   94                                nova_quotas_enabled=True,
   95                                unlimited_items=None):
   96         usages = {}
   97         if with_compute and nova_quotas_enabled:
   98             usages.update({
   99                 'instances': {'available': 8, 'used': 2, 'quota': 10},
  100                 'cores': {'available': 18, 'used': 2, 'quota': 20},
  101                 'ram': {'available': 8976, 'used': 1024, 'quota': 10000},
  102                 'key_pairs': {'quota': 100},
  103             })
  104         if with_volume:
  105             usages.update({
  106                 'volumes': {'available': 16, 'used': 4, 'quota': 20},
  107                 'gigabytes': {'available': 600, 'used': 400, 'quota': 1000},
  108                 'snapshots': {'available': 7, 'used': 3, 'quota': 10},
  109             })
  110         if unlimited_items:
  111             for item in unlimited_items:
  112                 usages[item]['available'] = float('inf')
  113                 usages[item]['quota'] = float('inf')
  114         return usages
  115 
  116     def assertAvailableQuotasEqual(self, expected_usages, actual_usages):
  117         expected_available = {key: value['available'] for key, value in
  118                               expected_usages.items() if 'available' in value}
  119         actual_available = {key: value['available'] for key, value in
  120                             actual_usages.items() if 'available' in value}
  121         self.assertEqual(expected_available, actual_available)
  122 
  123     @test.create_mocks({
  124         api.nova: (('tenant_absolute_limits', 'nova_tenant_absolute_limits'),),
  125         api.base: ('is_service_enabled',),
  126         cinder: (('tenant_absolute_limits', 'cinder_tenant_absolute_limits'),
  127                  'is_volume_service_enabled')})
  128     def test_tenant_quota_usages_with_id(self):
  129         tenant_id = 3
  130 
  131         self._mock_service_enabled()
  132         self.mock_nova_tenant_absolute_limits.return_value = \
  133             self.limits['absolute']
  134         self.mock_cinder_tenant_absolute_limits.return_value = \
  135             self.cinder_limits['absolute']
  136 
  137         quota_usages = quotas.tenant_quota_usages(self.request,
  138                                                   tenant_id=tenant_id)
  139         expected_output = self.get_usages_from_limits(
  140             with_volume=True, with_compute=True)
  141 
  142         # Compare internal structure of usages to expected.
  143         self.assertItemsEqual(expected_output, quota_usages.usages)
  144         # Compare available resources
  145         self.assertAvailableQuotasEqual(expected_output, quota_usages.usages)
  146 
  147         self._check_service_enabled({'compute': 2, 'network': 1, 'volume': 1})
  148         self.mock_nova_tenant_absolute_limits.assert_called_once_with(
  149             test.IsHttpRequest(), reserved=True, tenant_id=tenant_id)
  150         self.mock_cinder_tenant_absolute_limits.assert_called_once_with(
  151             test.IsHttpRequest(), tenant_id)
  152 
  153     @test.create_mocks({
  154         api.nova: (('tenant_absolute_limits', 'nova_tenant_absolute_limits'),),
  155         api.base: ('is_service_enabled',),
  156         cinder: (('tenant_absolute_limits', 'cinder_tenant_absolute_limits'),
  157                  'is_volume_service_enabled')})
  158     def _test_tenant_quota_usages(self,
  159                                   nova_quotas_enabled=True,
  160                                   with_compute=True, with_volume=True,
  161                                   unlimited_items=None):
  162         tenant_id = '1'
  163 
  164         self._mock_service_enabled(compute_enabled=with_compute,
  165                                    volume_enabled=with_volume)
  166         if with_compute and nova_quotas_enabled:
  167             self.mock_nova_tenant_absolute_limits.return_value = \
  168                 self.limits['absolute']
  169         if with_volume:
  170             self.mock_cinder_tenant_absolute_limits.return_value = \
  171                 self.cinder_limits['absolute']
  172 
  173         quota_usages = quotas.tenant_quota_usages(self.request)
  174         expected_output = self.get_usages_from_limits(
  175             nova_quotas_enabled=nova_quotas_enabled,
  176             with_volume=with_volume,
  177             with_compute=with_compute,
  178             unlimited_items=unlimited_items)
  179 
  180         # Compare internal structure of usages to expected.
  181         self.assertItemsEqual(expected_output, quota_usages.usages)
  182         # Compare available resources
  183         self.assertAvailableQuotasEqual(expected_output, quota_usages.usages)
  184 
  185         if with_compute and nova_quotas_enabled:
  186             self._check_service_enabled({'compute': 2, 'network': 1,
  187                                          'volume': 1})
  188             self.mock_nova_tenant_absolute_limits.assert_called_once_with(
  189                 test.IsHttpRequest(), reserved=True, tenant_id=tenant_id)
  190         else:
  191             self._check_service_enabled({'compute': 1, 'network': 1,
  192                                          'volume': 1})
  193             self.mock_nova_tenant_absolute_limits.assert_not_called()
  194         if with_volume:
  195             self.mock_cinder_tenant_absolute_limits.assert_called_once_with(
  196                 test.IsHttpRequest(), tenant_id)
  197         else:
  198             self.mock_cinder_tenant_absolute_limits.assert_not_called()
  199 
  200     def test_tenant_quota_usages(self):
  201         self._test_tenant_quota_usages()
  202 
  203     @override_settings(OPENSTACK_HYPERVISOR_FEATURES={'enable_quotas': False})
  204     def test_tenant_quota_usages_wo_nova_quotas(self):
  205         self._test_tenant_quota_usages(nova_quotas_enabled=False,
  206                                        with_compute=True,
  207                                        with_volume=False)
  208 
  209     def test_tenant_quota_usages_with_unlimited(self):
  210         self.limits['absolute']['maxTotalInstances'] = float('inf')
  211         self._test_tenant_quota_usages(unlimited_items=['instances'])
  212 
  213     @override_settings(OPENSTACK_HYPERVISOR_FEATURES={'enable_quotas': False})
  214     @test.create_mocks({api.base: ('is_service_enabled',),
  215                         cinder: ('is_volume_service_enabled',)})
  216     def test_get_all_disabled_quotas(self):
  217         self._mock_service_enabled(volume_enabled=False)
  218 
  219         result_quotas = quotas.get_disabled_quotas(self.request)
  220         expected_quotas = (quotas.CINDER_QUOTA_FIELDS |
  221                            quotas.NEUTRON_QUOTA_FIELDS |
  222                            quotas.NOVA_QUOTA_FIELDS)
  223         self.assertItemsEqual(result_quotas, expected_quotas)
  224 
  225         self._check_service_enabled({'compute': 1, 'network': 1, 'volume': 1})
  226 
  227     @test.create_mocks({api.nova: ('tenant_absolute_limits',),
  228                         api.base: ('is_service_enabled',),
  229                         cinder: ('is_volume_service_enabled',)})
  230     def test_tenant_quota_usages_without_volume(self):
  231         tenant_id = self.request.user.tenant_id
  232 
  233         self._mock_service_enabled(volume_enabled=False)
  234         self.mock_tenant_absolute_limits.return_value = self.limits['absolute']
  235 
  236         quota_usages = quotas.tenant_quota_usages(self.request)
  237         expected_output = self.get_usages_from_limits(with_volume=False)
  238 
  239         # Compare internal structure of usages to expected.
  240         self.assertItemsEqual(expected_output, quota_usages.usages)
  241 
  242         # Make sure that the `in` operator and the `.get()` method
  243         # behave as expected
  244         self.assertIn('ram', quota_usages)
  245         self.assertIsNotNone(quota_usages.get('ram'))
  246 
  247         self._check_service_enabled({'compute': 2, 'network': 1, 'volume': 1})
  248         self.mock_tenant_absolute_limits.assert_called_once_with(
  249             test.IsHttpRequest(), reserved=True, tenant_id=tenant_id)
  250 
  251     @test.create_mocks({api.nova: ('tenant_absolute_limits',),
  252                         api.base: ('is_service_enabled',),
  253                         cinder: ('is_volume_service_enabled',)})
  254     def test_tenant_quota_usages_no_instances_running(self):
  255         self._mock_service_enabled(volume_enabled=False)
  256         self.mock_tenant_absolute_limits.return_value = self.limits['absolute']
  257 
  258         quota_usages = quotas.tenant_quota_usages(self.request)
  259         expected_output = self.get_usages_from_limits(with_volume=False)
  260 
  261         expected_output.update({
  262             'ram': {'available': 10000, 'used': 0, 'quota': 10000},
  263             'instances': {'available': 10, 'used': 0, 'quota': 10},
  264             'cores': {'available': 10, 'used': 0, 'quota': 10}})
  265 
  266         # Compare internal structure of usages to expected.
  267         self.assertItemsEqual(expected_output, quota_usages.usages)
  268 
  269         self._check_service_enabled({'compute': 2, 'network': 1, 'volume': 1})
  270         self.mock_tenant_absolute_limits.assert_called_once_with(
  271             test.IsHttpRequest(), reserved=True, tenant_id='1')
  272 
  273     @test.create_mocks({
  274         api.nova: (('tenant_absolute_limits', 'nova_tenant_absolute_limits'),),
  275         api.base: ('is_service_enabled',),
  276         cinder: (('tenant_absolute_limits', 'cinder_tenant_absolute_limits'),
  277                  'is_volume_service_enabled')})
  278     def test_tenant_quota_usages_unlimited_quota(self):
  279         tenant_id = '1'
  280         inf_quota = self.quotas.first()
  281         inf_quota['ram'] = -1
  282 
  283         self._mock_service_enabled()
  284         self.mock_nova_tenant_absolute_limits.return_value = \
  285             self.limits['absolute']
  286         self.mock_cinder_tenant_absolute_limits.return_value = \
  287             self.cinder_limits['absolute']
  288 
  289         quota_usages = quotas.tenant_quota_usages(self.request)
  290         expected_output = self.get_usages_from_limits()
  291         expected_output.update({'ram': {'available': float("inf"),
  292                                         'used': 1024,
  293                                         'quota': float("inf")}})
  294 
  295         # Compare internal structure of usages to expected.
  296         self.assertItemsEqual(expected_output, quota_usages.usages)
  297 
  298         self._check_service_enabled({'compute': 2, 'network': 1, 'volume': 1})
  299         self.mock_nova_tenant_absolute_limits.assert_called_once_with(
  300             test.IsHttpRequest(), reserved=True, tenant_id=tenant_id)
  301         self.mock_cinder_tenant_absolute_limits.assert_called_once_with(
  302             test.IsHttpRequest(), tenant_id)
  303 
  304     @test.create_mocks({
  305         api.nova: (('tenant_absolute_limits', 'nova_tenant_absolute_limits'),),
  306         api.base: ('is_service_enabled',),
  307         cinder: (('tenant_absolute_limits', 'cinder_tenant_absolute_limits'),
  308                  'is_volume_service_enabled')})
  309     def test_tenant_quota_usages_neutron_fip_disabled(self):
  310         tenant_id = '1'
  311 
  312         self._mock_service_enabled()
  313         self.mock_nova_tenant_absolute_limits.return_value = \
  314             self.limits['absolute']
  315         self.mock_cinder_tenant_absolute_limits.return_value = \
  316             self.cinder_limits['absolute']
  317 
  318         quota_usages = quotas.tenant_quota_usages(self.request)
  319         expected_output = self.get_usages_from_limits()
  320 
  321         # Compare internal structure of usages to expected.
  322         self.assertItemsEqual(expected_output, quota_usages.usages)
  323 
  324         self._check_service_enabled({'compute': 2, 'network': 1, 'volume': 1})
  325         self.mock_nova_tenant_absolute_limits.assert_called_once_with(
  326             test.IsHttpRequest(), reserved=True, tenant_id=tenant_id)
  327         self.mock_cinder_tenant_absolute_limits.assert_called_once_with(
  328             test.IsHttpRequest(), tenant_id)
  329 
  330     @test.create_mocks({api.base: ('is_service_enabled',),
  331                         cinder: ('tenant_quota_get',
  332                                  'is_volume_service_enabled'),
  333                         exceptions: ('handle',)})
  334     def test_get_quota_data_cinder_exception(self):
  335         self._mock_service_enabled(compute_enabled=False)
  336         self.mock_tenant_quota_get.side_effect = \
  337             cinder.cinder_exception.ClientException('test')
  338 
  339         quotas.get_tenant_quota_data(self.request)
  340 
  341         self._check_service_enabled({'compute': 1, 'network': 1, 'volume': 1})
  342         self.mock_tenant_quota_get.assert_called_once_with(
  343             test.IsHttpRequest(), '1')
  344         self.mock_handle.assert_called_once_with(
  345             test.IsHttpRequest(),
  346             _("Unable to retrieve volume limit information."))
  347 
  348     @test.create_mocks({api.neutron: ('is_router_enabled',
  349                                       'is_extension_supported',
  350                                       'is_quotas_extension_supported',),
  351                         api.cinder: ('is_volume_service_enabled',),
  352                         api.base: ('is_service_enabled',)})
  353     def test_get_disabled_quotas_router_disabled(self):
  354         self._mock_service_enabled(network_enabled=True)
  355         self.mock_is_extension_supported.return_value = True
  356         self.mock_is_router_enabled.return_value = False
  357         self.mock_is_quotas_extension_supported.return_value = True
  358 
  359         disabled_quotas = quotas.get_disabled_quotas(self.request)
  360         expected = set(['router', 'floatingip'])
  361         self.assertEqual(expected, disabled_quotas)
  362 
  363         self._check_service_enabled({'compute': 1, 'network': 1, 'volume': 1})
  364         self.mock_is_extension_supported.assert_called_once_with(
  365             test.IsHttpRequest(), 'security-group')
  366         self.mock_is_router_enabled.assert_called_once_with(
  367             test.IsHttpRequest())
  368         self.mock_is_quotas_extension_supported.assert_called_once_with(
  369             test.IsHttpRequest())
  370 
  371     def test_tenant_quota_usages_with_target_instances(self):
  372         self._test_tenant_quota_usages_with_target(
  373             targets=('instances', ), use_cinder_call=False)
  374 
  375     def test_tenant_quota_usages_with_target_ram(self):
  376         self._test_tenant_quota_usages_with_target(
  377             targets=('ram', ), use_flavor_list=True, use_cinder_call=False)
  378 
  379     def test_tenant_quota_usages_with_target_volume(self):
  380         self._test_tenant_quota_usages_with_target(
  381             targets=('volumes', ), use_compute_call=False,
  382             use_cinder_call=True)
  383 
  384     def test_tenant_quota_usages_with_target_compute_volume(self):
  385         self._test_tenant_quota_usages_with_target(
  386             targets=('instances', 'cores', 'ram', 'volumes', ),
  387             use_flavor_list=True, use_cinder_call=True)
  388 
  389     @test.create_mocks({
  390         api.nova: (('tenant_absolute_limits', 'nova_tenant_absolute_limits'),),
  391         api.base: ('is_service_enabled',),
  392         cinder: (('tenant_absolute_limits', 'cinder_tenant_absolute_limits'),
  393                  'is_volume_service_enabled')})
  394     def _test_tenant_quota_usages_with_target(
  395             self, targets, use_compute_call=True,
  396             use_flavor_list=False, use_cinder_call=False):
  397 
  398         tenant_id = self.request.user.tenant_id
  399 
  400         self._mock_service_enabled()
  401         if use_compute_call:
  402             self.mock_nova_tenant_absolute_limits.return_value = \
  403                 self.limits['absolute']
  404         if use_cinder_call:
  405             self.mock_cinder_tenant_absolute_limits.return_value = \
  406                 self.cinder_limits['absolute']
  407 
  408         quota_usages = quotas.tenant_quota_usages(self.request,
  409                                                   targets=targets)
  410 
  411         expected = self.get_usages_from_limits()
  412         expected = dict((k, v) for k, v in expected.items() if k in targets)
  413 
  414         # Compare internal structure of usages to expected.
  415         self.assertItemsEqual(expected, quota_usages.usages)
  416         # Compare available resources
  417         self.assertAvailableQuotasEqual(expected, quota_usages.usages)
  418 
  419         expected_count = {}
  420         if use_compute_call:
  421             expected_count['compute'] = 2
  422         if use_cinder_call:
  423             expected_count['volume'] = 1
  424         self._check_service_enabled(expected_count)
  425         if use_compute_call:
  426             self.mock_nova_tenant_absolute_limits.assert_called_once_with(
  427                 test.IsHttpRequest(), reserved=True, tenant_id=tenant_id)
  428         else:
  429             self.mock_nova_tenant_absolute_limits.assert_not_called()
  430         if use_cinder_call:
  431             self.mock_cinder_tenant_absolute_limits.assert_called_once_with(
  432                 test.IsHttpRequest(), tenant_id)
  433         else:
  434             self.mock_cinder_tenant_absolute_limits.assert_not_called()
  435 
  436     def test_tenant_quota_usages_neutron_with_target_network_resources(self):
  437         self._test_tenant_quota_usages_neutron_with_target(
  438             targets=('network', 'subnet', 'router', ))
  439 
  440     def test_tenant_quota_usages_neutron_with_target_security_groups(self):
  441         self._test_tenant_quota_usages_neutron_with_target(
  442             targets=('security_group', ))
  443 
  444     def test_tenant_quota_usages_neutron_with_target_floating_ips(self):
  445         self._test_tenant_quota_usages_neutron_with_target(
  446             targets=('floatingip', ))
  447 
  448     @test.create_mocks({api.base: ('is_service_enabled',),
  449                         cinder: ('is_volume_service_enabled',),
  450                         api.neutron: ('floating_ip_supported',
  451                                       'tenant_floating_ip_list',
  452                                       'security_group_list',
  453                                       'is_extension_supported',
  454                                       'is_router_enabled',
  455                                       'is_quotas_extension_supported',
  456                                       'tenant_quota_get',
  457                                       'network_list',
  458                                       'subnet_list',
  459                                       'router_list')})
  460     def _test_tenant_quota_usages_neutron_with_target(self, targets):
  461         self._mock_service_enabled(network_enabled=True)
  462         if 'security_group' in targets:
  463             self.mock_is_extension_supported.side_effect = [True, False]
  464         else:
  465             self.mock_is_extension_supported.side_effect = [False]
  466         self.mock_is_router_enabled.return_value = True
  467         self.mock_is_quotas_extension_supported.return_value = True
  468         self.mock_tenant_quota_get.return_value = self.neutron_quotas.first()
  469 
  470         if 'network' in targets:
  471             self.mock_network_list.return_value = self.networks.list()
  472         if 'subnet' in targets:
  473             self.mock_subnet_list.return_value = self.subnets.list()
  474         if 'router' in targets:
  475             self.mock_router_list.return_value = self.routers.list()
  476         if 'floatingip' in targets:
  477             self.mock_tenant_floating_ip_list.return_value = \
  478                 self.floating_ips.list()
  479         if 'security_group' in targets:
  480             self.mock_security_group_list.return_value = \
  481                 self.security_groups.list()
  482 
  483         quota_usages = quotas.tenant_quota_usages(self.request,
  484                                                   targets=targets)
  485 
  486         network_used = len(self.networks.list())
  487         subnet_used = len(self.subnets.list())
  488         router_used = len(self.routers.list())
  489         fip_used = len(self.floating_ips.list())
  490         sg_used = len(self.security_groups.list())
  491         expected = {
  492             'network': {'used': network_used, 'quota': 10,
  493                         'available': 10 - network_used},
  494             'subnet': {'used': subnet_used, 'quota': 10,
  495                        'available': 10 - subnet_used},
  496             'router': {'used': router_used, 'quota': 10,
  497                        'available': 10 - router_used},
  498             'security_group': {'used': sg_used, 'quota': 20,
  499                                'available': 20 - sg_used},
  500             'floatingip': {'used': fip_used, 'quota': 50,
  501                            'available': 50 - fip_used},
  502         }
  503         expected = dict((k, v) for k, v in expected.items() if k in targets)
  504 
  505         # Compare internal structure of usages to expected.
  506         self.assertEqual(expected, quota_usages.usages)
  507         # Compare available resources
  508         self.assertAvailableQuotasEqual(expected, quota_usages.usages)
  509 
  510         self._check_service_enabled({'network': 1})
  511         if 'security_group' in targets:
  512             self.mock_is_extension_supported.assert_has_calls([
  513                 mock.call(test.IsHttpRequest(), 'security-group'),
  514                 mock.call(test.IsHttpRequest(), 'quota_details'),
  515             ])
  516             self.assertEqual(2, self.mock_is_extension_supported.call_count)
  517         else:
  518             self.mock_is_extension_supported.assert_called_once_with(
  519                 test.IsHttpRequest(), 'quota_details')
  520         if 'floatingip' in targets or 'router' in targets:
  521             self.mock_is_router_enabled.assert_called_once_with(
  522                 test.IsHttpRequest())
  523         else:
  524             self.mock_is_router_enabled.assert_not_called()
  525         self.mock_is_quotas_extension_supported.assert_called_once_with(
  526             test.IsHttpRequest())
  527         self.mock_tenant_quota_get.assert_called_once_with(
  528             test.IsHttpRequest(), '1')
  529         if 'network' in targets:
  530             self.mock_network_list.assert_called_once_with(
  531                 test.IsHttpRequest(),
  532                 tenant_id=self.request.user.tenant_id)
  533         else:
  534             self.mock_network_list.assert_not_called()
  535         if 'subnet' in targets:
  536             self.mock_subnet_list.assert_called_once_with(
  537                 test.IsHttpRequest(),
  538                 tenant_id=self.request.user.tenant_id)
  539         else:
  540             self.mock_subnet_list.assert_not_called()
  541         if 'router' in targets:
  542             self.mock_router_list.assert_called_once_with(
  543                 test.IsHttpRequest(),
  544                 tenant_id=self.request.user.tenant_id)
  545         else:
  546             self.mock_router_list.assert_not_called()
  547         if 'floatingip' in targets:
  548             self.mock_tenant_floating_ip_list.assert_called_once_with(
  549                 test.IsHttpRequest())
  550         else:
  551             self.mock_tenant_floating_ip_list.assert_not_called()
  552         if 'security_group' in targets:
  553             self.mock_security_group_list.assert_called_once_with(
  554                 test.IsHttpRequest())
  555         else:
  556             self.mock_security_group_list.assert_not_called()