← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1111192] Re: quantumclient-lbass test. Declare less variabels when possible.

 

Moving to client project since this bug applies there.

** Tags added: lbaas

** Also affects: python-quantumclient
   Importance: Undecided
       Status: New

** Changed in: quantum
       Status: New => Won't Fix

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to quantum.
https://bugs.launchpad.net/bugs/1111192

Title:
  quantumclient-lbass test. Declare less variabels when possible.

Status in Python client library for Quantum:
  New
Status in OpenStack Quantum (virtual network service):
  Won't Fix

Bug description:
  In quantumclient/tests/unit/lb/test_cli20_pool.py  (as an example) we have the following code:
  def test_create_pool_with_mandatory_params(self):
          """lb-pool-create with mandatory params only"""
          resource = 'pool'
          cmd = pool.CreatePool(test_cli20.MyApp(sys.stdout), None)
          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,
                  '--name', name,
                  '--protocol', protocol,
                  '--subnet-id', subnet_id,
                  '--tenant-id', tenant_id]
          position_names = ['admin_state_up', 'lb_method', 'name',
                            'protocol', 'subnet_id', 'tenant_id']
          position_values = [True, lb_method, name,
                             protocol, subnet_id, tenant_id]
          self._test_create_resource(resource, cmd, name, my_id, args,
                                     position_names, position_values)

   -- 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():
          args_list.append("--" + k)
          args_list.append(v)
      return position_names, position_values, args_list
  def main():
      args = {}
      args["name"] = "my-name"
      args["description"] = "my-description"
      args["address"] = "10.0.0.2"
      args["admin_state"] = False
      args["connection_limit"] = 1000
      args["port"] = 80    
      args["subnet_id"] = "subnet_id"
      args["tenant_id"] = "my-tenant"
      position_names, position_values, args_list  = create_args(args)
      print position_names
      print position_values
      print args_list    
  if __name__ == "__main__":
      main()

To manage notifications about this bug go to:
https://bugs.launchpad.net/python-quantumclient/+bug/1111192/+subscriptions