def test_tags_with_any_and_all(self): # If the tags are bundled in a c.l.searchbuilder.any or .all, the # find_any_tags attribute will also be updated. bug_subscription_filter = BugSubscriptionFilter() self.assertEqual(frozenset(), bug_subscription_filter.tags) self.assertFalse(bug_subscription_filter.find_all_tags) bug_subscription_filter.tags = searchbuilder.all(u"foo") self.assertEqual(frozenset((u"foo",)), bug_subscription_filter.tags) self.assertTrue(bug_subscription_filter.find_all_tags) # Not using `searchbuilder.any` or `.all` leaves find_all_tags # unchanged. bug_subscription_filter.tags = [u"-bar"] self.assertEqual(frozenset((u"-bar",)), bug_subscription_filter.tags) self.assertTrue(bug_subscription_filter.find_all_tags) bug_subscription_filter.tags = searchbuilder.any(u"baz") self.assertEqual(frozenset((u"baz",)), bug_subscription_filter.tags) self.assertFalse(bug_subscription_filter.find_all_tags)
def test_tags_with_any_and_all(self): # If the tags are bundled in a c.l.searchbuilder.any or .all, the # find_any_tags attribute will also be updated. bug_subscription_filter = BugSubscriptionFilter() self.assertEqual(frozenset(), bug_subscription_filter.tags) self.assertFalse(bug_subscription_filter.find_all_tags) bug_subscription_filter.tags = searchbuilder.all(u"foo") self.assertEqual(frozenset((u"foo", )), bug_subscription_filter.tags) self.assertTrue(bug_subscription_filter.find_all_tags) # Not using `searchbuilder.any` or `.all` leaves find_all_tags # unchanged. bug_subscription_filter.tags = [u"-bar"] self.assertEqual(frozenset((u"-bar", )), bug_subscription_filter.tags) self.assertTrue(bug_subscription_filter.find_all_tags) bug_subscription_filter.tags = searchbuilder.any(u"baz") self.assertEqual(frozenset((u"baz", )), bug_subscription_filter.tags) self.assertFalse(bug_subscription_filter.find_all_tags)
def fromSearchForm(cls, user, order_by=('-importance', ), search_text=None, status=list(UNRESOLVED_BUGTASK_STATUSES), importance=None, assignee=None, bug_reporter=None, bug_supervisor=None, bug_commenter=None, bug_subscriber=None, owner=None, affected_user=None, affects_me=False, has_patch=None, has_cve=None, distribution=None, tags=None, tags_combinator=BugTagsSearchCombinator.ALL, omit_duplicates=True, omit_targeted=None, status_upstream=None, milestone=None, component=None, nominated_for=None, sourcepackagename=None, has_no_package=None, hardware_bus=None, hardware_vendor_id=None, hardware_product_id=None, hardware_driver_name=None, hardware_driver_package_name=None, hardware_owner_is_bug_reporter=None, hardware_owner_is_affected_by_bug=False, hardware_owner_is_subscribed_to_bug=False, hardware_is_linked_to_bug=False, linked_branches=None, linked_merge_proposals=None, linked_blueprints=None, structural_subscriber=None, modified_since=None, created_since=None, created_before=None, information_type=None): """Create and return a new instance using the parameter list.""" search_params = cls(user=user, orderby=order_by) search_params.searchtext = search_text search_params.status = cls._anyfy(status) search_params.importance = cls._anyfy(importance) search_params.assignee = assignee search_params.bug_reporter = bug_reporter search_params.bug_supervisor = bug_supervisor search_params.bug_commenter = bug_commenter search_params.subscriber = bug_subscriber search_params.owner = owner search_params.affected_user = affected_user search_params.distribution = distribution if has_patch: # Import this here to avoid circular imports from lp.bugs.interfaces.bugattachment import (BugAttachmentType) search_params.attachmenttype = BugAttachmentType.PATCH search_params.has_cve = has_cve if zope_isinstance(tags, (list, tuple)): if len(tags) > 0: if tags_combinator == BugTagsSearchCombinator.ALL: search_params.tag = all(*tags) else: search_params.tag = any(*tags) elif zope_isinstance(tags, str): search_params.tag = tags elif tags is None: pass # tags not supplied else: raise AssertionError( 'Tags can only be supplied as a list or a string.') search_params.omit_dupes = omit_duplicates search_params.omit_targeted = omit_targeted if status_upstream is not None: if 'pending_bugwatch' in status_upstream: search_params.pending_bugwatch_elsewhere = True if 'resolved_upstream' in status_upstream: search_params.resolved_upstream = True if 'open_upstream' in status_upstream: search_params.open_upstream = True if 'hide_upstream' in status_upstream: search_params.has_no_upstream_bugtask = True search_params.milestone = cls._anyfy(milestone) search_params.component = cls._anyfy(component) search_params.sourcepackagename = sourcepackagename if has_no_package: search_params.sourcepackagename = NULL search_params.nominated_for = nominated_for search_params.hardware_bus = hardware_bus search_params.hardware_vendor_id = hardware_vendor_id search_params.hardware_product_id = hardware_product_id search_params.hardware_driver_name = hardware_driver_name search_params.hardware_driver_package_name = ( hardware_driver_package_name) search_params.hardware_owner_is_bug_reporter = ( hardware_owner_is_bug_reporter) search_params.hardware_owner_is_affected_by_bug = ( hardware_owner_is_affected_by_bug) search_params.hardware_owner_is_subscribed_to_bug = ( hardware_owner_is_subscribed_to_bug) search_params.hardware_is_linked_to_bug = (hardware_is_linked_to_bug) search_params.linked_branches = linked_branches search_params.linked_merge_proposals = linked_merge_proposals search_params.linked_blueprints = linked_blueprints search_params.structural_subscriber = structural_subscriber search_params.modified_since = modified_since search_params.created_since = created_since search_params.created_before = created_before search_params.information_type = information_type return search_params
def fromSearchForm(cls, user, order_by=('-importance', ), search_text=None, status=list(UNRESOLVED_BUGTASK_STATUSES), importance=None, assignee=None, bug_reporter=None, bug_supervisor=None, bug_commenter=None, bug_subscriber=None, owner=None, affected_user=None, affects_me=False, has_patch=None, has_cve=None, distribution=None, tags=None, tags_combinator=BugTagsSearchCombinator.ALL, omit_duplicates=True, omit_targeted=None, status_upstream=None, milestone=None, component=None, nominated_for=None, sourcepackagename=None, has_no_package=None, hardware_bus=None, hardware_vendor_id=None, hardware_product_id=None, hardware_driver_name=None, hardware_driver_package_name=None, hardware_owner_is_bug_reporter=None, hardware_owner_is_affected_by_bug=False, hardware_owner_is_subscribed_to_bug=False, hardware_is_linked_to_bug=False, linked_branches=None, linked_blueprints=None, structural_subscriber=None, modified_since=None, created_since=None, created_before=None, information_type=None): """Create and return a new instance using the parameter list.""" search_params = cls(user=user, orderby=order_by) search_params.searchtext = search_text search_params.status = cls._anyfy(status) search_params.importance = cls._anyfy(importance) search_params.assignee = assignee search_params.bug_reporter = bug_reporter search_params.bug_supervisor = bug_supervisor search_params.bug_commenter = bug_commenter search_params.subscriber = bug_subscriber search_params.owner = owner search_params.affected_user = affected_user search_params.distribution = distribution if has_patch: # Import this here to avoid circular imports from lp.bugs.interfaces.bugattachment import ( BugAttachmentType) search_params.attachmenttype = BugAttachmentType.PATCH search_params.has_cve = has_cve if zope_isinstance(tags, (list, tuple)): if len(tags) > 0: if tags_combinator == BugTagsSearchCombinator.ALL: search_params.tag = all(*tags) else: search_params.tag = any(*tags) elif zope_isinstance(tags, str): search_params.tag = tags elif tags is None: pass # tags not supplied else: raise AssertionError( 'Tags can only be supplied as a list or a string.') search_params.omit_dupes = omit_duplicates search_params.omit_targeted = omit_targeted if status_upstream is not None: if 'pending_bugwatch' in status_upstream: search_params.pending_bugwatch_elsewhere = True if 'resolved_upstream' in status_upstream: search_params.resolved_upstream = True if 'open_upstream' in status_upstream: search_params.open_upstream = True if 'hide_upstream' in status_upstream: search_params.has_no_upstream_bugtask = True search_params.milestone = cls._anyfy(milestone) search_params.component = cls._anyfy(component) search_params.sourcepackagename = sourcepackagename if has_no_package: search_params.sourcepackagename = NULL search_params.nominated_for = nominated_for search_params.hardware_bus = hardware_bus search_params.hardware_vendor_id = hardware_vendor_id search_params.hardware_product_id = hardware_product_id search_params.hardware_driver_name = hardware_driver_name search_params.hardware_driver_package_name = ( hardware_driver_package_name) search_params.hardware_owner_is_bug_reporter = ( hardware_owner_is_bug_reporter) search_params.hardware_owner_is_affected_by_bug = ( hardware_owner_is_affected_by_bug) search_params.hardware_owner_is_subscribed_to_bug = ( hardware_owner_is_subscribed_to_bug) search_params.hardware_is_linked_to_bug = ( hardware_is_linked_to_bug) search_params.linked_branches = linked_branches search_params.linked_blueprints = linked_blueprints search_params.structural_subscriber = structural_subscriber search_params.modified_since = modified_since search_params.created_since = created_since search_params.created_before = created_before search_params.information_type = information_type return search_params