Use of assert_called_once() instead of assert_called_once_with()

Bug #1365751 reported by Michael Davies
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
High
Davanum Srinivas (DIMS)
cliff
Fix Released
Undecided
Michael Davies
neutron
Fix Released
Undecided
Jacek Świderski

Bug Description

mock.assert_called_once() is a noop, it doesn't test anything.

Instead it should be mock.assert_called_once_with()

This occurs in the following places:
  Nova
    nova/tests/virt/hyperv/test_ioutils.py
    nova/tests/virt/libvirt/test_driver.py
  Cliff
    cliff/tests/test_app.py
  Neutron
    neutron/tests/unit/services/l3_router/test_l3_apic_plugin.py
    neutron/tests/unit/services/loadbalancer/drivers/radware/test_plugin_driver.py
    neutron/tests/unit/test_l3_agent.py
    neutron/tests/unit/ml2/drivers/cisco/apic/test_cisco_apic_sync.py
    neutron/tests/unit/ml2/drivers/cisco/apic/test_cisco_apic_mechanism_driver.py

Michael Davies (mrda)
Changed in nova:
assignee: nobody → Michael Davies (mrda)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

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

Michael Davies (mrda)
Changed in python-cliff:
assignee: nobody → Michael Davies (mrda)
status: New → In Progress
description: updated
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to cliff (master)

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

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to cliff (master)

Reviewed: https://review.openstack.org/119252
Committed: https://git.openstack.org/cgit/openstack/cliff/commit/?id=3ec92068f0e31e20be2c10249aa837c382a037ff
Submitter: Jenkins
Branch: master

commit 3ec92068f0e31e20be2c10249aa837c382a037ff
Author: Michael Davies <email address hidden>
Date: Fri Sep 5 08:56:40 2014 +0930

    mock.assert_called_once() is not a valid method

    mock.assert_called_once() is a no-op that tests nothing. Instead
    with mock.assert_called_once_with() should be used (or use
    assertEqual(1, mock_obj.call_count) if you don't want to check
    parameters).

    Change-Id: Ib302f2e888306558535cdd3e5edf447809aee430
    Partial-Bug: #1365751

Sean Dague (sdague)
Changed in nova:
importance: Undecided → High
milestone: none → juno-rc1
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

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

Changed in nova:
assignee: Michael Davies (mrda) → Davanum Srinivas (DIMS) (dims-v)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/121726
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=45553a6dda84ef6be38150071f8bb6fa9850a53e
Submitter: Jenkins
Branch: master

commit 45553a6dda84ef6be38150071f8bb6fa9850a53e
Author: Davanum Srinivas <email address hidden>
Date: Mon Sep 15 21:23:58 2014 -0400

    mock.assert_called_once() is not a valid method

    mock.assert_called_once() is a no-op that tests nothing. Instead
    with mock.assert_called_once_with() should be used (or use
    assertEqual(1, mock_obj.call_count) if you don't want to check
    parameters).

    Add a new HACKING rule for nova to prevent assert_called_once()
    usage from creeping in.

    Closes-Bug: #1365751

    Change-Id: I1055093a1c31792b6411a3cd46c80b8bcaaf78c1

Changed in nova:
status: In Progress → Fix Committed
Changed in neutron:
assignee: nobody → Jacek Świderski (jacek-swiderski)
status: New → In Progress
description: updated
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (master)

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

Terry Howe (thowe-g)
Changed in python-cliff:
status: In Progress → Fix Released
Thierry Carrez (ttx)
Changed in nova:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: juno-rc1 → 2014.2
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on nova (master)

Change abandoned by Michael Davies (<email address hidden>) on branch: master
Review: https://review.openstack.org/119249
Reason: Abandoned after https://review.openstack.org/#/c/121726 just copied this change, including the commit message, and adding in a hacking check as per Sean Dague's suggestion on this patch.

Sigh.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

Reviewed: https://review.openstack.org/123430
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=e40c2ed58ce998fc5aba83ffae8ebefec9403c3b
Submitter: Jenkins
Branch: master

