]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Removed duplicate keys in dicts in test
authorAlexander Ignatov <aignatov@mirantis.com>
Fri, 29 May 2015 21:49:31 +0000 (00:49 +0300)
committerAlexander Ignatov <aignatov@mirantis.com>
Sat, 30 May 2015 04:58:08 +0000 (07:58 +0300)
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

index e21813b354e2bd5b15b25ccd177f98991e69bf31..38c60777ed3b7dce2e5c1174e36b0c02749242f8 100644 (file)
@@ -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',