def __init__(self, date=NoFilter(), locations=NoFilter(), tags=NoFilter(), partner=NoFilter(), partner_tags=NoFilter()): self.date = date self.locations = locations self.tags = tags self.partner = partner self.partner_tags = partner_tags
def __init__(self, date=NoFilter(), locations=NoFilter(), tags=NoFilter(), data_source=NoFilter(), uri=NoFilter()): self.date = date self.locations = locations self.tags = tags self.data_source = data_source self.uri = uri
def test_composite_and_group_missing_db_field(self): """ Failing to pass a db field to a compsite and field should result in no comparison for that field. """ qs = MockQuerySet() filt = CompositeAndFilter({'a': MatchFilter('b'), 'c': NoFilter()}) result = apply_filter_to_queryset(qs, filt, {'a': 'aaa', 'b': 'bbb'}) self.assert_filters_equals([Q(aaa='b')], result.filters) result = apply_filter_to_queryset(qs, filt, {'b', 'bbb'}) self.assert_filters_equals([], result.filters)
def clone_without_state(self): """State help needs it's filter cleared before searching for help. Return a new PartnersFilter without the current state filter applied. """ new_root = dict(self.__dict__) locations = new_root.get('locations', NoFilter()) if locations: new_locations = dict(locations.field_map) if 'state' in locations.field_map: del new_locations['state'] new_root['locations'] = CompositeAndFilter(new_locations) return PartnersFilter(**new_root)
def clone_without_city(self): """City help needs it's filter cleared before searching for help. Return a new CommRecordsFilter without the current city filter applied. """ new_root = dict(self.__dict__) locations = new_root.get('locations', NoFilter()) if locations: new_locations = dict(locations.field_map) if 'city' in locations.field_map: del new_locations['city'] new_root['locations'] = CompositeAndFilter(new_locations) return CommRecordsFilter(**new_root)
def __init__(self, date_time=NoFilter(), locations=NoFilter(), tags=NoFilter(), communication_type=NoFilter(), partner=NoFilter(), contact=NoFilter(), contact_tags=NoFilter(), partner_tags=NoFilter()): self.date_time = date_time self.locations = locations self.tags = tags self.communication_type = communication_type self.partner = partner self.contact = contact self.contact_tags = contact_tags self.partner_tags = partner_tags
def test_composite_and_group_none(self): """Falsey branches of CompositeAndFilter should not compare.""" qs = MockQuerySet() filt = CompositeAndFilter({'a': MatchFilter('b'), 'c': NoFilter()}) result = apply_filter_to_queryset(qs, filt, {'a': 'aaa', 'c': 'ccc'}) self.assert_filters_equals([Q(aaa='b')], result.filters)
def test_no_filter(self): """NoFilter should evaluate falsey and not result in a comparison.""" qs = MockQuerySet() result = apply_filter_to_queryset(qs, NoFilter(), 'zz') self.assertEqual(False, bool(NoFilter())) self.assert_filters_equals([], result.filters)