Merge ~ack/maas:1993152-pod-form-keep-tags into maas:master

Proposed by Alberto Donato
Status: Merged
Approved by: Alberto Donato
Approved revision: 202ad7487407857fa0f02d43a20fd8ad8631fd34
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~ack/maas:1993152-pod-form-keep-tags
Merge into: maas:master
Diff against target: 65 lines (+18/-3)
4 files modified
src/maasserver/api/tests/test_nodes.py (+3/-1)
src/maasserver/api/utils.py (+1/-2)
src/maasserver/forms/pods.py (+2/-0)
src/maasserver/forms/tests/test_pods.py (+12/-0)
Reviewer Review Type Date Requested Status
Jack Lloyd-Walters Approve
MAAS Lander Approve
Review via email: mp+432883@code.launchpad.net

Commit message

LP:1993152 keep current tags in PodForm when not specified in posted data

To post a comment you must log in.
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b 1993152-pod-form-keep-tags lp:~ack/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED
LOG: http://maas-ci.internal:8080/job/maas-tester/1306/consoleText
COMMIT: 202ad7487407857fa0f02d43a20fd8ad8631fd34

review: Needs Fixing
Revision history for this message
Alberto Donato (ack) wrote :

jenkins: !test

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

UNIT TESTS
-b 1993152-pod-form-keep-tags lp:~ack/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 202ad7487407857fa0f02d43a20fd8ad8631fd34

review: Approve
Revision history for this message
Jack Lloyd-Walters (lloydwaltersj) wrote :

+1

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

LANDING
-b 1993152-pod-form-keep-tags lp:~ack/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED BUILD
LOG: http://maas-ci.internal:8080/job/maas-tester/1316/consoleText

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

LANDING
-b 1993152-pod-form-keep-tags lp:~ack/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED BUILD
LOG: http://maas-ci.internal:8080/job/maas-tester/1317/consoleText

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/maasserver/api/tests/test_nodes.py b/src/maasserver/api/tests/test_nodes.py
2index e124d74..88fa7e6 100644
3--- a/src/maasserver/api/tests/test_nodes.py
4+++ b/src/maasserver/api/tests/test_nodes.py
5@@ -188,7 +188,9 @@ class RequestFixture:
6 if user is None:
7 user = factory.make_User()
8 self.user = user
9- self.GET = get_overridden_query_dict(dict, QueryDict(""), fields)
10+ self.GET = get_overridden_query_dict(
11+ dict, QueryDict(mutable=True), fields
12+ )
13
14
15 class TestFilteredNodesListFromRequest(APITestCase.ForUser):
16diff --git a/src/maasserver/api/utils.py b/src/maasserver/api/utils.py
17index 3613011..43e363b 100644
18--- a/src/maasserver/api/utils.py
19+++ b/src/maasserver/api/utils.py
20@@ -155,8 +155,7 @@ def get_overridden_query_dict(defaults, data, fields):
21 :return: The updated QueryDict.
22 :raises: :class:`django.http.QueryDict`
23 """
24- # Create a writable query dict.
25- new_data = QueryDict("").copy()
26+ new_data = QueryDict(mutable=True)
27 # If the fields are a dict of django Fields see if one is a DictCharField.
28 # DictCharField must have their values prefixed with the DictField name in
29 # the returned data or defaults don't get carried.
30diff --git a/src/maasserver/forms/pods.py b/src/maasserver/forms/pods.py
31index 05cb103..27c2970 100644
32--- a/src/maasserver/forms/pods.py
33+++ b/src/maasserver/forms/pods.py
34@@ -197,6 +197,8 @@ class PodForm(MAASModelForm):
35 if self.instance.power_type != "":
36 self.initial["type"] = self.instance.power_type
37 if instance is not None:
38+ # tags must be passed as a comma-separated value, not a list
39+ self.initial["tags"] = ",".join(instance.tags)
40 self.initial["zone"] = instance.zone.name
41 self.initial["pool"] = instance.pool.name
42 self.fields[
43diff --git a/src/maasserver/forms/tests/test_pods.py b/src/maasserver/forms/tests/test_pods.py
44index b7c4e74..9a4dd86 100644
45--- a/src/maasserver/forms/tests/test_pods.py
46+++ b/src/maasserver/forms/tests/test_pods.py
47@@ -365,6 +365,18 @@ class TestPodForm(MAASTransactionServerTestCase):
48 self.assertEqual(pod.pool, pool)
49 self.assertEqual(pod.name, new_name)
50
51+ def test_updates_existing_pod_keeps_tags(self):
52+ tags = ["foo", "bar", "pod-console-logging"]
53+ pod = factory.make_Pod(tags=tags)
54+ form = PodForm(
55+ data={"name": factory.make_name("pod")},
56+ request=self.request,
57+ instance=pod,
58+ )
59+ self.assertTrue(form.is_valid(), form._errors)
60+ pod = form.save()
61+ self.assertCountEqual(pod.tags, tags)
62+
63 def test_updates_default_storage_pool(self):
64 discovered_pod = self.make_discovered_pod()
65 default_storage_pool = random.choice(discovered_pod.storage_pools)

Subscribers

People subscribed via source and target branches