some tests call assert_called_once() into a mock, this function doesn't exists, and gets auto-mocked, falsely passing tests

Bug #1300265 reported by Miguel Angel Ajo on 2014-03-31
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Sahara
Fix Released
Critical
Vitalii Gridnev
Kilo
Fix Released
Undecided
Vitalii Gridnev
neutron
Medium
Jacek Świderski

Bug Description

neutron/tests/unit/agent/linux/test_async_process.py: spawn.assert_called_once()
neutron/tests/unit/agent/linux/test_async_process.py: func.assert_called_once()
neutron/tests/unit/agent/linux/test_async_process.py: mock_start.assert_called_once()
neutron/tests/unit/agent/linux/test_async_process.py: mock_kill_event.send.assert_called_once()
neutron/tests/unit/agent/linux/test_async_process.py: mock_kill_process.assert_called_once(pid)
neutron/tests/unit/test_dhcp_agent.py: log.error.assert_called_once()
neutron/tests/unit/test_dhcp_agent.py: device.route.get_gateway.assert_called_once()
neutron/tests/unit/test_dhcp_agent.py: device.route.get_gateway.assert_called_once()
neutron/tests/unit/test_dhcp_agent.py: device.route.get_gateway.assert_called_once()
neutron/tests/unit/test_dhcp_agent.py: device.route.get_gateway.assert_called_once()
neutron/tests/unit/test_dhcp_agent.py: device.route.get_gateway.assert_called_once()
neutron/tests/unit/test_dhcp_agent.py: device.route.get_gateway.assert_called_once()
neutron/tests/unit/test_dhcp_agent.py: device.route.get_gateway.assert_called_once()
neutron/tests/unit/test_post_mortem_debug.py: mock_post_mortem.assert_called_once()
neutron/tests/unit/test_linux_interface.py: log.assert_called_once()
neutron/tests/unit/test_l3_agent.py: self.send_arp.assert_called_once()
neutron/tests/unit/test_l3_agent.py: self.send_arp.assert_called_once()
neutron/tests/unit/test_l3_agent.py: self.send_arp.assert_called_once()
neutron/tests/unit/test_l3_agent.py: self.send_arp.assert_called_once()
neutron/tests/unit/test_l3_agent.py: self.send_arp.assert_called_once()
neutron/tests/unit/cisco/test_nexus_plugin.py: mock_db.assert_called_once()
neutron/tests/unit/linuxbridge/test_lb_neutron_agent.py: exec_fn.assert_called_once()
neutron/tests/unit/services/firewall/agents/l3reference/test_firewall_l3_agent.py: mock_driver_update_firewall.assert_called_once(
neutron/tests/unit/services/firewall/agents/l3reference/test_firewall_l3_agent.py: mock_driver_delete_firewall.assert_called_once(

Changed in neutron:
assignee: nobody → Miguel Angel Ajo (mangelajo)
Changed in neutron:
importance: Undecided → Medium
status: New → Triaged
tags: added: unittest
Changed in neutron:
assignee: Miguel Angel Ajo (mangelajo) → Jacek Świderski (jacek-swiderski)
status: Triaged → In Progress

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
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) on 2014-12-18
Changed in neutron:
milestone: none → kilo-1
status: Fix Committed → Fix Released
Thierry Carrez (ttx) on 2015-04-30
Changed in neutron:
milestone: kilo-1 → 2015.1.0
Changed in sahara:
status: New → Triaged
importance: Undecided → Critical
milestone: none → liberty-2
Sergey Vilgelm (sergey.vilgelm) wrote :
Changed in murano:
assignee: nobody → Sergey Vilgelm (sergey.vilgelm)
status: New → In Progress
Changed in sahara:
assignee: nobody → Vitaly Gridnev (vgridnev)
Sergey Vilgelm (sergey.vilgelm) wrote :

I think, this bug is more related: https://bugs.launchpad.net/neutron/+bug/1473369

no longer affects: murano

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

Changed in sahara:
status: Triaged → In Progress

Reviewed: https://review.openstack.org/200443
Committed: https://git.openstack.org/cgit/openstack/sahara/commit/?id=a1c95bca604f9b7de06f53d407b8407a40d4ba8b
Submitter: Jenkins
Branch: master

commit a1c95bca604f9b7de06f53d407b8407a40d4ba8b
Author: Vitaly Gridnev <email address hidden>
Date: Fri Jul 10 12:34:12 2015 +0300

    Fix failed unit tests

    We should not use assert_called_once() and assert_called() in our unit
    tests, because this cause AttributeError

    Change-Id: I9669ddac3200d282899c272cd35007b3456e71ca
    Closes-bug: 1300265

Changed in sahara:
status: In Progress → Fix Committed

Reviewed: https://review.openstack.org/200472
Committed: https://git.openstack.org/cgit/openstack/sahara/commit/?id=02d3e117a17b289e05b6917a2c9710a4d723b747
Submitter: Jenkins
Branch: stable/kilo

commit 02d3e117a17b289e05b6917a2c9710a4d723b747
Author: Vitaly Gridnev <email address hidden>
Date: Fri Jul 10 12:34:12 2015 +0300

    Fix failed unit tests

    We should not use assert_called_once() and assert_called() in our unit
    tests, because this cause AttributeError

    Change-Id: I9669ddac3200d282899c272cd35007b3456e71ca
    Closes-bug: 1300265
    (cherry picked from commit a1c95bca604f9b7de06f53d407b8407a40d4ba8b)

tags: added: in-stable-kilo
Thierry Carrez (ttx) on 2015-07-28
Changed in sahara:
status: Fix Committed → Fix Released
Thierry Carrez (ttx) on 2015-10-15
Changed in sahara:
milestone: liberty-2 → 3.0.0
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers