Merge lp:~danwent/neutron/bug814012 into lp:neutron/diablo

Proposed by dan wendlandt
Status: Merged
Approved by: Salvatore Orlando
Approved revision: 27
Merged at revision: 27
Proposed branch: lp:~danwent/neutron/bug814012
Merge into: lp:neutron/diablo
Diff against target: 52 lines (+26/-1)
2 files modified
quantum/common/wsgi.py (+4/-1)
tests/unit/test_api.py (+22/-0)
To merge this branch: bzr merge lp:~danwent/neutron/bug814012
Reviewer Review Type Date Requested Status
Somik Behera netstack-core Approve
Salvatore Orlando Approve
Review via email: mp+69505@code.launchpad.net

Description of the change

proposed fix and unit test for: https://bugs.launchpad.net/quantum/+bug/814012

To post a comment you must log in.
Revision history for this message
Salvatore Orlando (salvatore-orlando) wrote :

Hi Dan,
Thanks for fixing this bug!
Both the fix and the unit test look good.

Just a couple of PEP8 violations to fix:
tests/unit/test_api.py:634:5: E303 too many blank lines (2)
tests/unit/test_api.py:855:1: W391 blank line at end of file

review: Needs Fixing
lp:~danwent/neutron/bug814012 updated
27. By dan wendlandt

pep8 fixes

Revision history for this message
dan wendlandt (danwent) wrote :

ah, good catch. I fixed those and pushed.

Revision history for this message
Salvatore Orlando (salvatore-orlando) wrote :

lgtm

review: Approve
Revision history for this message
Somik Behera (somikbehera) wrote :

Looks pretty good. Anything that gets us closer to passing unit tests is good :)

review: Approve (netstack-core)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'quantum/common/wsgi.py'
2--- quantum/common/wsgi.py 2011-06-30 17:13:01 +0000
3+++ quantum/common/wsgi.py 2011-07-27 17:26:27 +0000
4@@ -425,7 +425,10 @@
5 The string must be in the format of a supported MIME type.
6
7 """
8- return self.get_deserialize_handler(content_type)(datastring)
9+ try:
10+ return self.get_deserialize_handler(content_type)(datastring)
11+ except Exception:
12+ raise webob.exc.HTTPBadRequest("Could not deserialize data")
13
14 def get_deserialize_handler(self, content_type):
15 handlers = {
16
17=== modified file 'tests/unit/test_api.py'
18--- tests/unit/test_api.py 2011-07-21 15:34:58 +0000
19+++ tests/unit/test_api.py 2011-07-27 17:26:27 +0000
20@@ -614,6 +614,22 @@
21 LOG.debug("_test_delete_attachment_portnotfound - " \
22 "format:%s - END", format)
23
24+ def _test_unparsable_data(self, format):
25+ LOG.debug("_test_unparsable_data - " \
26+ " format:%s - START", format)
27+
28+ data = "this is not json or xml"
29+ method = 'POST'
30+ content_type = "application/%s" % format
31+ tenant_id = self.tenant_id
32+ path = "/tenants/%(tenant_id)s/networks.%(format)s" % locals()
33+ network_req = testlib.create_request(path, data, content_type, method)
34+ network_res = network_req.get_response(self.api)
35+ self.assertEqual(network_res.status_int, 400)
36+
37+ LOG.debug("_test_unparsable_data - " \
38+ "format:%s - END", format)
39+
40 def setUp(self):
41 options = {}
42 options['plugin_provider'] = 'quantum.plugins.SamplePlugin.FakePlugin'
43@@ -829,3 +845,9 @@
44
45 def test_delete_attachment_portnotfound_json(self):
46 self._test_delete_attachment_portnotfound('json')
47+
48+ def test_unparsable_data_xml(self):
49+ self._test_unparsable_data('xml')
50+
51+ def test_unparsable_data_json(self):
52+ self._test_unparsable_data('json')

Subscribers

People subscribed via source and target branches