]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Make '_create_router' function handle Boolean kwargs correctly
authorBob Melander <bob.melander@gmail.com>
Sat, 27 Jun 2015 17:14:19 +0000 (19:14 +0200)
committerBob Melander <bob.melander@gmail.com>
Sun, 28 Jun 2015 01:20:43 +0000 (03:20 +0200)
The function allows arbitrary kw arguments to be specificed.
Those kw arguments whose key is specified in the function
parameter 'arg_list' are then passed in the create router REST
API call.

The code line that checks if a kw argument key is included in
'arg_list' does not work with Boolean kw arguments. Nor does it
work with None kw argument values. This is a limitation as
tests in inheriting classes may need such kw arguments.

This patch fixes the faulty 'if' clause so that it simply
checks that the kw argument key is in 'arg_list'. This makes it
support Boolean kw arguments and kw arguments with value None.

Closes-Bug: #1482108
Change-Id: I5618dc4d5c803c7614dd1f579db3c79928007fb6

neutron/tests/unit/extensions/test_l3.py

index 143c34869e72936f7a19e06839a52080544a5853..2583b47d2ef22706c22eb4f518fd55dcfef5aee7 100644 (file)
@@ -326,7 +326,7 @@ class L3NatTestCaseMixin(object):
             data['router']['admin_state_up'] = admin_state_up
         for arg in (('admin_state_up', 'tenant_id') + (arg_list or ())):
             # Arg must be present and not empty
-            if kwargs.get(arg):
+            if arg in kwargs:
                 data['router'][arg] = kwargs[arg]
         router_req = self.new_create_request('routers', data, fmt)
         if set_context and tenant_id: