Merge lp:~freyes/maas/lp1610414-2.0 into lp:maas/2.0

Proposed by Felipe Reyes
Status: Merged
Approved by: Blake Rouse
Approved revision: no longer in the source branch.
Merged at revision: 5184
Proposed branch: lp:~freyes/maas/lp1610414-2.0
Merge into: lp:maas/2.0
Diff against target: 37 lines (+15/-1)
2 files modified
src/apiclient/maas_client.py (+2/-1)
src/apiclient/tests/test_maas_client.py (+13/-0)
To merge this branch: bzr merge lp:~freyes/maas/lp1610414-2.0
Reviewer Review Type Date Requested Status
Blake Rouse (community) Approve
Review via email: mp+302346@code.launchpad.net

Commit message

This MP allows to use MAASClient to submit POST calls without the `op` argument in the query string, this is needed to create devices.

Description of the change

To post a comment you must log in.
Revision history for this message
Blake Rouse (blake-rouse) wrote :

Thanks for doing this.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/apiclient/maas_client.py'
--- src/apiclient/maas_client.py 2016-04-01 18:16:57 +0000
+++ src/apiclient/maas_client.py 2016-08-08 20:54:16 +0000
@@ -240,7 +240,8 @@
240 POST it as application/json240 POST it as application/json
241 :return: The result of the dispatch_query call on the dispatcher.241 :return: The result of the dispatch_query call on the dispatcher.
242 """242 """
243 kwargs['op'] = op243 if op:
244 kwargs['op'] = op
244 url, headers, body = self._formulate_change(245 url, headers, body = self._formulate_change(
245 path, kwargs, as_json=as_json)246 path, kwargs, as_json=as_json)
246 return self.dispatcher.dispatch_query(247 return self.dispatcher.dispatch_query(
247248
=== modified file 'src/apiclient/tests/test_maas_client.py'
--- src/apiclient/tests/test_maas_client.py 2016-05-12 19:07:37 +0000
+++ src/apiclient/tests/test_maas_client.py 2016-08-08 20:54:16 +0000
@@ -352,6 +352,19 @@
352 self.assertTrue(request["request_url"].endswith('?op=%s' % (method,)))352 self.assertTrue(request["request_url"].endswith('?op=%s' % (method,)))
353 self.assertEqual({'param': param, 'list_param': list_param}, content)353 self.assertEqual({'param': param, 'list_param': list_param}, content)
354354
355 def test_post_without_op(self):
356 path = make_path()
357 param = factory.make_string()
358 method = None
359 client = make_client()
360
361 client.post(path, method, parameter=param)
362 request = client.dispatcher.last_call
363 post, _ = parse_headers_and_body_with_django(
364 request["headers"], request["data"])
365 self.assertTrue(request["request_url"].endswith(path))
366 self.assertEqual({"parameter": [param]}, post)
367
355 def test_put_dispatches_to_resource(self):368 def test_put_dispatches_to_resource(self):
356 path = make_path()369 path = make_path()
357 client = make_client()370 client = make_client()

Subscribers

People subscribed via source and target branches

to all changes: