def test_hasevent(self): """ Test HasEvent rule. """ rule = HasEvent(['Marriage', 'before 1900', 'USA', '', 'Garner']) self.assertEqual( self.filter_with_rule(rule), set([ b'KSFKQCP4V0YXGM1LR9', b'8ZFKQC3FRSHACOJBOU', b'3XFKQCE7QUDJ99AVNV', b'OVFKQC51DX0OQUV3JB', b'9OUJQCBOHW9UEK9CNV' ]))
def get_filter(self): gid = str(self.filter_id.get_text()).strip() father = str(self.filter_father.get_text()).strip() mother = str(self.filter_mother.get_text()).strip() child = str(self.filter_child.get_text()).strip() note = str(self.filter_note.get_text()).strip() etype = self.filter_event.get_type().xml_str() rtype = self.filter_family.get_relationship().xml_str() regex = self.filter_regex.get_active() tag = self.tag.get_active() > 0 generic = self.generic.get_active() > 0 empty = not (gid or father or mother or child or note or regex or etype or rtype or tag or generic) if empty: generic_filter = None else: generic_filter = GenericFamilyFilter() if gid: rule = RegExpIdOf([gid], use_regex=regex) generic_filter.add_rule(rule) if father: rule = RegExpFatherName([father], use_regex=regex) generic_filter.add_rule(rule) if mother: rule = RegExpMotherName([mother], use_regex=regex) generic_filter.add_rule(rule) if child: rule = RegExpChildName([child], use_regex=regex) generic_filter.add_rule(rule) if etype: rule = HasEvent([etype, '', '', '', ''], use_regex=regex) generic_filter.add_rule(rule) if rtype: rule = HasRelType([rtype], use_regex=regex) generic_filter.add_rule(rule) if note: rule = HasNoteRegexp([note], use_regex=regex) generic_filter.add_rule(rule) # check the Tag if tag: model = self.tag.get_model() node = self.tag.get_active_iter() attr = model.get_value(node, 0) rule = HasTag([attr]) generic_filter.add_rule(rule) if self.generic.get_active() != 0: model = self.generic.get_model() node = self.generic.get_active_iter() obj = str(model.get_value(node, 0)) rule = MatchesFilter([obj]) generic_filter.add_rule(rule) return generic_filter