Wrong assertions in unittests using mock

Bug #1330391 reported by Valeriy Ponomaryov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Shared File Systems Service (Manila)
Fix Released
Medium
Valeriy Ponomaryov

Bug Description

mock objects don't have method "assert_called_once", but this is called in next unit test suites:

manila/tests/network/linux/test_interface.py
manila/tests/network/neutron/test_neutron_api.py
manila/tests/test_share_generic.py
manila/tests/test_service_instance.py
manila/tests/test_share_glusterfs.py
manila/tests/test_utils.py

So, these test modules should be rewritten properly using next methods:

assert_any_call
assert_called_once_with
assert_called_with
assert_has_calls

Changed in manila:
importance: Undecided → Medium
Changed in manila:
milestone: none → juno-2
summary: - Wrong assertions in unittests
+ Wrong assertions in unittests using mock
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to manila (master)

Reviewed: https://review.openstack.org/108193
Committed: https://git.openstack.org/cgit/stackforge/manila/commit/?id=ab02ab464572062029eae49c1e67eeb28305e8cf
Submitter: Jenkins
Branch: master

commit ab02ab464572062029eae49c1e67eeb28305e8cf
Author: Valeriy Ponomaryov <email address hidden>
Date: Sat Jul 19 12:06:09 2014 +0300

    Fix service subnet capacity within service_instance module

    Module 'service_instance' creates service_subnet per neutron_subnet,
    current mask is 29, that allows take only 3 (three) ips for service
    instances. Changed mask to 28, that allows take 11 (eleven) ips now
    by default.
    It allows us to use multibackend installation with drivers, that
    depend on this module more reliably and provides possibility to
    change this value in general.

    Changes:
    - added config option for network subnets mask with default value 28,
      instead of hardcoded 29.
    - fixed related unittests

    Change-Id: Ib58048832287a9f184317d2c92f0cc22e7f2a303
    Closes-Bug: #1341711
    Related-Bug: #1330391

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to manila (master)

Related fix proposed to branch: master
Review: https://review.openstack.org/117761

description: updated
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to manila (master)

Reviewed: https://review.openstack.org/117761
Committed: https://git.openstack.org/cgit/stackforge/manila/commit/?id=73b874bd7469ccd0483cbbc364e943a7c0e2f9ff
Submitter: Jenkins
Branch: master

commit 73b874bd7469ccd0483cbbc364e943a7c0e2f9ff
Author: Valeriy Ponomaryov <email address hidden>
Date: Fri Aug 29 05:53:59 2014 -0400

    Fix scheduled share creation with generic driver

    Generic driver uses separate module service_instance for handling of Nova VMs.
    If service m-shr starts and there are existing scheduled shares for creation,
    then concurrent issue appears between method 'do_setup', that is called once
    on start of service and 'ensure_server', that uses stuff from do_setup.

    Main error is in following:
    - "Returning exception 'GenericShareDriver' object has no attribute
      'service_instance_manager' to caller"

    Changes:
    - moved definition of attr 'service_instance_manager' to __init__ method.
    - removed attrs '_helpers' and 'share_networks_servers' from
      ServiceInstanceManager as they are redundant.
    - updated unittests according to changes.
    - used direct import of 'constants' submodule for neutron api,
      to be able to access it on driver init step.
    - replaced generic driver with common driver interface for inheritance
      by fake driver for unittests.

    Change-Id: I0fe7f097dc03eade5e0d4dfdbda0eb49588f4dde
    Closes-Bug: #1362985
    Related-Bug: #1330391

Changed in manila:
milestone: juno-2 → kilo-1
Changed in manila:
assignee: nobody → venkata anil (anil-venkata)
Changed in manila:
status: New → In Progress
Changed in manila:
assignee: venkata anil (anil-venkata) → nobody
status: In Progress → New
Changed in manila:
assignee: nobody → Valeriy Ponomaryov (vponomaryov)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to manila (master)

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

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

Reviewed: https://review.openstack.org/140116
Committed: https://git.openstack.org/cgit/openstack/manila/commit/?id=ab37c79a7e3527ee022cb7a6703c16aa0803e33a
Submitter: Jenkins
Branch: master

commit ab37c79a7e3527ee022cb7a6703c16aa0803e33a
Author: vponomaryov <email address hidden>
Date: Mon Dec 8 21:00:29 2014 +0200

    Fix wrong mock assertions in unit tests

    'mock' objects don't have method "assert_called_once", but this is called in
    following unit test suites:

    manila/tests/network/linux/test_interface.py
    manila/tests/network/neutron/test_neutron_api.py
    manila/tests/test_share_generic.py
    manila/tests/test_service_instance.py
    manila/tests/test_share_glusterfs.py
    manila/tests/test_utils.py

    Make unit tests call proper assertion methods.

    Change-Id: I96923bd345fc5129963c77dfce3555e7284eb836
    Closes-Bug: #1330391

Changed in manila:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in manila:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in manila:
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.