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
diff --git a/lib/lp/app/widgets/tests/test_snapbuildchannels.py b/lib/lp/app/widgets/tests/test_snapbuildchannels.py
index 107c023..0fc6ce0 100644
--- a/lib/lp/app/widgets/tests/test_snapbuildchannels.py
+++ b/lib/lp/app/widgets/tests/test_snapbuildchannels.py
@@ -42,10 +42,10 @@ class TestSnapBuildChannelsWidget(TestCaseWithFactory):
42 # The subwidgets are set up and a flag is set.42 # The subwidgets are set up and a flag is set.
43 self.widget.setUpSubWidgets()43 self.widget.setUpSubWidgets()
44 self.assertTrue(self.widget._widgets_set_up)44 self.assertTrue(self.widget._widgets_set_up)
45 self.assertIsNotNone(getattr(self.widget, "core_widget", None))45 for snap_name in self.field._core_snap_names:
46 self.assertIsNotNone(getattr(self.widget, "core18_widget", None))46 self.assertIsNotNone(
47 self.assertIsNotNone(getattr(self.widget, "core20_widget", None))47 getattr(self.widget, "%s_widget" % snap_name, None)
48 self.assertIsNotNone(getattr(self.widget, "core22_widget", None))48 )
49 self.assertIsNotNone(getattr(self.widget, "snapcraft_widget", None))49 self.assertIsNotNone(getattr(self.widget, "snapcraft_widget", None))
5050
51 def test_setUpSubWidgets_second_call(self):51 def test_setUpSubWidgets_second_call(self):
@@ -53,40 +53,45 @@ class TestSnapBuildChannelsWidget(TestCaseWithFactory):
53 # indicate that the widgets were set up.53 # indicate that the widgets were set up.
54 self.widget._widgets_set_up = True54 self.widget._widgets_set_up = True
55 self.widget.setUpSubWidgets()55 self.widget.setUpSubWidgets()
56 self.assertIsNone(getattr(self.widget, "core_widget", None))56 for snap_name in self.field._core_snap_names:
57 self.assertIsNone(getattr(self.widget, "core18_widget", None))57 self.assertIsNone(
58 self.assertIsNone(getattr(self.widget, "core20_widget", None))58 getattr(self.widget, "%s_widget" % snap_name, None)
59 self.assertIsNone(getattr(self.widget, "core22_widget", None))59 )
60 self.assertIsNone(getattr(self.widget, "snapcraft_widget", None))60 self.assertIsNone(getattr(self.widget, "snapcraft_widget", None))
6161
62 def test_setRenderedValue_None(self):62 def test_setRenderedValue_None(self):
63 self.widget.setRenderedValue(None)63 self.widget.setRenderedValue(None)
64 self.assertIsNone(self.widget.core_widget._getCurrentValue())64 for snap_name in self.field._core_snap_names:
65 self.assertIsNone(self.widget.core18_widget._getCurrentValue())65 self.assertIsNone(
66 self.assertIsNone(self.widget.core20_widget._getCurrentValue())66 getattr(
67 self.assertIsNone(self.widget.core22_widget._getCurrentValue())67 self.widget, "%s_widget" % snap_name
68 )._getCurrentValue()
69 )
68 self.assertIsNone(self.widget.snapcraft_widget._getCurrentValue())70 self.assertIsNone(self.widget.snapcraft_widget._getCurrentValue())
6971
70 def test_setRenderedValue_empty(self):72 def test_setRenderedValue_empty(self):
71 self.widget.setRenderedValue({})73 self.widget.setRenderedValue({})
72 self.assertIsNone(self.widget.core_widget._getCurrentValue())74 for snap_name in self.field._core_snap_names:
73 self.assertIsNone(self.widget.core18_widget._getCurrentValue())75 self.assertIsNone(
74 self.assertIsNone(self.widget.core20_widget._getCurrentValue())76 getattr(
75 self.assertIsNone(self.widget.core22_widget._getCurrentValue())77 self.widget, "%s_widget" % snap_name
78 )._getCurrentValue()
79 )
76 self.assertIsNone(self.widget.snapcraft_widget._getCurrentValue())80 self.assertIsNone(self.widget.snapcraft_widget._getCurrentValue())
7781
78 def test_setRenderedValue_one_channel(self):82 def test_setRenderedValue_one_channel(self):
79 self.widget.setRenderedValue({"snapcraft": "stable"})83 self.widget.setRenderedValue({"snapcraft": "stable"})
80 self.assertIsNone(self.widget.core_widget._getCurrentValue())84 for snap_name in self.field._core_snap_names:
81 self.assertIsNone(self.widget.core18_widget._getCurrentValue())85 self.assertIsNone(
82 self.assertIsNone(self.widget.core20_widget._getCurrentValue())86 getattr(
83 self.assertIsNone(self.widget.core20_widget._getCurrentValue())87 self.widget, "%s_widget" % snap_name
84 self.assertIsNone(self.widget.core22_widget._getCurrentValue())88 )._getCurrentValue()
89 )
85 self.assertEqual(90 self.assertEqual(
86 "stable", self.widget.snapcraft_widget._getCurrentValue()91 "stable", self.widget.snapcraft_widget._getCurrentValue()
87 )92 )
8893
89 def test_setRenderedValue_all_channels(self):94 def test_setRenderedValue_multiple_channels(self):
90 self.widget.setRenderedValue(95 self.widget.setRenderedValue(
91 {96 {
92 "core": "candidate",97 "core": "candidate",
@@ -125,23 +130,33 @@ class TestSnapBuildChannelsWidget(TestCaseWithFactory):
125 # (At the moment, individual channel names are not validated, so130 # (At the moment, individual channel names are not validated, so
126 # there is no "false" counterpart to this test.)131 # there is no "false" counterpart to this test.)
127 form = {132 form = {
128 "field.auto_build_channels.core": "",133 "field.auto_build_channels.%s" % snap_name: ""
129 "field.auto_build_channels.core18": "beta",134 for snap_name in self.field._core_snap_names
130 "field.auto_build_channels.core20": "edge",
131 "field.auto_build_channels.core22": "edge/feature",
132 "field.auto_build_channels.snapcraft": "stable",
133 }135 }
136 form.update(
137 {
138 "field.auto_build_channels.core18": "beta",
139 "field.auto_build_channels.core20": "edge",
140 "field.auto_build_channels.core22": "edge/feature",
141 "field.auto_build_channels.snapcraft": "stable",
142 }
143 )
134 self.widget.request = LaunchpadTestRequest(form=form)144 self.widget.request = LaunchpadTestRequest(form=form)
135 self.assertTrue(self.widget.hasValidInput())145 self.assertTrue(self.widget.hasValidInput())
136146
137 def test_getInputValue(self):147 def test_getInputValue(self):
138 form = {148 form = {
139 "field.auto_build_channels.core": "",149 "field.auto_build_channels.%s" % snap_name: ""
140 "field.auto_build_channels.core18": "beta",150 for snap_name in self.field._core_snap_names
141 "field.auto_build_channels.core20": "edge",
142 "field.auto_build_channels.core22": "edge/feature",
143 "field.auto_build_channels.snapcraft": "stable",
144 }151 }
152 form.update(
153 {
154 "field.auto_build_channels.core18": "beta",
155 "field.auto_build_channels.core20": "edge",
156 "field.auto_build_channels.core22": "edge/feature",
157 "field.auto_build_channels.snapcraft": "stable",
158 }
159 )
145 self.widget.request = LaunchpadTestRequest(form=form)160 self.widget.request = LaunchpadTestRequest(form=form)
146 self.assertEqual(161 self.assertEqual(
147 {162 {
@@ -156,19 +171,15 @@ class TestSnapBuildChannelsWidget(TestCaseWithFactory):
156 def test_call(self):171 def test_call(self):
157 # The __call__ method sets up the widgets.172 # The __call__ method sets up the widgets.
158 markup = self.widget()173 markup = self.widget()
159 self.assertIsNotNone(self.widget.core_widget)174 for snap_name in self.field._core_snap_names:
160 self.assertIsNotNone(self.widget.core18_widget)175 self.assertIsNotNone(getattr(self.widget, "%s_widget" % snap_name))
161 self.assertIsNotNone(self.widget.core20_widget)
162 self.assertIsNotNone(self.widget.core22_widget)
163 self.assertIsNotNone(self.widget.snapcraft_widget)176 self.assertIsNotNone(self.widget.snapcraft_widget)
164 soup = BeautifulSoup(markup)177 soup = BeautifulSoup(markup)
165 fields = soup.find_all(["input"], {"id": re.compile(".*")})178 fields = soup.find_all(["input"], {"id": re.compile(".*")})
166 expected_ids = [179 expected_ids = [
167 "field.auto_build_channels.core",180 "field.auto_build_channels.%s" % snap_name
168 "field.auto_build_channels.core18",181 for snap_name in self.field._core_snap_names
169 "field.auto_build_channels.core20",
170 "field.auto_build_channels.core22",
171 "field.auto_build_channels.snapcraft",
172 ]182 ]
183 expected_ids.append("field.auto_build_channels.snapcraft")
173 ids = [field["id"] for field in fields]184 ids = [field["id"] for field in fields]
174 self.assertContentEqual(expected_ids, ids)185 self.assertContentEqual(expected_ids, ids)
diff --git a/lib/lp/charms/browser/tests/test_charmrecipe.py b/lib/lp/charms/browser/tests/test_charmrecipe.py
index 60c561e..997b711 100644
--- a/lib/lp/charms/browser/tests/test_charmrecipe.py
+++ b/lib/lp/charms/browser/tests/test_charmrecipe.py
@@ -1682,6 +1682,7 @@ class TestCharmRecipeRequestBuildsView(BaseTestCharmRecipeView):
1682 core181682 core18
1683 core201683 core20
1684 core221684 core22
1685 core24
1685 The channels to use for build tools when building the charm1686 The channels to use for build tools when building the charm
1686 recipe.1687 recipe.
1687 or1688 or
diff --git a/lib/lp/snappy/browser/tests/test_snap.py b/lib/lp/snappy/browser/tests/test_snap.py
index 4821790..1efc57d 100644
--- a/lib/lp/snappy/browser/tests/test_snap.py
+++ b/lib/lp/snappy/browser/tests/test_snap.py
@@ -2653,6 +2653,7 @@ class TestSnapRequestBuildsView(BaseTestSnapView):
2653 core182653 core18
2654 core202654 core20
2655 core222655 core22
2656 core24
2656 snapcraft2657 snapcraft
2657 snapd2658 snapd
2658 The channels to use for build tools when building the snap2659 The channels to use for build tools when building the snap

Subscribers

People subscribed via source and target branches

to status/vote changes: