[openstack-dev] [horizon] test error when using horizon exception handler

Gabriel Hurley Gabriel.Hurley at nebula.com
Mon Feb 11 21:23:40 UTC 2013


It's a somewhat misleading traceback. The root issue is that a real error is being raised by a client method you forgot to stub out somewhere in your tests. Make sure that all client API calls are stubbed. When in doubt, stub out more methods but don't add any expected calls for them and see which one raises an "Unexpected Method Call" error on you.


-          Gabriel

From: Kuang-Ching Wang [mailto:kc.wang at bigswitch.com]
Sent: Monday, February 11, 2013 1:06 PM
To: OpenStack Development Mailing List
Subject: [openstack-dev] [horizon] test error when using horizon exception handler

While using the horizon exception handler in tabs.py, it works fine in actual execution but triggers the following error in unit test.  I wonder if someone knows what I have missed to do in setting up the test to cause this.

Thanks!
KC

======================================================================
ERROR: test_index_monitors (openstack_dashboard.dashboards.project.loadbalancer.tests.LoadBalancerTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/nova/gerrit/horizon/openstack_dashboard/test/helpers.py", line 74, in instance_stub_out
    return fn(self)
  File "/home/nova/gerrit/horizon/openstack_dashboard/dashboards/project/loadbalancer/tests.py", line 133, in test_index_monitors
    res = self.client.get(self.INDEX_URL, args=param)
  File "/home/nova/gerrit/horizon/.venv/local/lib/python2.7/site-packages/django/test/client.py", line 439, in get
    response = super(Client, self).get(path, data=data, **extra)
  File "/home/nova/gerrit/horizon/.venv/local/lib/python2.7/site-packages/django/test/client.py", line 244, in get
    return self.request(**r)
  File "/home/nova/gerrit/horizon/.venv/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 111, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/home/nova/gerrit/horizon/horizon/decorators.py", line 38, in dec
    return view_func(request, *args, **kwargs)
  File "/home/nova/gerrit/horizon/horizon/decorators.py", line 54, in dec
    return view_func(request, *args, **kwargs)
  File "/home/nova/gerrit/horizon/horizon/decorators.py", line 38, in dec
    return view_func(request, *args, **kwargs)
  File "/home/nova/gerrit/horizon/horizon/decorators.py", line 86, in dec
    return view_func(request, *args, **kwargs)
  File "/home/nova/gerrit/horizon/.venv/local/lib/python2.7/site-packages/django/views/generic/base.py", line 48, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/nova/gerrit/horizon/.venv/local/lib/python2.7/site-packages/django/views/generic/base.py", line 69, in dispatch
    return handler(request, *args, **kwargs)
  File "/home/nova/gerrit/horizon/horizon/tabs/views.py", line 60, in get
    context = self.get_context_data(**kwargs)
  File "/home/nova/gerrit/horizon/horizon/tabs/views.py", line 44, in get_context_data
    exceptions.handle(self.request)
  File "/home/nova/gerrit/horizon/horizon/tabs/views.py", line 42, in get_context_data
    context["tab_group"].load_tab_data()
  File "/home/nova/gerrit/horizon/horizon/tabs/base.py", line 122, in load_tab_data
    exceptions.handle(self.request)
  File "/home/nova/gerrit/horizon/horizon/tabs/base.py", line 119, in load_tab_data
    tab._data = tab.get_context_data(self.request)
  File "/home/nova/gerrit/horizon/horizon/tabs/base.py", line 450, in get_context_data
    self.load_table_data()
  File "/home/nova/gerrit/horizon/horizon/tabs/base.py", line 434, in load_table_data
    table.data = data_func()
  File "/home/nova/gerrit/horizon/openstack_dashboard/dashboards/project/loadbalancer/tabs.py", line 40, in get_poolstable_data
    _('Unable to retrieve pools list.'))
  File "/home/nova/gerrit/horizon/openstack_dashboard/dashboards/project/loadbalancer/tabs.py", line 36, in get_poolstable_data
    pools = api.quantum.pools_get(self.tab_group.request)
  File "/home/nova/gerrit/horizon/openstack_dashboard/api/quantum.py", line 539, in pools_get
    pools = quantumclient(request).list_pools().get('pools')
  File "/home/nova/gerrit/horizon/.venv/local/lib/python2.7/site-packages/python_quantumclient-2.1.40.g2bca8ee-py2.7.egg/quantumclient/v2_0/client.py", line 104, in with_params
    ret = self.function(instance, *args, **kwargs)
  File "/home/nova/gerrit/horizon/.venv/local/lib/python2.7/site-packages/python_quantumclient-2.1.40.g2bca8ee-py2.7.egg/quantumclient/v2_0/client.py", line 532, in list_pools
    return self.get(self.pools_path, params=_params)
  File "/home/nova/gerrit/horizon/.venv/local/lib/python2.7/site-packages/python_quantumclient-2.1.40.g2bca8ee-py2.7.egg/quantumclient/v2_0/client.py", line 771, in get
    headers=headers, params=params)
  File "/home/nova/gerrit/horizon/.venv/local/lib/python2.7/site-packages/python_quantumclient-2.1.40.g2bca8ee-py2.7.egg/quantumclient/v2_0/client.py", line 756, in retry_request
    headers=headers, params=params)
  File "/home/nova/gerrit/horizon/.venv/local/lib/python2.7/site-packages/python_quantumclient-2.1.40.g2bca8ee-py2.7.egg/quantumclient/v2_0/client.py", line 701, in do_request
    self._handle_fault_response(status_code, replybody)
  File "/home/nova/gerrit/horizon/.venv/local/lib/python2.7/site-packages/python_quantumclient-2.1.40.g2bca8ee-py2.7.egg/quantumclient/v2_0/client.py", line 682, in _handle_fault_response
    exception_handler_v20(status_code, des_error_body)
  File "/home/nova/gerrit/horizon/.venv/local/lib/python2.7/site-packages/python_quantumclient-2.1.40.g2bca8ee-py2.7.egg/quantumclient/v2_0/client.py", line 84, in exception_handler_v20
    message=message)
TypeError: fake_init_exception() takes exactly 3 arguments (2 given)


--
Kuang-Ching (KC) Wang
Member of Technical Staff -- Big Switch Networks -- http://www.bigswitch.com/






-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20130211/30729671/attachment.html>


More information about the OpenStack-dev mailing list