Merge ~ack/maas:1929643-only-json-emitter into maas:master

Proposed by Alberto Donato
Status: Merged
Approved by: Alberto Donato
Approved revision: 29111a629021d5d853fceab6e26a8c4e03237cef
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~ack/maas:1929643-only-json-emitter
Merge into: maas:master
Diff against target: 54 lines (+13/-2)
2 files modified
src/maasserver/api/support.py (+7/-2)
src/maasserver/api/tests/test_support.py (+6/-0)
Reviewer Review Type Date Requested Status
MAAS Lander Approve
Björn Tillenius Approve
Review via email: mp+403440@code.launchpad.net

Commit message

LP: #1929643 - only keep the JSON emitter for API responses

Currently JSON is the only supported output format for API calls

To post a comment you must log in.
Revision history for this message
Adam Collard (adam-collard) :
Revision history for this message
Björn Tillenius (bjornt) wrote :

+1

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b 1929643-only-json-emitter lp:~ack/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 29111a629021d5d853fceab6e26a8c4e03237cef

review: Approve
Revision history for this message
Alberto Donato (ack) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/maasserver/api/support.py b/src/maasserver/api/support.py
2index ba0729f..b2ed6df 100644
3--- a/src/maasserver/api/support.py
4+++ b/src/maasserver/api/support.py
5@@ -53,8 +53,7 @@ class OperationsResource(Resource):
6 return False
7
8 def __call__(self, request, *args, **kwargs):
9- upcall = super().__call__
10- response = upcall(request, *args, **kwargs)
11+ response = super().__call__(request, *args, **kwargs)
12 response["X-MAAS-API-Hash"] = get_api_description_hash()
13 return response
14
15@@ -368,6 +367,12 @@ def method_fields_reserved_fields_patch(self, handler, fields):
16
17 Emitter.method_fields = method_fields_reserved_fields_patch
18
19+# only keep the JSON emitter as it's the only format we support
20+for name in list(Emitter.EMITTERS):
21+ if name == "json":
22+ continue
23+ Emitter.unregister(name)
24+
25
26 class ModelOperationsHandlerType(OperationsHandlerType, ABCMeta):
27 """Metaclass for ModelOperationsHandler"""
28diff --git a/src/maasserver/api/tests/test_support.py b/src/maasserver/api/tests/test_support.py
29index 942d62e..fe8d411 100644
30--- a/src/maasserver/api/tests/test_support.py
31+++ b/src/maasserver/api/tests/test_support.py
32@@ -17,6 +17,7 @@ from maasserver.api.doc import get_api_description_hash
33 from maasserver.api.support import (
34 admin_method,
35 AdminRestrictedResource,
36+ Emitter,
37 OperationsHandlerMixin,
38 OperationsResource,
39 RestrictedResource,
40@@ -28,6 +29,11 @@ from maasserver.testing.testcase import MAASServerTestCase
41 from maastesting.testcase import MAASTestCase
42
43
44+class TestEmitterOnlyJSON(MAASTestCase):
45+ def test_emitters(self):
46+ self.assertItemsEqual(Emitter.EMITTERS.keys(), ["json"])
47+
48+
49 class StubHandler:
50 """A stub handler class that breaks when called."""
51
52diff --git a/src/maasserver/urls.py b/src/maasserver/urls.py
53old mode 100755
54new mode 100644

Subscribers

People subscribed via source and target branches