Test: Bad method has been mocked

Bug #1329701 reported by Florent Flament
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ceilometer
Fix Released
Medium
Florent Flament

Bug Description

Method `api_client.alarms` has been mocked in the following test:
https://github.com/openstack/ceilometer/blob/master/ceilometer/tests/alarm/partition/test_coordination.py#L421

However, the `api_client.alarms.list` method is called from `assigned_alarms`, called by the test:
https://github.com/openstack/ceilometer/blob/master/ceilometer/alarm/partition/coordination.py#L303

The test passes because the `api_client.alarms.list` call raises a `TypeError: "'Mock' object is not iterable"`, which is caught by the `except Exception` catchall. Instead an `Exception: Exception('Boom!',)` should be raised and caught.

In the test:
https://github.com/openstack/ceilometer/blob/master/ceilometer/tests/alarm/partition/test_coordination.py#L421
The method `api_client.alarms.list` should be mocked instead of `api_client.alarms`.

Changed in ceilometer:
assignee: nobody → Florent Flament (florent-flament-ext)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to ceilometer (master)

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

Changed in ceilometer:
status: New → In Progress
Lianhao Lu (lianhao-lu)
Changed in ceilometer:
importance: Undecided → Medium
milestone: none → juno-2
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to ceilometer (master)

Reviewed: https://review.openstack.org/99890
Committed: https://git.openstack.org/cgit/openstack/ceilometer/commit/?id=3ae3d272d41ef7a5bac6bfeb8bad430b495c2e93
Submitter: Jenkins
Branch: master

commit 3ae3d272d41ef7a5bac6bfeb8bad430b495c2e93
Author: florent <email address hidden>
Date: Fri Jun 13 09:59:09 2014 +0000

    Fix method mocked in a test

    Mock `api_client.alarms.list` instead of `api_client.alarms` in the
    tests/alarm/partition/test_coordination.py:TestCoordinate.test_assigned_alarms
    method.

    Change-Id: Id33f9854de4604b47b2a453c91a58f2dcd15e682
    Closes-Bug: #1329701

Changed in ceilometer:
status: In Progress → Fix Committed
Changed in ceilometer:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in ceilometer:
milestone: juno-2 → 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.