56
57
derived_series=Equals(derived_series),
57
58
parent_series=Equals(parent_series),
58
initialized=Equals(True)
59
initialized=Equals(True),
60
is_overlay=Equals(False),
61
component=Equals(None),
65
def test_properties_overlay(self):
66
# Test the model properties if the DSP represents an overlay.
67
parent_series = self.factory.makeDistroSeries()
68
derived_series = self.factory.makeDistroSeries()
69
universe_component = getUtility(IComponentSet).ensure('universe')
70
dsp = self.factory.makeDistroSeriesParent(
71
derived_series=derived_series,
72
parent_series=parent_series,
75
component=universe_component,
76
pocket=PackagePublishingPocket.SECURITY,
82
derived_series=Equals(derived_series),
83
parent_series=Equals(parent_series),
84
initialized=Equals(True),
85
is_overlay=Equals(True),
86
component=Equals(universe_component),
87
pocket=Equals(PackagePublishingPocket.SECURITY),
61
90
def test_getByDerivedSeries(self):
130
159
dsp.derived_series.distribution.owner = person
131
160
with person_logged_in(person):
132
161
self.assertCanEdit(dsp)
164
class TestOverlayTree(TestCaseWithFactory):
165
"""Test the overlay tree."""
167
layer = DatabaseFunctionalLayer
169
def test_getFlattenedOverlayTree(self):
173
# ----------------------------------
177
# parent11 parent21 parent31 parent41
180
# | | type of relation:
181
# parent12 parent22 | |
184
# | no overlay overlay
187
distroseries = self.factory.makeDistroSeries()
188
parent11 = self.factory.makeDistroSeries()
189
parent12 = self.factory.makeDistroSeries()
190
parent21 = self.factory.makeDistroSeries()
191
universe_component = getUtility(IComponentSet).ensure('universe')
193
dsp_series_parent11 = self.factory.makeDistroSeriesParent(
194
derived_series=distroseries, parent_series=parent11,
195
initialized=True, is_overlay=True,
196
pocket=PackagePublishingPocket.RELEASE,
197
component=universe_component)
198
# parent11 -> parent12
199
dsp_parent11_parent12 = self.factory.makeDistroSeriesParent(
200
derived_series=parent11, parent_series=parent12,
201
initialized=True, is_overlay=True,
202
pocket=PackagePublishingPocket.RELEASE,
203
component=universe_component)
204
# parent12 -> parent13
205
self.factory.makeDistroSeriesParent(derived_series=parent12,
206
initialized=True, is_overlay=False)
208
dsp_series_parent21 = self.factory.makeDistroSeriesParent(
209
derived_series=distroseries, parent_series=parent21,
210
initialized=True, is_overlay=True,
211
pocket=PackagePublishingPocket.RELEASE,
212
component=universe_component)
213
# parent21 -> parent22
214
dsp_parent21_parent22 = self.factory.makeDistroSeriesParent(
215
derived_series=parent21, initialized=True, is_overlay=True,
216
pocket=PackagePublishingPocket.RELEASE,
217
component=universe_component)
219
self.factory.makeDistroSeriesParent(derived_series=distroseries,
220
initialized=True, is_overlay=False)
222
dsp_series_parent41 = self.factory.makeDistroSeriesParent(
223
derived_series=distroseries, initialized=True, is_overlay=True,
224
pocket=PackagePublishingPocket.RELEASE,
225
component=universe_component)
226
overlays = getUtility(
227
IDistroSeriesParentSet).getFlattenedOverlayTree(distroseries)
229
self.assertContentEqual(
230
[dsp_series_parent11, dsp_parent11_parent12, dsp_series_parent21,
231
dsp_parent21_parent22, dsp_series_parent41],
234
def test_getFlattenedOverlayTree_empty(self):
235
distroseries = self.factory.makeDistroSeries()
236
self.factory.makeDistroSeriesParent(derived_series=distroseries,
237
initialized=True, is_overlay=False)
238
overlays = getUtility(
239
IDistroSeriesParentSet).getFlattenedOverlayTree(distroseries)
241
self.assertTrue(overlays.is_empty())