Misuse of 'assert_has_calls' in unit tests

Bug #1840200 reported by Takashi NATSUME on 2019-08-15
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Medium
Takashi NATSUME
Ocata
Medium
Takashi NATSUME
Pike
Medium
Takashi NATSUME
Queens
Medium
Takashi NATSUME
Rocky
Medium
Takashi NATSUME
Stein
Medium
Takashi NATSUME

Bug Description

In unit tests, 'has_calls' method is used to assert mock calls.
But 'has_calls' does not exist in assertion methods.
It should be 'assert_has_calls'.

Fix proposed to branch: master
Review: https://review.opendev.org/676536

Changed in nova:
status: New → In Progress

Reviewed: https://review.opendev.org/676536
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=ad482e53fbb956288e73692f6bff5f74d862fe5d
Submitter: Zuul
Branch: master

commit ad482e53fbb956288e73692f6bff5f74d862fe5d
Author: Takashi NATSUME <email address hidden>
Date: Thu Aug 15 10:00:38 2019 +0900

    Fix 'has_calls' method calls in unit tests

    The 'has_calls' method does not exist in assertion methods of mock.
    Replace the 'has_calls' method with an 'assert_has_calls' method or
    an 'assert_called_once_with' method.
    Add an 'assertEqual' check before an 'assert_has_calls' method.

    Change-Id: I4b606fce473d064b9bb00213696c075cea020aaf
    Closes-Bug: #1840200

Changed in nova:
status: In Progress → Fix Released

Reviewed: https://review.opendev.org/677329
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=fa59033c40745febc26399e668ceb9911f8ec45d
Submitter: Zuul
Branch: stable/stein

commit fa59033c40745febc26399e668ceb9911f8ec45d
Author: Takashi NATSUME <email address hidden>
Date: Thu Aug 15 10:00:38 2019 +0900

    Fix 'has_calls' method calls in unit tests

    The 'has_calls' method does not exist in assertion methods of mock.
    Replace the 'has_calls' method with an 'assert_has_calls' method or
    an 'assert_called_once_with' method.
    Add an 'assertEqual' check before an 'assert_has_calls' method.

    Change-Id: I4b606fce473d064b9bb00213696c075cea020aaf
    Closes-Bug: #1840200
    (cherry picked from commit ad482e53fbb956288e73692f6bff5f74d862fe5d)

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers