API v2 Test (test_page_reverse) Has No Assertion

Bug #1373126 reported by Ian Cordasco
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Low
Wlodzimierz Borkowski

Bug Description

In neutron/tests/unit/test_api_v2.py's APIv2TestCase.test_page_reverse, there are essentially two tests cases. There is no assertion made for the second test case here: https://github.com/openstack/neutron/blob/d3dfbf3e500a30d88f1c08664204dfc118a0154c/neutron/tests/unit/test_api_v2.py#L378..L383

Ostensibly no assertion was made because the pattern is to use assert_called_once_with, but a mock can be reset, e.g., on line 377 you could write

instance.get_networks.reset_mock()

Such that the pattern could continue to be followed.

tags: added: low-hanging-fruit unittest
Changed in neutron:
importance: Undecided → Low
status: New → Confirmed
assignee: nobody → Ilya Shakhat (shakhat)
Revision history for this message
Wlodzimierz Borkowski (borqosky) wrote :

Hi Ilya, are working on this ?

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/130944

Changed in neutron:
assignee: Ilya Shakhat (shakhat) → Wlodzimierz Borkowski (woodbor)
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

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

commit c615b7602ce50c21a8347e0c501170ee1f97d11c
Author: Wlodzimierz Borkowski <email address hidden>
Date: Sat Oct 25 14:59:24 2014 +0200

    Add assertion to test_page_reverse method

    In neutron/tests/unit/test_api_v2.APIv2TestCase.test_page_reverse
    there is no second call to test_case with 'page_reverse': 'False,
    because of use assert_called_once_with.
    In proposed change before second testcase, reset_mock is called.
    Remove also second 'instance' initialization.

    Closes-Bug: #1373126
    Change-Id: I552b7b47456a1cdfccdeb8d7853ec3395317097a

Changed in neutron:
status: In Progress → Fix Committed
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.