TypeError: fake_init_exception() with Neutron exceptions in the tests

Bug #1315035 reported by Julie Pichon
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Fix Released
Low
Julie Pichon

Bug Description

When a Neutron Client exception is thrown in the unit tests (usually because a call wasn't mocked properly, see e.g. bug 1284664), the following error is displayed instead of the actual error:

TypeError: fake_init_exception() takes exactly 3 arguments (1 given)

Neutron seems to prefer to declare exceptions by overriding the message attribute (and possibly adding additional information later, like a 'reason' for the failure), rather than passing the code + message around as arguments. We should handle this appropriately and display the correct message.

An example of how to reproduce:
1. Open https://git.openstack.org/cgit/openstack/horizon/tree/openstack_dashboard/dashboards/project/instances/tests.py?id=e0dc562ec8
2. Comment out the api.network key/values from the stub declarations (L56-58), and comment out the network mocks in the test (L72, L75-76)
3. Run the tests

Actual results:
4. Trace shows as TypeError: fake_init_exception() takes exactly 3 arguments (1 given)

Expected results:
4. Trace shows the actual error (here something like Connection to Neutron failed: Maximum attempts reached)

Revision history for this message
Openstack Gerrit (openstack-gerrit) wrote : Fix proposed to horizon (master)

Fix proposed to branch: master
Review: https://review.openstack.org/91586

Changed in horizon:
status: New → In Progress
Julie Pichon (jpichon)
Changed in horizon:
milestone: none → juno-1
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to horizon (master)

Reviewed: https://review.openstack.org/91586
Committed: https://git.openstack.org/cgit/openstack/horizon/commit/?id=b04d26a51a8a2673b88b5b4da473f37d9a0209b4
Submitter: Jenkins
Branch: master

commit b04d26a51a8a2673b88b5b4da473f37d9a0209b4
Author: Julie Pichon <email address hidden>
Date: Thu May 1 15:41:01 2014 +0100

    Fix fake_init_exception() to better handle Neutron exceptions

    Neutron often declares exceptions by overriding the message attribute
    and possibly adding additional information later, like a 'reason' for
    the failure, rather than passing the code and message around as
    arguments. We should handle this appropriately and display the correct
    message, instead of failing with "TypeError: fake_init_exception()
    takes exactly 3 arguments (1 given)"

    Change-Id: Ib838704cb9ca968ddfc6e3bfed3af7d0ea08f384
    Closes-Bug: #1315035

Changed in horizon:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in horizon:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in horizon:
milestone: juno-1 → 2014.2
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.