Merge ~lloydwaltersj/maas:fix-yaml-dump into maas:master

Proposed by Jack Lloyd-Walters
Status: Merged
Approved by: Jack Lloyd-Walters
Approved revision: 139ad39763dcf750fbd5180fffe17b069c789a2d
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~lloydwaltersj/maas:fix-yaml-dump
Merge into: maas:master
Diff against target: 38 lines (+23/-1)
2 files modified
src/maasserver/management/commands/generate_oapi_spec.py (+1/-1)
src/maasserver/management/commands/tests/test_generate_oapi.py (+22/-0)
Reviewer Review Type Date Requested Status
Adam Collard (community) Approve
MAAS Lander Approve
Review via email: mp+428979@code.launchpad.net

Commit message

fix openapi output

Description of the change

To post a comment you must log in.
~lloydwaltersj/maas:fix-yaml-dump updated
7069477... by Jack Lloyd-Walters

remove changes from seperate branch

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

UNIT TESTS
-b fix-yaml-dump lp:~lloydwaltersj/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 706947769bc3d96d6c2d3a342cc529c881ea6939

review: Approve
Revision history for this message
Adam Collard (adam-collard) wrote :

What does this change? Why is this code better? Can you add a test that fails before and passes now?

review: Needs Fixing
~lloydwaltersj/maas:fix-yaml-dump updated
b8cd63d... by Jack Lloyd-Walters

add some tests

2e73204... by Jack Lloyd-Walters

remove pointless tests

94f9263... by Jack Lloyd-Walters

formatting and lint

671ebd5... by Jack Lloyd-Walters

formatting and lint

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

UNIT TESTS
-b fix-yaml-dump lp:~lloydwaltersj/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 671ebd5f63867f88911e6bb8a4575e16222a142f

review: Approve
Revision history for this message
Adam Collard (adam-collard) :
Revision history for this message
Jack Lloyd-Walters (lloydwaltersj) :
~lloydwaltersj/maas:fix-yaml-dump updated
139ad39... by Jack Lloyd-Walters

address comments

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

UNIT TESTS
-b fix-yaml-dump lp:~lloydwaltersj/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 139ad39763dcf750fbd5180fffe17b069c789a2d

review: Approve
Revision history for this message
Adam Collard (adam-collard) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/maasserver/management/commands/generate_oapi_spec.py b/src/maasserver/management/commands/generate_oapi_spec.py
2index 096d779..3c25a13 100644
3--- a/src/maasserver/management/commands/generate_oapi_spec.py
4+++ b/src/maasserver/management/commands/generate_oapi_spec.py
5@@ -13,4 +13,4 @@ class Command(BaseCommand):
6 def handle(self, *args, **options):
7 oapi = get_api_endpoint()
8 oapi["externalDocs"]["url"] = "https://maas.io/docs"
9- yaml.dump(oapi, self.stdout)
10+ self.stdout.write(yaml.dump(oapi))
11diff --git a/src/maasserver/management/commands/tests/test_generate_oapi.py b/src/maasserver/management/commands/tests/test_generate_oapi.py
12new file mode 100644
13index 0000000..2c49814
14--- /dev/null
15+++ b/src/maasserver/management/commands/tests/test_generate_oapi.py
16@@ -0,0 +1,22 @@
17+# Copyright 2022 Canonical Ltd. This software is licensed under the
18+# GNU Affero General Public License version 3 (see the file LICENSE).
19+
20+"""Test OpenApi commands work correctly."""
21+
22+
23+from io import StringIO
24+
25+from django.core.management import call_command
26+import yaml
27+
28+from maasserver.api.doc_oapi import get_api_endpoint
29+from maastesting.testcase import MAASTestCase
30+
31+
32+class TestOAPIDoc(MAASTestCase):
33+ def test_generate_spec(self):
34+ spec = get_api_endpoint()
35+ spec["externalDocs"]["url"] = "https://maas.io/docs"
36+ out = StringIO()
37+ call_command("generate_oapi_spec", stdout=out)
38+ self.assertEqual(yaml.dump(spec), out.getvalue())

Subscribers

People subscribed via source and target branches