From 9a73722992cc302127472a5a98ca05348db52a5f Mon Sep 17 00:00:00 2001 From: Alexander Ignatov Date: Sat, 30 May 2015 00:49:31 +0300 Subject: [PATCH] Removed duplicate keys in dicts in test Test test_create_security_group_rule_invalid_ethertype_for_prefix contained dict with duplicate keys, remote ip prefixes. Test was successful because incorrect items for tests were overwitten: '192.168.1.1/24': 'ipv4' by '192.168.1.1/24': 'IPv6' '2001:db8:1234::/48': 'ipv6' by '2001:db8:1234::/48': 'IPv4' This patch removes incorrect and useless items for tests. Also added additional item with invalid ethertype. Change-Id: I29cd2b843a7905986de13a1ecfba0cb5797ccaf8 --- neutron/tests/unit/extensions/test_securitygroup.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/neutron/tests/unit/extensions/test_securitygroup.py b/neutron/tests/unit/extensions/test_securitygroup.py index e21813b35..38c60777e 100644 --- a/neutron/tests/unit/extensions/test_securitygroup.py +++ b/neutron/tests/unit/extensions/test_securitygroup.py @@ -79,8 +79,7 @@ class SecurityGroupsTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase): 'direction': direction, 'protocol': proto, 'ethertype': ethertype, - 'tenant_id': tenant_id, - 'ethertype': ethertype}} + 'tenant_id': tenant_id}} if port_range_min: data['security_group_rule']['port_range_min'] = port_range_min @@ -454,14 +453,12 @@ class TestSecurityGroups(SecurityGroupDBTestCase): def test_create_security_group_rule_invalid_ethertype_for_prefix(self): name = 'webservers' description = 'my webservers' - test_addr = {'192.168.1.1/24': 'ipv4', '192.168.1.1/24': 'IPv6', - '2001:db8:1234::/48': 'ipv6', - '2001:db8:1234::/48': 'IPv4'} - for prefix, ether in test_addr.iteritems(): + test_addr = {'192.168.1.1/24': 'IPv6', + '2001:db8:1234::/48': 'IPv4', + '192.168.2.1/24': 'BadEthertype'} + for remote_ip_prefix, ethertype in test_addr.iteritems(): with self.security_group(name, description) as sg: sg_id = sg['security_group']['id'] - ethertype = ether - remote_ip_prefix = prefix rule = self._build_security_group_rule( sg_id, 'ingress', -- 2.45.2