159
160
layer = DatabaseFunctionalLayer
163
super(TestDistributionSourcePackagePickerEntrySourceAdapter,
165
flag = {'disclosure.target_picker_enhancements.enabled':'on'}
166
self.useFixture(FeatureFixture(flag))
161
168
def test_dsp_to_picker_entry(self):
162
169
dsp = self.factory.makeDistributionSourcePackage()
163
170
adapter = IPickerEntrySource(dsp)
164
171
self.assertTrue(IPickerEntrySource.providedBy(adapter))
173
def test_dsp_target_type(self):
174
dsp = self.factory.makeDistributionSourcePackage()
175
series = self.factory.makeDistroSeries(distribution=dsp.distribution)
176
release = self.factory.makeSourcePackageRelease(
178
sourcepackagename=dsp.sourcepackagename)
179
self.factory.makeSourcePackagePublishingHistory(
181
sourcepackagerelease=release)
182
[entry] = IPickerEntrySource(dsp).getPickerEntries([dsp], object())
183
self.assertEqual('package', entry.target_type)
185
def test_dsp_provides_details(self):
186
dsp = self.factory.makeDistributionSourcePackage()
187
series = self.factory.makeDistroSeries(distribution=dsp.distribution)
188
release = self.factory.makeSourcePackageRelease(
190
sourcepackagename=dsp.sourcepackagename)
191
self.factory.makeSourcePackagePublishingHistory(
193
sourcepackagerelease=release)
194
[entry] = IPickerEntrySource(dsp).getPickerEntries([dsp], object())
195
expected = "Maintainer: %s" % dsp.currentrelease.maintainer.displayname
196
self.assertEqual([expected], entry.details)
166
198
def test_dsp_provides_summary(self):
167
199
dsp = self.factory.makeDistributionSourcePackage()
168
200
series = self.factory.makeDistroSeries(distribution=dsp.distribution)
191
223
layer = DatabaseFunctionalLayer
226
super(TestProductPickerEntrySourceAdapter, self).setUp()
227
flag = {'disclosure.target_picker_enhancements.enabled':'on'}
228
self.useFixture(FeatureFixture(flag))
193
230
def test_product_to_picker_entry(self):
194
231
product = self.factory.makeProduct()
195
232
adapter = IPickerEntrySource(product)
196
233
self.assertTrue(IPickerEntrySource.providedBy(adapter))
235
def test_product_provides_alt_title(self):
236
with FeatureFixture({
237
'disclosure.target_picker_enhancements.enabled':'on'}):
238
product = self.factory.makeProduct()
239
[entry] = IPickerEntrySource(product).getPickerEntries(
241
self.assertEqual(entry.alt_title, product.name)
243
def test_product_target_type(self):
244
product = self.factory.makeProduct()
245
[entry] = IPickerEntrySource(product).getPickerEntries(
247
# We check for project, not product, because users don't see products.
248
self.assertEqual('project', entry.target_type)
250
def test_product_provides_details(self):
251
product = self.factory.makeProduct()
252
[entry] = IPickerEntrySource(product).getPickerEntries(
254
expected = "Maintainer: %s" % product.owner.displayname
255
self.assertEqual([expected], entry.details)
198
257
def test_product_provides_summary(self):
199
258
product = self.factory.makeProduct()
200
259
[entry] = IPickerEntrySource(product).getPickerEntries(
202
261
self.assertEqual(entry.description, product.summary)
264
class TestProjectGroupPickerEntrySourceAdapter(TestCaseWithFactory):
266
layer = DatabaseFunctionalLayer
269
super(TestProjectGroupPickerEntrySourceAdapter, self).setUp()
270
flag = {'disclosure.target_picker_enhancements.enabled':'on'}
271
self.useFixture(FeatureFixture(flag))
273
def test_projectgroup_to_picker_entry(self):
274
projectgroup = self.factory.makeProject()
275
adapter = IPickerEntrySource(projectgroup)
276
self.assertTrue(IPickerEntrySource.providedBy(adapter))
278
def test_projectgroup_provides_alt_title(self):
279
with FeatureFixture({
280
'disclosure.target_picker_enhancements.enabled':'on'}):
281
projectgroup = self.factory.makeProject()
282
[entry] = IPickerEntrySource(projectgroup).getPickerEntries(
283
[projectgroup], object())
284
self.assertEqual(entry.alt_title, projectgroup.name)
286
def test_projectgroup_target_type(self):
287
projectgroup = self.factory.makeProject()
288
[entry] = IPickerEntrySource(projectgroup).getPickerEntries(
289
[projectgroup], object())
290
self.assertEqual('project group', entry.target_type)
292
def test_projectgroup_provides_details(self):
293
projectgroup = self.factory.makeProject()
294
[entry] = IPickerEntrySource(projectgroup).getPickerEntries(
295
[projectgroup], object())
296
expected = "Maintainer: %s" % projectgroup.owner.displayname
297
self.assertEqual([expected], entry.details)
299
def test_projectgroup_provides_summary(self):
300
projectgroup = self.factory.makeProject()
301
[entry] = IPickerEntrySource(projectgroup).getPickerEntries(
302
[projectgroup], object())
303
self.assertEqual(entry.description, projectgroup.summary)
205
306
class TestDistributionPickerEntrySourceAdapter(TestCaseWithFactory):
207
308
layer = DatabaseFunctionalLayer
311
super(TestDistributionPickerEntrySourceAdapter, self).setUp()
312
flag = {'disclosure.target_picker_enhancements.enabled':'on'}
313
self.useFixture(FeatureFixture(flag))
209
315
def test_distribution_to_picker_entry(self):
210
316
distribution = self.factory.makeDistribution()
211
317
adapter = IPickerEntrySource(distribution)
212
318
self.assertTrue(IPickerEntrySource.providedBy(adapter))
320
def test_distribution_provides_alt_title(self):
321
with FeatureFixture({
322
'disclosure.target_picker_enhancements.enabled':'on'}):
323
distribution = self.factory.makeDistribution()
324
[entry] = IPickerEntrySource(distribution).getPickerEntries(
325
[distribution], object())
326
self.assertEqual(entry.alt_title, distribution.name)
328
def test_distribution_provides_details(self):
329
distribution = self.factory.makeDistribution()
330
series = self.factory.makeDistroSeries(
331
distribution=distribution,
332
status=SeriesStatus.CURRENT)
333
[entry] = IPickerEntrySource(distribution).getPickerEntries(
334
[distribution], object())
335
maintain_name = distribution.currentseries.owner.displayname
336
expected = "Maintainer: %s" % maintain_name
337
self.assertEqual([expected], entry.details)
214
339
def test_distribution_provides_summary(self):
215
340
distribution = self.factory.makeDistribution()
216
341
[entry] = IPickerEntrySource(distribution).getPickerEntries(
217
342
[distribution], object())
218
343
self.assertEqual(entry.description, distribution.summary)
345
def test_distribution_target_type(self):
346
distribution = self.factory.makeDistribution()
347
[entry] = IPickerEntrySource(distribution).getPickerEntries(
348
[distribution], object())
349
self.assertEqual('distribution', entry.target_type)
221
351
class TestPersonVocabulary:
222
352
implements(IHugeVocabulary)