1339
1339
accepts exactly one instance.
1342
def setUpTwoSearchParams(self, orderby=None):
1343
# Prepare the test data for the tests in this class.
1344
params1 = self.getBugTaskSearchParams(
1345
user=None, status=BugTaskStatus.FIXCOMMITTED, orderby=orderby)
1346
subscriber = self.factory.makePerson()
1347
self.subscribeToTarget(subscriber)
1348
params2 = self.getBugTaskSearchParams(
1349
user=None, status=BugTaskStatus.NEW,
1350
structural_subscriber=subscriber, orderby=orderby)
1351
return params1, params2
1342
1353
def test_two_param_objects(self):
1343
1354
# We can pass more than one BugTaskSearchParams instance to
1344
1355
# BugTaskSet.search().
1345
params1 = self.getBugTaskSearchParams(
1346
user=None, status=BugTaskStatus.FIXCOMMITTED)
1347
subscriber = self.factory.makePerson()
1348
self.subscribeToTarget(subscriber)
1349
params2 = self.getBugTaskSearchParams(
1350
user=None, status=BugTaskStatus.NEW,
1351
structural_subscriber=subscriber)
1356
params1, params2 = self.setUpTwoSearchParams()
1352
1357
search_result = self.runSearch(params1, params2)
1353
1358
expected = self.resultValuesForBugtasks(self.bugtasks[1:])
1354
1359
self.assertEqual(expected, search_result)
1361
def test_two_param_objects_sorting_needs_extra_join(self):
1362
# If result ordering needs an extra join, the join
1363
# is added to the union of the result sets for the two
1364
# BugTaskSearchParams instances.
1365
params1, params2 = self.setUpTwoSearchParams(orderby='reporter')
1366
search_result = self.runSearch(params1, params2)
1368
def sortkey(bugtask):
1369
return bugtask.owner.name
1371
expected_bugtasks = sorted(self.bugtasks[1:], key=sortkey)
1372
expected = self.resultValuesForBugtasks(expected_bugtasks)
1373
self.assertEqual(expected, search_result)
1357
1376
class PreloadBugtaskTargets(MultipleParams):
1358
1377
"""Preload bug targets during a BugTaskSet.search() query."""