(Websocket) tests don't validate many responses from Zaqar

Bug #1549012 reported by Eva Balycheva
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
zaqar
Fix Released
Low
Eva Balycheva

Bug Description

The problem:

See this file:
https://github.com/openstack/zaqar/blob/master/zaqar/tests/unit/transport/websocket/v2/test_queue_lifecycle.py

You can try to modify asserted response code in "test_no_metadata" test case (and many other test cases) and the test still will pass.

Why it happens:

Let's examine common code costruction in "test_queue_lifecycle.py" file:

        send_mock = mock.patch.object(self.protocol, 'sendMessage')
        self.addCleanup(send_mock.stop)
        send_mock.start()

        req = test_utils.create_request(action, body, headers)

        def validator(resp, isBinary):
            resp = json.loads(resp)
            self.assertEqual(201, resp['headers']['status'])

        send_mock.side_effect = validator
        self.protocol.onMessage(req, False)

The code under "validator" function never executes. Because "send_mock" variable actually has "mock.mock._patch" type instead of "mock.MagicMock" type.

Eva Balycheva (ubershy)
Changed in zaqar:
assignee: nobody → Eva Balycheva (ubershy)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to zaqar (master)

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

Changed in zaqar:
status: New → In Progress
Feilong Wang (flwang)
Changed in zaqar:
importance: Undecided → Low
status: In Progress → Triaged
Changed in zaqar:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to zaqar (master)

Reviewed: https://review.openstack.org/283838
Committed: https://git.openstack.org/cgit/openstack/zaqar/commit/?id=a73ce2bf6190e538a44e1fc24b8d7ff5d04a5546
Submitter: Jenkins
Branch: master

commit a73ce2bf6190e538a44e1fc24b8d7ff5d04a5546
Author: Eva Balycheva <email address hidden>
Date: Wed Feb 24 01:26:14 2016 +0300

    Fix validation in websocket unit tests

    Validation is not performed for many Zaqar responses in these files:
    zaqar.tests.unit.transport.websocket.v2.test_queue_lifecycle.py
    zaqar.tests.unit.transport.websocket.v2.test_subscriptions.py

    For example, it's possible to modify asserted response code in
    "test_no_metadata" test case in "test_queue_lifecycle.py" and the test
    will still pass.

    This patch fixes all places where validation is not performed. Not all
    tests pass after the change, so this patch fixes these tests.

    Change-Id: I597084a16f4a796ffa74df7e299013e80d9cf6a3
    Closes-Bug: 1549012

Changed in zaqar:
status: In Progress → Fix Released
Revision history for this message
Doug Hellmann (doug-hellmann) wrote : Fix included in openstack/zaqar 2.0.0.0b3

This issue was fixed in the openstack/zaqar 2.0.0.0b3 development milestone.

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.