From f23c84189c8a4febbbcd86864fa5cd28bc9a9a65 Mon Sep 17 00:00:00 2001 From: Akihiro Motoki Date: Sun, 16 Apr 2017 05:03:45 +0000 Subject: [PATCH] Drop Nova SG and FIP related unit tests from dashboard code Previously security group and floating IP tests covered both nova and neutron APIs. This commit drops Nova security group and floating IP unit tests. All these unit tests now consumes neutron API wrapper and neutron test data. Partially implement blueprint drop-nova-network Change-Id: I1e3ad42cbeb90c00be29784869108d3d0db83162 --- .../dashboards/project/floating_ips/tests.py | 127 ++++++++------ .../project/security_groups/tests.py | 157 ++++++++---------- 2 files changed, 142 insertions(+), 142 deletions(-) diff --git a/openstack_dashboard/dashboards/project/floating_ips/tests.py b/openstack_dashboard/dashboards/project/floating_ips/tests.py index fa9ca054b4..3ad1bd6c65 100644 --- a/openstack_dashboard/dashboards/project/floating_ips/tests.py +++ b/openstack_dashboard/dashboards/project/floating_ips/tests.py @@ -37,27 +37,13 @@ NAMESPACE = "horizon:project:floating_ips" class FloatingIpViewTests(test.TestCase): - # TODO(amotoki): [drop-nova-network] self.floating_ips (with integer - # ID) is no longer needed. self.floating_ips_uuid should be renamed - # self.floating_ips. - # floating IP test data in nova_data.py needs to be dropped as well. - - def setUp(self): - super(FloatingIpViewTests, self).setUp() - self._floating_ips_orig = self.floating_ips - self.floating_ips = self.floating_ips_uuid - - def tearDown(self): - self.floating_ips = self._floating_ips_orig - super(FloatingIpViewTests, self).tearDown() - @test.create_stubs({api.network: ('floating_ip_target_list', 'tenant_floating_ip_list',)}) def test_associate(self): api.network.floating_ip_target_list(IsA(http.HttpRequest)) \ - .AndReturn(self.servers.list()) + .AndReturn(self._get_fip_targets()) api.network.tenant_floating_ip_list(IsA(http.HttpRequest)) \ - .AndReturn(self.floating_ips.list()) + .AndReturn(self.q_floating_ips.list()) self.mox.ReplayAll() url = reverse('%s:associate' % NAMESPACE) @@ -66,69 +52,96 @@ class FloatingIpViewTests(test.TestCase): workflow = res.context['workflow'] choices = dict(workflow.steps[0].action.fields['ip_id'].choices) # Verify that our "associated" floating IP isn't in the choices list. - self.assertNotIn(self.floating_ips.first(), choices) + self.assertNotIn(self.q_floating_ips.first(), choices) @test.create_stubs({api.network: ('floating_ip_target_list', 'floating_ip_target_get_by_instance', 'tenant_floating_ip_list',)}) def test_associate_with_instance_id(self): + targets = self._get_fip_targets() + target = targets[0] api.network.floating_ip_target_list(IsA(http.HttpRequest)) \ - .AndReturn(self.servers.list()) + .AndReturn(targets) api.network.floating_ip_target_get_by_instance( - IsA(http.HttpRequest), 'TEST-ID', self.servers.list()) \ - .AndReturn('TEST-ID') + IsA(http.HttpRequest), target.instance_id, targets) \ + .AndReturn(target.id) api.network.tenant_floating_ip_list(IsA(http.HttpRequest)) \ - .AndReturn(self.floating_ips.list()) + .AndReturn(self.q_floating_ips.list()) self.mox.ReplayAll() base_url = reverse('%s:associate' % NAMESPACE) - params = urlencode({'instance_id': 'TEST-ID'}) + params = urlencode({'instance_id': target.instance_id}) url = '?'.join([base_url, params]) res = self.client.get(url) self.assertTemplateUsed(res, views.WorkflowView.template_name) workflow = res.context['workflow'] choices = dict(workflow.steps[0].action.fields['ip_id'].choices) # Verify that our "associated" floating IP isn't in the choices list. - self.assertNotIn(self.floating_ips.first(), choices) + self.assertNotIn(self.q_floating_ips.first(), choices) + + def _get_compute_ports(self): + return [p for p in self.ports.list() + if not p.device_owner.startswith('network:')] + + def _get_fip_targets(self): + server_dict = dict((s.id, s.name) for s in self.servers.list()) + targets = [] + for p in self._get_compute_ports(): + for ip in p.fixed_ips: + p_data = {'name': '%s: %s' % (server_dict[p.device_id], + ip['ip_address']), + 'id': '%s_%s' % (p.id, ip['ip_address']), + 'port_id': p.id, + 'instance_id': p.device_id} + targets.append(api.neutron.FloatingIpTarget(p_data)) + return targets + + @staticmethod + def _get_target_id(port): + return '%s_%s' % (port.id, port.fixed_ips[0]['ip_address']) @test.create_stubs({api.network: ('floating_ip_target_list', 'tenant_floating_ip_list',)}) def test_associate_with_port_id(self): - targets = [api.nova.FloatingIpTarget(s) for s in self.servers.list()] - targets[0].port_id = '101' + compute_port = self._get_compute_ports()[0] + associated_fips = [fip.id for fip in self.q_floating_ips.list() + if fip.port_id] + api.network.floating_ip_target_list(IsA(http.HttpRequest)) \ - .AndReturn(targets) + .AndReturn(self._get_fip_targets()) api.network.tenant_floating_ip_list(IsA(http.HttpRequest)) \ - .AndReturn(self.floating_ips.list()) + .AndReturn(self.q_floating_ips.list()) self.mox.ReplayAll() base_url = reverse('%s:associate' % NAMESPACE) - params = urlencode({'port_id': '101'}) + params = urlencode({'port_id': compute_port.id}) url = '?'.join([base_url, params]) res = self.client.get(url) self.assertTemplateUsed(res, views.WorkflowView.template_name) workflow = res.context['workflow'] choices = dict(workflow.steps[0].action.fields['ip_id'].choices) # Verify that our "associated" floating IP isn't in the choices list. - self.assertNotIn(self.floating_ips.first(), choices) + self.assertFalse(set(associated_fips) & set(choices.keys())) @test.create_stubs({api.network: ('floating_ip_associate', 'floating_ip_target_list', 'tenant_floating_ip_list',)}) def test_associate_post(self): - floating_ip = self.floating_ips.list()[1] - server = self.servers.first() + floating_ip = [fip for fip in self.q_floating_ips.list() + if not fip.port_id][0] + compute_port = self._get_compute_ports()[0] + port_target_id = self._get_target_id(compute_port) api.network.tenant_floating_ip_list(IsA(http.HttpRequest)) \ - .AndReturn(self.floating_ips.list()) + .AndReturn(self.q_floating_ips.list()) api.network.floating_ip_target_list(IsA(http.HttpRequest)) \ - .AndReturn(self.servers.list()) + .AndReturn(self._get_fip_targets()) api.network.floating_ip_associate(IsA(http.HttpRequest), floating_ip.id, - server.id) + port_target_id) self.mox.ReplayAll() - form_data = {'instance_id': server.id, + form_data = {'instance_id': port_target_id, 'ip_id': floating_ip.id} url = reverse('%s:associate' % NAMESPACE) res = self.client.post(url, form_data) @@ -138,19 +151,21 @@ class FloatingIpViewTests(test.TestCase): 'floating_ip_target_list', 'tenant_floating_ip_list',)}) def test_associate_post_with_redirect(self): - floating_ip = self.floating_ips.list()[1] - server = self.servers.first() + floating_ip = [fip for fip in self.q_floating_ips.list() + if not fip.port_id][0] + compute_port = self._get_compute_ports()[0] + port_target_id = self._get_target_id(compute_port) api.network.tenant_floating_ip_list(IsA(http.HttpRequest)) \ - .AndReturn(self.floating_ips.list()) + .AndReturn(self.q_floating_ips.list()) api.network.floating_ip_target_list(IsA(http.HttpRequest)) \ - .AndReturn(self.servers.list()) + .AndReturn(self._get_fip_targets()) api.network.floating_ip_associate(IsA(http.HttpRequest), floating_ip.id, - server.id) + port_target_id) self.mox.ReplayAll() next = reverse("horizon:project:instances:index") - form_data = {'instance_id': server.id, + form_data = {'instance_id': port_target_id, 'next': next, 'ip_id': floating_ip.id} url = reverse('%s:associate' % NAMESPACE) @@ -161,20 +176,22 @@ class FloatingIpViewTests(test.TestCase): 'floating_ip_target_list', 'tenant_floating_ip_list',)}) def test_associate_post_with_exception(self): - floating_ip = self.floating_ips.list()[1] - server = self.servers.first() + floating_ip = [fip for fip in self.q_floating_ips.list() + if not fip.port_id][0] + compute_port = self._get_compute_ports()[0] + port_target_id = self._get_target_id(compute_port) api.network.tenant_floating_ip_list(IsA(http.HttpRequest)) \ - .AndReturn(self.floating_ips.list()) + .AndReturn(self.q_floating_ips.list()) api.network.floating_ip_target_list(IsA(http.HttpRequest)) \ - .AndReturn(self.servers.list()) + .AndReturn(self._get_fip_targets()) api.network.floating_ip_associate(IsA(http.HttpRequest), floating_ip.id, - server.id) \ + port_target_id) \ .AndRaise(self.exceptions.nova) self.mox.ReplayAll() - form_data = {'instance_id': server.id, + form_data = {'instance_id': port_target_id, 'ip_id': floating_ip.id} url = reverse('%s:associate' % NAMESPACE) res = self.client.post(url, form_data) @@ -186,12 +203,12 @@ class FloatingIpViewTests(test.TestCase): 'tenant_floating_ip_list',), api.neutron: ('is_extension_supported',)}) def test_disassociate_post(self): - floating_ip = self.floating_ips.first() + floating_ip = self.q_floating_ips.first() api.nova.server_list(IsA(http.HttpRequest), detailed=False) \ .AndReturn([self.servers.list(), False]) api.network.tenant_floating_ip_list(IsA(http.HttpRequest)) \ - .AndReturn(self.floating_ips.list()) + .AndReturn(self.q_floating_ips.list()) api.neutron.is_extension_supported(IsA(http.HttpRequest), 'subnet_allocation')\ .AndReturn(True) @@ -210,12 +227,12 @@ class FloatingIpViewTests(test.TestCase): 'tenant_floating_ip_list',), api.neutron: ('is_extension_supported',)}) def test_disassociate_post_with_exception(self): - floating_ip = self.floating_ips.first() + floating_ip = self.q_floating_ips.first() api.nova.server_list(IsA(http.HttpRequest), detailed=False) \ .AndReturn([self.servers.list(), False]) api.network.tenant_floating_ip_list(IsA(http.HttpRequest)) \ - .AndReturn(self.floating_ips.list()) + .AndReturn(self.q_floating_ips.list()) api.neutron.is_extension_supported(IsA(http.HttpRequest), 'subnet_allocation')\ .AndReturn(True) @@ -235,7 +252,7 @@ class FloatingIpViewTests(test.TestCase): quotas: ('tenant_quota_usages',), api.base: ('is_service_enabled',)}) def test_allocate_button_attributes(self): - floating_ips = self.floating_ips.list() + floating_ips = self.q_floating_ips.list() floating_pools = self.pools.list() quota_data = self.quota_usages.first() quota_data['floating_ips']['available'] = 10 @@ -273,7 +290,7 @@ class FloatingIpViewTests(test.TestCase): quotas: ('tenant_quota_usages',), api.base: ('is_service_enabled',)}) def test_allocate_button_disabled_when_quota_exceeded(self): - floating_ips = self.floating_ips.list() + floating_ips = self.q_floating_ips.list() floating_pools = self.pools.list() quota_data = self.quota_usages.first() quota_data['floating_ips']['available'] = 0 @@ -354,11 +371,11 @@ class FloatingIpViewTests(test.TestCase): api.network.floating_ip_supported(IsA(http.HttpRequest)) \ .AndReturn(True) api.network.tenant_floating_ip_list(IsA(http.HttpRequest)) \ - .MultipleTimes().AndReturn(self.floating_ips.list()) + .MultipleTimes().AndReturn(self.q_floating_ips.list()) api.network.floating_ip_pools_list(IsA(http.HttpRequest)) \ .AndReturn(self.pools.list()) api.network.security_group_list(IsA(http.HttpRequest)) \ - .AndReturn(self.security_groups.list()) + .AndReturn(self.q_secgroups.list()) self.mox.ReplayAll() url = reverse('%s:allocate' % NAMESPACE) diff --git a/openstack_dashboard/dashboards/project/security_groups/tests.py b/openstack_dashboard/dashboards/project/security_groups/tests.py index 47e23bc7f1..6e654f59dc 100644 --- a/openstack_dashboard/dashboards/project/security_groups/tests.py +++ b/openstack_dashboard/dashboards/project/security_groups/tests.py @@ -59,33 +59,16 @@ class SecurityGroupsViewTests(test.TestCase): def setUp(self): super(SecurityGroupsViewTests, self).setUp() - sec_group = self.security_groups.first() + + sec_group = self.q_secgroups.first() self.detail_url = reverse(SG_DETAIL_VIEW, args=[sec_group.id]) self.edit_url = reverse(SG_ADD_RULE_VIEW, args=[sec_group.id]) self.update_url = reverse(SG_UPDATE_VIEW, args=[sec_group.id]) - # TODO(amotoki): [drop-nova-network] security_groups test data in - # nova_data.py needs to be dropped as well. - self._sec_groups_orig = self.security_groups - self.security_groups = self.q_secgroups - - self._sec_group_rules_orig = self.security_group_rules - self.security_group_rules = self.q_secgroup_rules - - sec_group = self.security_groups.first() - self.detail_url = reverse(SG_DETAIL_VIEW, args=[sec_group.id]) - self.edit_url = reverse(SG_ADD_RULE_VIEW, args=[sec_group.id]) - self.update_url = reverse(SG_UPDATE_VIEW, args=[sec_group.id]) - - def tearDown(self): - self.security_groups = self._sec_groups_orig - self.security_group_rules = self._sec_group_rules_orig - super(SecurityGroupsViewTests, self).tearDown() - @test.create_stubs({api.network: ('security_group_list',), quotas: ('tenant_quota_usages',)}) def test_index(self): - sec_groups = self.security_groups.list() + sec_groups = self.q_secgroups.list() quota_data = self.quota_usages.first() quota_data['security_groups']['available'] = 10 @@ -116,7 +99,7 @@ class SecurityGroupsViewTests(test.TestCase): @test.create_stubs({api.network: ('security_group_list',), quotas: ('tenant_quota_usages',)}) def test_create_button_attributes(self): - sec_groups = self.security_groups.list() + sec_groups = self.q_secgroups.list() quota_data = self.quota_usages.first() quota_data['security_groups']['available'] = 10 @@ -132,7 +115,7 @@ class SecurityGroupsViewTests(test.TestCase): res = self.client.get(INDEX_URL) security_groups = res.context['security_groups_table'].data - self.assertItemsEqual(security_groups, self.security_groups.list()) + self.assertItemsEqual(security_groups, self.q_secgroups.list()) create_action = self.getAndAssertTableAction(res, 'security_groups', 'create') @@ -149,7 +132,7 @@ class SecurityGroupsViewTests(test.TestCase): quotas: ('tenant_quota_usages',)}) def _test_create_button_disabled_when_quota_exceeded(self, network_enabled): - sec_groups = self.security_groups.list() + sec_groups = self.q_secgroups.list() quota_data = self.quota_usages.first() quota_data['security_groups']['available'] = 0 @@ -165,7 +148,7 @@ class SecurityGroupsViewTests(test.TestCase): res = self.client.get(INDEX_URL) security_groups = res.context['security_groups_table'].data - self.assertItemsEqual(security_groups, self.security_groups.list()) + self.assertItemsEqual(security_groups, self.q_secgroups.list()) create_action = self.getAndAssertTableAction(res, 'security_groups', 'create') @@ -181,9 +164,9 @@ class SecurityGroupsViewTests(test.TestCase): @test.create_stubs({api.network: ('security_group_rule_create', 'security_group_list')}) def _add_security_group_rule_fixture(self, **kwargs): - sec_group = self.security_groups.first() - sec_group_list = self.security_groups.list() - rule = self.security_group_rules.first() + sec_group = self.q_secgroups.first() + sec_group_list = self.q_secgroups.list() + rule = self.q_secgroup_rules.first() api.network.security_group_rule_create( IsA(http.HttpRequest), @@ -201,7 +184,7 @@ class SecurityGroupsViewTests(test.TestCase): @test.create_stubs({api.network: ('security_group_get',)}) def test_update_security_groups_get(self): - sec_group = self.security_groups.first() + sec_group = self.q_secgroups.first() api.network.security_group_get(IsA(http.HttpRequest), sec_group.id).AndReturn(sec_group) self.mox.ReplayAll() @@ -219,7 +202,7 @@ class SecurityGroupsViewTests(test.TestCase): bug #1233501 Security group names cannot contain at characters bug #1224576 Security group names cannot contain spaces """ - sec_group = self.security_groups.first() + sec_group = self.q_secgroups.first() sec_group.name = "@new name" api.network.security_group_update( IsA(http.HttpRequest), @@ -241,7 +224,7 @@ class SecurityGroupsViewTests(test.TestCase): self.assertTemplateUsed(res, SG_CREATE_TEMPLATE) def test_create_security_groups_post(self): - sec_group = self.security_groups.first() + sec_group = self.q_secgroups.first() self._create_security_group(sec_group) def test_create_security_groups_special_chars(self): @@ -251,7 +234,7 @@ class SecurityGroupsViewTests(test.TestCase): bug #1233501 Security group names cannot contain at characters bug #1224576 Security group names cannot contain spaces """ - sec_group = self.security_groups.first() + sec_group = self.q_secgroups.first() sec_group.name = '@group name-\xe3\x82\xb3' self._create_security_group(sec_group) @@ -271,7 +254,7 @@ class SecurityGroupsViewTests(test.TestCase): @test.create_stubs({api.network: ('security_group_create',)}) def test_create_security_groups_post_exception(self): - sec_group = self.security_groups.first() + sec_group = self.q_secgroups.first() api.network.security_group_create( IsA(http.HttpRequest), sec_group.name, @@ -287,7 +270,7 @@ class SecurityGroupsViewTests(test.TestCase): @test.create_stubs({api.network: ('security_group_get',)}) def test_detail_get(self): - sec_group = self.security_groups.first() + sec_group = self.q_secgroups.first() api.network.security_group_get(IsA(http.HttpRequest), sec_group.id).AndReturn(sec_group) @@ -297,7 +280,7 @@ class SecurityGroupsViewTests(test.TestCase): @test.create_stubs({api.network: ('security_group_get',)}) def test_detail_get_exception(self): - sec_group = self.security_groups.first() + sec_group = self.q_secgroups.first() api.network.security_group_get( IsA(http.HttpRequest), @@ -391,9 +374,9 @@ class SecurityGroupsViewTests(test.TestCase): @test.create_stubs({api.network: ('security_group_rule_create', 'security_group_list')}) def test_detail_add_rule_cidr_with_template(self): - sec_group = self.security_groups.first() - sec_group_list = self.security_groups.list() - rule = self.security_group_rules.first() + sec_group = self.q_secgroups.first() + sec_group_list = self.q_secgroups.list() + rule = self.q_secgroup_rules.first() api.network.security_group_rule_create(IsA(http.HttpRequest), sec_group.id, @@ -417,7 +400,7 @@ class SecurityGroupsViewTests(test.TestCase): self.assertRedirectsNoFollow(res, self.detail_url) def _get_source_group_rule(self): - for rule in self.security_group_rules.list(): + for rule in self.q_secgroup_rules.list(): if rule.group: return rule raise Exception("No matches found.") @@ -425,8 +408,8 @@ class SecurityGroupsViewTests(test.TestCase): @test.create_stubs({api.network: ('security_group_rule_create', 'security_group_list',)}) def test_detail_add_rule_self_as_source_group(self): - sec_group = self.security_groups.first() - sec_group_list = self.security_groups.list() + sec_group = self.q_secgroups.first() + sec_group_list = self.q_secgroups.list() rule = self._get_source_group_rule() api.network.security_group_rule_create( @@ -458,8 +441,8 @@ class SecurityGroupsViewTests(test.TestCase): @test.create_stubs({api.network: ('security_group_rule_create', 'security_group_list',)}) def test_detail_add_rule_self_as_source_group_with_template(self): - sec_group = self.security_groups.first() - sec_group_list = self.security_groups.list() + sec_group = self.q_secgroups.first() + sec_group_list = self.q_secgroups.list() rule = self._get_source_group_rule() api.network.security_group_rule_create( @@ -489,9 +472,9 @@ class SecurityGroupsViewTests(test.TestCase): @test.create_stubs({api.network: ('security_group_list',)}) def test_detail_invalid_port(self): - sec_group = self.security_groups.first() - sec_group_list = self.security_groups.list() - rule = self.security_group_rules.first() + sec_group = self.q_secgroups.first() + sec_group_list = self.q_secgroups.list() + rule = self.q_secgroup_rules.first() api.network.security_group_list( IsA(http.HttpRequest)).AndReturn(sec_group_list) @@ -514,9 +497,9 @@ class SecurityGroupsViewTests(test.TestCase): @test.create_stubs({api.network: ('security_group_list',)}) def test_detail_invalid_port_range(self): - sec_group = self.security_groups.first() - sec_group_list = self.security_groups.list() - rule = self.security_group_rules.first() + sec_group = self.q_secgroups.first() + sec_group_list = self.q_secgroups.list() + rule = self.q_secgroup_rules.first() for i in range(3): api.network.security_group_list( @@ -569,9 +552,9 @@ class SecurityGroupsViewTests(test.TestCase): @test.create_stubs({api.network: ('security_group_get', 'security_group_list')}) def test_detail_invalid_icmp_rule(self): - sec_group = self.security_groups.first() - sec_group_list = self.security_groups.list() - icmp_rule = self.security_group_rules.list()[1] + sec_group = self.q_secgroups.first() + sec_group_list = self.q_secgroups.list() + icmp_rule = self.q_secgroup_rules.list()[1] # Call POST 5 times (*2 if Django >= 1.9) call_post = 5 @@ -648,9 +631,9 @@ class SecurityGroupsViewTests(test.TestCase): @test.create_stubs({api.network: ('security_group_rule_create', 'security_group_list')}) def test_detail_add_rule_exception(self): - sec_group = self.security_groups.first() - sec_group_list = self.security_groups.list() - rule = self.security_group_rules.first() + sec_group = self.q_secgroups.first() + sec_group_list = self.q_secgroups.list() + rule = self.q_secgroup_rules.first() api.network.security_group_rule_create( IsA(http.HttpRequest), @@ -677,9 +660,9 @@ class SecurityGroupsViewTests(test.TestCase): @test.create_stubs({api.network: ('security_group_rule_create', 'security_group_list')}) def test_detail_add_rule_duplicated(self): - sec_group = self.security_groups.first() - sec_group_list = self.security_groups.list() - rule = self.security_group_rules.first() + sec_group = self.q_secgroups.first() + sec_group_list = self.q_secgroups.list() + rule = self.q_secgroup_rules.first() api.network.security_group_rule_create( IsA(http.HttpRequest), @@ -706,8 +689,8 @@ class SecurityGroupsViewTests(test.TestCase): @test.create_stubs({api.network: ('security_group_rule_delete',)}) def test_detail_delete_rule(self): - sec_group = self.security_groups.first() - rule = self.security_group_rules.first() + sec_group = self.q_secgroups.first() + rule = self.q_secgroup_rules.first() api.network.security_group_rule_delete(IsA(http.HttpRequest), rule.id) self.mox.ReplayAll() @@ -722,8 +705,8 @@ class SecurityGroupsViewTests(test.TestCase): @test.create_stubs({api.network: ('security_group_rule_delete',)}) def test_detail_delete_rule_exception(self): - sec_group = self.security_groups.first() - rule = self.security_group_rules.first() + sec_group = self.q_secgroups.first() + rule = self.q_secgroup_rules.first() api.network.security_group_rule_delete( IsA(http.HttpRequest), @@ -734,28 +717,28 @@ class SecurityGroupsViewTests(test.TestCase): req = self.factory.post(self.edit_url, form_data) kwargs = {'security_group_id': sec_group.id} table = tables.RulesTable( - req, self.security_group_rules.list(), **kwargs) + req, self.q_secgroup_rules.list(), **kwargs) handled = table.maybe_handle() self.assertEqual(strip_absolute_base(handled['location']), self.detail_url) @test.create_stubs({api.network: ('security_group_delete',)}) def test_delete_group(self): - sec_group = self.security_groups.get(name="other_group") + sec_group = self.q_secgroups.get(name="other_group") api.network.security_group_delete(IsA(http.HttpRequest), sec_group.id) self.mox.ReplayAll() form_data = {"action": "security_groups__delete__%s" % sec_group.id} req = self.factory.post(INDEX_URL, form_data) - table = tables.SecurityGroupsTable(req, self.security_groups.list()) + table = tables.SecurityGroupsTable(req, self.q_secgroups.list()) handled = table.maybe_handle() self.assertEqual(strip_absolute_base(handled['location']), INDEX_URL) @test.create_stubs({api.network: ('security_group_delete',)}) def test_delete_group_exception(self): - sec_group = self.security_groups.get(name="other_group") + sec_group = self.q_secgroups.get(name="other_group") api.network.security_group_delete( IsA(http.HttpRequest), @@ -765,7 +748,7 @@ class SecurityGroupsViewTests(test.TestCase): form_data = {"action": "security_groups__delete__%s" % sec_group.id} req = self.factory.post(INDEX_URL, form_data) - table = tables.SecurityGroupsTable(req, self.security_groups.list()) + table = tables.SecurityGroupsTable(req, self.q_secgroups.list()) handled = table.maybe_handle() self.assertEqual(strip_absolute_base(handled['location']), @@ -774,9 +757,9 @@ class SecurityGroupsViewTests(test.TestCase): @test.create_stubs({api.network: ('security_group_rule_create', 'security_group_list')}) def test_detail_add_rule_custom_protocol(self): - sec_group = self.security_groups.first() - sec_group_list = self.security_groups.list() - rule = self.security_group_rules.first() + sec_group = self.q_secgroups.first() + sec_group_list = self.q_secgroups.list() + rule = self.q_secgroup_rules.first() api.network.security_group_rule_create(IsA(http.HttpRequest), sec_group.id, 'ingress', 'IPv6', @@ -800,9 +783,9 @@ class SecurityGroupsViewTests(test.TestCase): @test.create_stubs({api.network: ('security_group_rule_create', 'security_group_list')}) def test_detail_add_rule_egress(self): - sec_group = self.security_groups.first() - sec_group_list = self.security_groups.list() - rule = self.security_group_rules.first() + sec_group = self.q_secgroups.first() + sec_group_list = self.q_secgroups.list() + rule = self.q_secgroup_rules.first() api.network.security_group_rule_create(IsA(http.HttpRequest), sec_group.id, 'egress', 'IPv4', @@ -826,9 +809,9 @@ class SecurityGroupsViewTests(test.TestCase): @test.create_stubs({api.network: ('security_group_rule_create', 'security_group_list')}) def test_detail_add_rule_egress_with_all_tcp(self): - sec_group = self.security_groups.first() - sec_group_list = self.security_groups.list() - rule = self.security_group_rules.list()[3] + sec_group = self.q_secgroups.first() + sec_group_list = self.q_secgroups.list() + rule = self.q_secgroup_rules.list()[3] api.network.security_group_rule_create(IsA(http.HttpRequest), sec_group.id, 'egress', 'IPv4', @@ -854,8 +837,8 @@ class SecurityGroupsViewTests(test.TestCase): @test.create_stubs({api.network: ('security_group_rule_create', 'security_group_list')}) def test_detail_add_rule_source_group_with_direction_ethertype(self): - sec_group = self.security_groups.first() - sec_group_list = self.security_groups.list() + sec_group = self.q_secgroups.first() + sec_group_list = self.q_secgroups.list() rule = self._get_source_group_rule() api.network.security_group_rule_create( @@ -913,7 +896,7 @@ class SecurityGroupsViewTests(test.TestCase): OPENSTACK_NEUTRON_NETWORK={'enable_ipv6': False}) @test.create_stubs({api.network: ('security_group_list',)}) def test_add_rule_cidr_with_ipv6_disabled(self): - sec_group = self.security_groups.first() + sec_group = self.q_secgroups.first() self.mox.ReplayAll() @@ -932,9 +915,9 @@ class SecurityGroupsViewTests(test.TestCase): @test.create_stubs({api.network: ('security_group_list',)}) def test_detail_add_rule_invalid_port(self): - sec_group = self.security_groups.first() - sec_group_list = self.security_groups.list() - rule = self.security_group_rules.first() + sec_group = self.q_secgroups.first() + sec_group_list = self.q_secgroups.list() + rule = self.q_secgroup_rules.first() api.network.security_group_list( IsA(http.HttpRequest)).AndReturn(sec_group_list) @@ -958,9 +941,9 @@ class SecurityGroupsViewTests(test.TestCase): @test.create_stubs({api.network: ('security_group_rule_create', 'security_group_list')}) def test_detail_add_rule_ingress_tcp_without_port(self): - sec_group = self.security_groups.first() - sec_group_list = self.security_groups.list() - rule = self.security_group_rules.list()[3] + sec_group = self.q_secgroups.first() + sec_group_list = self.q_secgroups.list() + rule = self.q_secgroup_rules.list()[3] api.network.security_group_rule_create(IsA(http.HttpRequest), sec_group.id, 'ingress', 'IPv4', @@ -985,9 +968,9 @@ class SecurityGroupsViewTests(test.TestCase): @test.create_stubs({api.network: ('security_group_rule_create', 'security_group_list')}) def test_detail_add_rule_custom_without_protocol(self): - sec_group = self.security_groups.first() - sec_group_list = self.security_groups.list() - rule = self.security_group_rules.list()[3] + sec_group = self.q_secgroups.first() + sec_group_list = self.q_secgroups.list() + rule = self.q_secgroup_rules.list()[3] api.network.security_group_rule_create(IsA(http.HttpRequest), sec_group.id, 'ingress', 'IPv4',