commit e40c2ed58ce998fc5aba83ffae8ebefec9403c3b
Author: Jacek Swiderski <email address hidden>
Date: Tue Sep 23 14:35:06 2014 +0200

    mock.assert_called_once() is not a valid method

    mock.assert_called_once() is a no-op that tests nothing. Instead
    mock.assert_called_once_with() should be used (or use
    assertEqual(1, mock_obj.call_count) if you don't want to check
    parameters).

    Borrowed HACKING rule from Davanum Srinivas's nova patch to
    prevent it from appearing again.

    Change-Id: Idac1d3c89c07e13c9a209663f4e557fcb7547821
    Closes-Bug: #1365751
    Closes-Bug: #1300265

Changed in neutron:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (feature/lbaasv2)

Fix proposed to branch: feature/lbaasv2
Review: https://review.openstack.org/130864

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (feature/lbaasv2)
Download full text (72.6 KiB)

Reviewed: https://review.openstack.org/130864
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=c089154a94e5872efc95eab33d3d0c9de8619fe4
Submitter: Jenkins
Branch: feature/lbaasv2

commit 62588957fbeccfb4f80eaa72bef2b86b6f08dcf8
Author: Kevin Benton <email address hidden>
Date: Wed Oct 22 13:04:03 2014 -0700

    Big Switch: Switch to TLSv1 in server manager

    Switch to TLSv1 for the connections to the backend
    controllers. The default SSLv3 is no longer considered
    secure.

    TLSv1 was chosen over .1 or .2 because the .1 and .2 weren't
    added until python 2.7.9 so TLSv1 is the only compatible option
    for py26.

    Closes-Bug: #1384487
    Change-Id: I68bd72fc4d90a102003d9ce48c47a4a6a3dd6e03

commit 17204e8f02fdad046dabdb8b31397289d72c877b
Author: OpenStack Proposal Bot <email address hidden>
Date: Wed Oct 22 06:20:15 2014 +0000

    Imported Translations from Transifex

    For more information about this automatic import see:
    https://wiki.openstack.org/wiki/Translations/Infrastructure

    Change-Id: I58db0476c810aa901463b07c42182eef0adb5114

commit d712663b99520e6d26269b0ca193527603178742
Author: Carl Baldwin <email address hidden>
Date: Mon Oct 20 21:48:42 2014 +0000

    Move disabling of metadata and ipv6_ra to _destroy_router_namespace

    I noticed that disable_ipv6_ra is called from the wrong place and that
    in some cases it was called with a bogus router_id because the code
    made an incorrect assumption about the context. In other case, it was
    never called because _destroy_router_namespace was being called
    directly. This patch moves the disabling of metadata and ipv6_ra in
    to _destroy_router_namespace to ensure they get called correctly and
    avoid duplication.

    Change-Id: Ia76a5ff4200df072b60481f2ee49286b78ece6c4
    Closes-Bug: #1383495

commit f82a5117f6f484a649eadff4b0e6be9a5a4d18bb
Author: OpenStack Proposal Bot <email address hidden>
Date: Tue Oct 21 12:11:19 2014 +0000

    Updated from global requirements

    Change-Id: Idcbd730f5c781d21ea75e7bfb15959c8f517980f

commit be6bd82d43fbcb8d1512d8eb5b7a106332364c31
Author: Angus Lees <email address hidden>
Date: Mon Aug 25 12:14:29 2014 +1000

    Remove duplicate import of constants module

    .. and enable corresponding pylint check now the only offending instance
    is fixed.

    Change-Id: I35a12ace46c872446b8c87d0aacce45e94d71bae

commit 9902400039018d77aa3034147cfb24ca4b2353f6
Author: rajeev <email address hidden>
Date: Mon Oct 13 16:25:36 2014 -0400

    Fix race condition on processing DVR floating IPs

    Fip namespace and agent gateway port can be shared by multiple dvr routers.
    This change uses a set as the control variable for these shared resources
    and ensures that Test and Set operation on the control variable are
    performed atomically so that race conditions do not occur among
    multiple threads processing floating IPs.
    Limitation: The scope of this change is limited to addressing the race
    condition described in the bug report. It may not address other issues
    such as pre-existing issue wit...

Thierry Carrez (ttx)
Changed in neutron:
milestone: none → kilo-1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in neutron:
milestone: kilo-1 → 2015.1.0
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.