Merge ~cjwatson/launchpad:fix-core24 into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 9cf19fa3f9d79d87d330bb4a938734fc5388616d
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:fix-core24
Merge into: launchpad:master
Diff against target: 176 lines (+54/-41)
3 files modified
lib/lp/app/widgets/tests/test_snapbuildchannels.py (+52/-41)
lib/lp/charms/browser/tests/test_charmrecipe.py (+1/-0)
lib/lp/snappy/browser/tests/test_snap.py (+1/-0)
Reviewer Review Type Date Requested Status
Ines Almeida Approve
Review via email: mp+446189@code.launchpad.net

Commit message

Fix tests for addition of core24

Description of the change

I also further reduced the number of tests that will need attention the next time we add a core snap version.

To post a comment you must log in.
Revision history for this message
Ines Almeida (ines-almeida) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/app/widgets/tests/test_snapbuildchannels.py b/lib/lp/app/widgets/tests/test_snapbuildchannels.py
2index 107c023..0fc6ce0 100644
3--- a/lib/lp/app/widgets/tests/test_snapbuildchannels.py
4+++ b/lib/lp/app/widgets/tests/test_snapbuildchannels.py
5@@ -42,10 +42,10 @@ class TestSnapBuildChannelsWidget(TestCaseWithFactory):
6 # The subwidgets are set up and a flag is set.
7 self.widget.setUpSubWidgets()
8 self.assertTrue(self.widget._widgets_set_up)
9- self.assertIsNotNone(getattr(self.widget, "core_widget", None))
10- self.assertIsNotNone(getattr(self.widget, "core18_widget", None))
11- self.assertIsNotNone(getattr(self.widget, "core20_widget", None))
12- self.assertIsNotNone(getattr(self.widget, "core22_widget", None))
13+ for snap_name in self.field._core_snap_names:
14+ self.assertIsNotNone(
15+ getattr(self.widget, "%s_widget" % snap_name, None)
16+ )
17 self.assertIsNotNone(getattr(self.widget, "snapcraft_widget", None))
18
19 def test_setUpSubWidgets_second_call(self):
20@@ -53,40 +53,45 @@ class TestSnapBuildChannelsWidget(TestCaseWithFactory):
21 # indicate that the widgets were set up.
22 self.widget._widgets_set_up = True
23 self.widget.setUpSubWidgets()
24- self.assertIsNone(getattr(self.widget, "core_widget", None))
25- self.assertIsNone(getattr(self.widget, "core18_widget", None))
26- self.assertIsNone(getattr(self.widget, "core20_widget", None))
27- self.assertIsNone(getattr(self.widget, "core22_widget", None))
28+ for snap_name in self.field._core_snap_names:
29+ self.assertIsNone(
30+ getattr(self.widget, "%s_widget" % snap_name, None)
31+ )
32 self.assertIsNone(getattr(self.widget, "snapcraft_widget", None))
33
34 def test_setRenderedValue_None(self):
35 self.widget.setRenderedValue(None)
36- self.assertIsNone(self.widget.core_widget._getCurrentValue())
37- self.assertIsNone(self.widget.core18_widget._getCurrentValue())
38- self.assertIsNone(self.widget.core20_widget._getCurrentValue())
39- self.assertIsNone(self.widget.core22_widget._getCurrentValue())
40+ for snap_name in self.field._core_snap_names:
41+ self.assertIsNone(
42+ getattr(
43+ self.widget, "%s_widget" % snap_name
44+ )._getCurrentValue()
45+ )
46 self.assertIsNone(self.widget.snapcraft_widget._getCurrentValue())
47
48 def test_setRenderedValue_empty(self):
49 self.widget.setRenderedValue({})
50- self.assertIsNone(self.widget.core_widget._getCurrentValue())
51- self.assertIsNone(self.widget.core18_widget._getCurrentValue())
52- self.assertIsNone(self.widget.core20_widget._getCurrentValue())
53- self.assertIsNone(self.widget.core22_widget._getCurrentValue())
54+ for snap_name in self.field._core_snap_names:
55+ self.assertIsNone(
56+ getattr(
57+ self.widget, "%s_widget" % snap_name
58+ )._getCurrentValue()
59+ )
60 self.assertIsNone(self.widget.snapcraft_widget._getCurrentValue())
61
62 def test_setRenderedValue_one_channel(self):
63 self.widget.setRenderedValue({"snapcraft": "stable"})
64- self.assertIsNone(self.widget.core_widget._getCurrentValue())
65- self.assertIsNone(self.widget.core18_widget._getCurrentValue())
66- self.assertIsNone(self.widget.core20_widget._getCurrentValue())
67- self.assertIsNone(self.widget.core20_widget._getCurrentValue())
68- self.assertIsNone(self.widget.core22_widget._getCurrentValue())
69+ for snap_name in self.field._core_snap_names:
70+ self.assertIsNone(
71+ getattr(
72+ self.widget, "%s_widget" % snap_name
73+ )._getCurrentValue()
74+ )
75 self.assertEqual(
76 "stable", self.widget.snapcraft_widget._getCurrentValue()
77 )
78
79- def test_setRenderedValue_all_channels(self):
80+ def test_setRenderedValue_multiple_channels(self):
81 self.widget.setRenderedValue(
82 {
83 "core": "candidate",
84@@ -125,23 +130,33 @@ class TestSnapBuildChannelsWidget(TestCaseWithFactory):
85 # (At the moment, individual channel names are not validated, so
86 # there is no "false" counterpart to this test.)
87 form = {
88- "field.auto_build_channels.core": "",
89- "field.auto_build_channels.core18": "beta",
90- "field.auto_build_channels.core20": "edge",
91- "field.auto_build_channels.core22": "edge/feature",
92- "field.auto_build_channels.snapcraft": "stable",
93+ "field.auto_build_channels.%s" % snap_name: ""
94+ for snap_name in self.field._core_snap_names
95 }
96+ form.update(
97+ {
98+ "field.auto_build_channels.core18": "beta",
99+ "field.auto_build_channels.core20": "edge",
100+ "field.auto_build_channels.core22": "edge/feature",
101+ "field.auto_build_channels.snapcraft": "stable",
102+ }
103+ )
104 self.widget.request = LaunchpadTestRequest(form=form)
105 self.assertTrue(self.widget.hasValidInput())
106
107 def test_getInputValue(self):
108 form = {
109- "field.auto_build_channels.core": "",
110- "field.auto_build_channels.core18": "beta",
111- "field.auto_build_channels.core20": "edge",
112- "field.auto_build_channels.core22": "edge/feature",
113- "field.auto_build_channels.snapcraft": "stable",
114+ "field.auto_build_channels.%s" % snap_name: ""
115+ for snap_name in self.field._core_snap_names
116 }
117+ form.update(
118+ {
119+ "field.auto_build_channels.core18": "beta",
120+ "field.auto_build_channels.core20": "edge",
121+ "field.auto_build_channels.core22": "edge/feature",
122+ "field.auto_build_channels.snapcraft": "stable",
123+ }
124+ )
125 self.widget.request = LaunchpadTestRequest(form=form)
126 self.assertEqual(
127 {
128@@ -156,19 +171,15 @@ class TestSnapBuildChannelsWidget(TestCaseWithFactory):
129 def test_call(self):
130 # The __call__ method sets up the widgets.
131 markup = self.widget()
132- self.assertIsNotNone(self.widget.core_widget)
133- self.assertIsNotNone(self.widget.core18_widget)
134- self.assertIsNotNone(self.widget.core20_widget)
135- self.assertIsNotNone(self.widget.core22_widget)
136+ for snap_name in self.field._core_snap_names:
137+ self.assertIsNotNone(getattr(self.widget, "%s_widget" % snap_name))
138 self.assertIsNotNone(self.widget.snapcraft_widget)
139 soup = BeautifulSoup(markup)
140 fields = soup.find_all(["input"], {"id": re.compile(".*")})
141 expected_ids = [
142- "field.auto_build_channels.core",
143- "field.auto_build_channels.core18",
144- "field.auto_build_channels.core20",
145- "field.auto_build_channels.core22",
146- "field.auto_build_channels.snapcraft",
147+ "field.auto_build_channels.%s" % snap_name
148+ for snap_name in self.field._core_snap_names
149 ]
150+ expected_ids.append("field.auto_build_channels.snapcraft")
151 ids = [field["id"] for field in fields]
152 self.assertContentEqual(expected_ids, ids)
153diff --git a/lib/lp/charms/browser/tests/test_charmrecipe.py b/lib/lp/charms/browser/tests/test_charmrecipe.py
154index 60c561e..997b711 100644
155--- a/lib/lp/charms/browser/tests/test_charmrecipe.py
156+++ b/lib/lp/charms/browser/tests/test_charmrecipe.py
157@@ -1682,6 +1682,7 @@ class TestCharmRecipeRequestBuildsView(BaseTestCharmRecipeView):
158 core18
159 core20
160 core22
161+ core24
162 The channels to use for build tools when building the charm
163 recipe.
164 or
165diff --git a/lib/lp/snappy/browser/tests/test_snap.py b/lib/lp/snappy/browser/tests/test_snap.py
166index 4821790..1efc57d 100644
167--- a/lib/lp/snappy/browser/tests/test_snap.py
168+++ b/lib/lp/snappy/browser/tests/test_snap.py
169@@ -2653,6 +2653,7 @@ class TestSnapRequestBuildsView(BaseTestSnapView):
170 core18
171 core20
172 core22
173+ core24
174 snapcraft
175 snapd
176 The channels to use for build tools when building the snap

Subscribers

People subscribed via source and target branches

to status/vote changes: