Merge lp:~freyes/maas/lp1610414 into lp:maas/trunk

Proposed by Felipe Reyes on 2016-08-05
Status: Merged
Approved by: Gavin Panella on 2016-08-08
Approved revision: 5225
Merged at revision: 5225
Proposed branch: lp:~freyes/maas/lp1610414
Merge into: lp:maas/trunk
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
Reviewer Review Type Date Requested Status
Gavin Panella (community) 2016-08-05 Approve on 2016-08-08
Review via email: mp+302188@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

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

This patch doesn't change the default behavior (op=update), to avoid adding it the op argument must be set to None.

[0] https://maas.ubuntu.com/docs/api.html#devices

To post a comment you must log in.
Gavin Panella (allenap) wrote :

Tip top, thanks Felipe.

review: Approve
Andres Rodriguez (andreserl) wrote :

This needs backporting right ?

On Mon, Aug 8, 2016 at 9:35 AM, Blake Rouse <email address hidden>
wrote:

> The proposal to merge lp:~freyes/maas/lp1610414 into lp:maas has been
> updated.
>
> Commit Message changed to:
>
> This MP allows to use MAASClient to submit POST calls without the `op`
> argument in the query string, this is needed to create devices.
>
> For more details, see:
> https://code.launchpad.net/~freyes/maas/lp1610414/+merge/302188
> --
> You are subscribed to branch lp:maas.
>

--
Andres Rodriguez (RoAkSoAx)
Ubuntu Server Developer
MSc. Telecom & Networking
Systems Engineer

Felipe Reyes (freyes) wrote :

On Mon, 08 Aug 2016 13:45:39 -0000
Andres Rodriguez <email address hidden> wrote:

> This needs backporting right ?

Into 2.0, yes, it does, I will do it now.

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-05 20:28:56 +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-06-22 17:03:02 +0000
17+++ src/apiclient/tests/test_maas_client.py 2016-08-05 20:28:56 +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()