API tests not checking the return code

Bug #1275812 reported by Lucas Alvares Gomes
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ironic
Fix Released
Medium
Lucas Alvares Gomes

Bug Description

Some of our tests in the API is not checking for the return code, for e.g at ironic/test/api/test_nodes.py

    def test_remove_fail(self):
        self.assertRaises(webtest.app.AppError, self.patch_json,
                          '/nodes/%s' % self.node['uuid'],
                          [{'path': '/extra/non-existent', 'op': 'remove'}])

This test in particular is a problem, it would be expected to it to return 400 (Bad Request) since the user is removing an attribute that doesn't exist, but it's returning 500 instead because it's raising an exception which is not being captured by our patch() method. (see: http://paste.openstack.org/show/62384/)

So we have to check the return codes in the API tests.

Changed in ironic:
milestone: none → icehouse-3
importance: Undecided → Critical
importance: Critical → High
assignee: nobody → Lucas Alvares Gomes (lucasagomes)
Changed in ironic:
importance: High → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to ironic (master)

Reviewed: https://review.openstack.org/70766
Committed: https://git.openstack.org/cgit/openstack/ironic/commit/?id=969dac648d4540e2a0bc6f757172ff54f102fe5d
Submitter: Jenkins
Branch: master

commit 969dac648d4540e2a0bc6f757172ff54f102fe5d
Author: Lucas Alvares Gomes <email address hidden>
Date: Mon Feb 3 16:29:52 2014 +0000

    API tests to check for the return codes

    Some API tests were just checking whether a particular request would
    raise a generic exception (webtest.app.AppError) or not, and this is not
    enough, the API tests should make sure that the request will raise an
    exception (expect_errors=True) and also check if the HTTP code returned
    is appropriated for that error.

    The FIXME left at test_remove_fail() is going to be fixed by a following
    patch.

    Closes-Bug: #1275812
    Change-Id: I156749b3de0627c6d322192c397bbfe33919cf2d

Changed in ironic:
status: New → Fix Committed
Thierry Carrez (ttx)
Changed in ironic:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in ironic:
milestone: icehouse-3 → 2014.1
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.