Misuse of 'assert_has_calls' in unit tests

Bug #1840200 reported by Takashi Natsume
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
Takashi Natsume
Ocata
In Progress
Medium
Unassigned
Pike
In Progress
Medium
Unassigned
Queens
Fix Committed
Medium
Takashi Natsume
Rocky
Fix Committed
Medium
Takashi Natsume
Stein
Fix Committed
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'.

Tags: testing
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

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

Changed in nova:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

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
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (stable/stein)

Fix proposed to branch: stable/stein
Review: https://review.opendev.org/677329

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (stable/rocky)

Fix proposed to branch: stable/rocky
Review: https://review.opendev.org/677330

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (stable/queens)

Fix proposed to branch: stable/queens
Review: https://review.opendev.org/677378

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (stable/pike)

Fix proposed to branch: stable/pike
Review: https://review.opendev.org/677379

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (stable/ocata)

Fix proposed to branch: stable/ocata
Review: https://review.opendev.org/677383

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (stable/stein)

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)

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/nova 20.0.0.0rc1

This issue was fixed in the openstack/nova 20.0.0.0rc1 release candidate.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (stable/rocky)

Reviewed: https://review.opendev.org/677330
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=8e7e54f60b0374d6439a4cedc098c5a3c97b79d9
Submitter: Zuul
Branch: stable/rocky

commit 8e7e54f60b0374d6439a4cedc098c5a3c97b79d9
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.

    Conflicts:
        nova/tests/unit/compute/test_compute_mgr.py

    NOTE(takashin): The conflict is due to not having the following change
    in stable/rocky.

        Ic062446e5c620c89aec3065b34bcdc6bf5966275

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

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/nova 19.0.3

This issue was fixed in the openstack/nova 19.0.3 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/nova 18.2.3

This issue was fixed in the openstack/nova 18.2.3 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (stable/queens)

Reviewed: https://review.opendev.org/677378
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=eca5608fe35728b12fc4d817f4a7e0a783219047
Submitter: Zuul
Branch: stable/queens

commit eca5608fe35728b12fc4d817f4a7e0a783219047
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.

    Conflicts:
        nova/tests/unit/virt/ironic/test_driver.py

    NOTE(takashin): The conflict is due to not having the following change
    in stable/queens.

        I87f085589bb663c519650f307f25d087c88bbdb1

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

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/nova 17.0.13

This issue was fixed in the openstack/nova 17.0.13 release.

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.