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

Proposed by Felipe Reyes on 2016-08-08
Status: Merged
Approved by: Blake Rouse on 2016-08-08
Approved revision: 5184
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 2016-08-08 Approve on 2016-08-08
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.
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
1=== modified file 'src/apiclient/maas_client.py'
2--- src/apiclient/maas_client.py 2016-04-01 18:16:57 +0000
3+++ src/apiclient/maas_client.py 2016-08-08 20:54:16 +0000
4@@ -240,7 +240,8 @@
5 POST it as application/json
6 :return: The result of the dispatch_query call on the dispatcher.
7 """
8- kwargs['op'] = op
9+ if op:
10+ kwargs['op'] = op
11 url, headers, body = self._formulate_change(
12 path, kwargs, as_json=as_json)
13 return self.dispatcher.dispatch_query(
14
15=== modified file 'src/apiclient/tests/test_maas_client.py'
16--- src/apiclient/tests/test_maas_client.py 2016-05-12 19:07:37 +0000
17+++ src/apiclient/tests/test_maas_client.py 2016-08-08 20:54:16 +0000
18@@ -352,6 +352,19 @@
19 self.assertTrue(request["request_url"].endswith('?op=%s' % (method,)))
20 self.assertEqual({'param': param, 'list_param': list_param}, content)
21
22+ def test_post_without_op(self):
23+ path = make_path()
24+ param = factory.make_string()
25+ method = None
26+ client = make_client()
27+
28+ client.post(path, method, parameter=param)
29+ request = client.dispatcher.last_call
30+ post, _ = parse_headers_and_body_with_django(
31+ request["headers"], request["data"])
32+ self.assertTrue(request["request_url"].endswith(path))
33+ self.assertEqual({"parameter": [param]}, post)
34+
35 def test_put_dispatches_to_resource(self):
36 path = make_path()
37 client = make_client()

Subscribers

People subscribed via source and target branches

to all changes: