quantumclient unit test: Declare less variables when possible
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
neutron |
Won't Fix
|
Undecided
|
Unassigned | ||
python-neutronclient |
Expired
|
Low
|
Unassigned |
Bug Description
In quantumclient/
def test_create_
resource = 'pool'
cmd = pool.CreatePool
name = 'my-name'
lb_method = 'round-robin'
protocol = 'http'
subnet_id = 'subnet-id'
tenant_id = 'my-tenant'
my_id = 'my-id'
args = ['--lb-method', lb_method,
-- This is a pattern in the load balancing tests in quantumclient. --
The proposal below will cover the 'simple' cases and might need some modifications in other cases
We are able to implement this code in a more "economic" way. The main point us to define 'args' as dict and derive rest of the data we need from this dict.
A working example below.
-------
def create_args(args):
position_names = args.keys()
position_values = args.values()
args_list = []
for k,v in args.iteritems():
return position_names, position_values, args_list
def main():
args = {}
args["name"] = "my-name"
args[
args["address"] = "10.0.0.2"
args[
args[
args["port"] = 80
args[
args[
position_names, position_values, args_list = create_args(args)
print position_names
print position_values
print args_list
if __name__ == "__main__":
main()
summary: |
- Having less code do the same job. + quantumclient-lbass test. Declare less variabels |
summary: |
- quantumclient-lbass test. Declare less variabels + quantumclient-lbass test. Declare less variabels when possible. |
Please refine the description of this bug to be more specific to the problem being addressed.
Also, if args is going to be defined as a dict, consider defining it in one step for brevity, e.g.:
args = dict( 'my-description ',
name='my-name',
description=
...
)