Fix mock return settings in test_full_uuids_skip_port_id_lookup

Bug #1444009 reported by Dane LeBlanc
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Undecided
Dane LeBlanc

Bug Description

In the test_full_uuids_skip_port_id_lookup test in test_security_group.py, there are a couple of problems
with how a mock return value is being set for a database query.

The first problem is that in this line:
    fmock = sess_mock.query.return_value.outerjoin.return_value.filter
there is a missing '.return_value' missing between 'sess_mock' and 'query'.

The second problem is that in this line:
    fmock.return_value.all.return_value = []
the 'all.return_value' should not be used.

For reference, the query for which this mock return value is being set is in the
get_sg_ids_grouped_by_port() method in ML2's db.py:
        query = session.query(models_v2.Port,
                              sg_db.SecurityGroupPortBinding.security_group_id)
        query = query.outerjoin(sg_db.SecurityGroupPortBinding,
                                models_v2.Port.id == sg_binding_port)
        query = query.filter(or_(*or_criteria))

If the mock return values are set correctly, the last statement should yield an empty list.

Dane LeBlanc (leblancd)
Changed in neutron:
assignee: nobody → Dane LeBlanc (leblancd)
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/173399

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

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

commit 391c1b8cc1fc6f024232bef65bb5deb77357f294
Author: Dane LeBlanc <email address hidden>
Date: Tue Apr 14 11:05:40 2015 -0400

    Fix mock return settings in test_full_uuids_skip_port_id_lookup

    In the test_full_uuids_skip_port_id_lookup test in test_security_group.py,
    there are a couple of problems with how a mock return value is being set
    for a database query.

    The first problem is that in this line:
        fmock = sess_mock.query.return_value.outerjoin.return_value.filter
    there is a missing '.return_value' missing between 'sess_mock' and 'query'.

    The second problem is that in this line:
        fmock.return_value.all.return_value = []
    the 'all.return_value' should not be used.

    For reference, the query for which this mock return value is being set
    is in the get_sg_ids_grouped_by_port() method in ML2's db.py:
            query = session.query(models_v2.Port,
                                  sg_db.SecurityGroupPortBinding.security_group_id)
            query = query.outerjoin(sg_db.SecurityGroupPortBinding,
                                    models_v2.Port.id == sg_binding_port)
            query = query.filter(or_(*or_criteria))

    This patch fixes the problems mentioned above so that the query above
    returns an empty list for the test_full_uuids_skip_port_id_lookup test.

    Change-Id: I2cec2c27fcdc82557c91205d202a6ac79987e92a
    Closes-Bug: 1444009

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

Fix proposed to branch: neutron-pecan
Review: https://review.openstack.org/185072

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