comparison test/db_test_base.py @ 6399:f3fcd6628c0c

Allow '-1' (empty) in multilink expression
author Ralf Schlatterbeck <rsc@runtux.com>
date Sat, 08 May 2021 09:45:38 +0200
parents 1361e07f5b24
children 5ce995c33eee
comparison
equal deleted inserted replaced
6398:26e5c42f148c 6399:f3fcd6628c0c
1978 ae(filt(None, {kw: ['-1']}), 1978 ae(filt(None, {kw: ['-1']}),
1979 ['1']) 1979 ['1'])
1980 # '3' or empty (without explicit 'or') 1980 # '3' or empty (without explicit 'or')
1981 ae(filt(None, {kw: ['3', '-1']}), 1981 ae(filt(None, {kw: ['3', '-1']}),
1982 ['1', '2', '3']) 1982 ['1', '2', '3'])
1983 # This does not work with any of the backends currently:
1984 # '3' or empty (with explicit 'or') 1983 # '3' or empty (with explicit 'or')
1985 #ae(filt(None, {kw: ['3', '-1', '-4']}), 1984 ae(filt(None, {kw: ['3', '-1', '-4']}),
1986 # ['1', '2', '3']) 1985 ['1', '2', '3'])
1986 # empty or '3' (with explicit 'or')
1987 ae(filt(None, {kw: ['-1', '3', '-4']}),
1988 ['1', '2', '3'])
1989 # '3' and empty (should always return empty list)
1990 ae(filt(None, {kw: ['3', '-1', '-3']}),
1991 [])
1992 # empty and '3' (should always return empty list)
1993 ae(filt(None, {kw: ['3', '-1', '-3']}),
1994 [])
1995 # ('4' and empty) or ('3' or empty)
1996 ae(filt(None, {kw: ['4', '-1', '-3', '3', '-1', '-4', '-4']}),
1997 ['1', '2', '3'])
1987 1998
1988 def testFilteringRevMultilink(self): 1999 def testFilteringRevMultilink(self):
1989 ae, iiter = self.filteringSetupTransitiveSearch('user') 2000 ae, iiter = self.filteringSetupTransitiveSearch('user')
1990 ni = 'nosy_issues' 2001 ni = 'nosy_issues'
1991 self.db.issue.set('6', nosy=['3', '4', '5']) 2002 self.db.issue.set('6', nosy=['3', '4', '5'])
2045 # 7: 5 2056 # 7: 5
2046 # 8: 2057 # 8:
2047 # Retire users '9' and '10' to reduce list 2058 # Retire users '9' and '10' to reduce list
2048 self.db.user.retire ('9') 2059 self.db.user.retire ('9')
2049 self.db.user.retire ('10') 2060 self.db.user.retire ('10')
2061 self.db.commit ()
2050 for filt in iiter(): 2062 for filt in iiter():
2051 # '1' or '2' 2063 # '1' or '2'
2052 ae(filt(None, {ni: ['1', '2', '-4']}), ['4', '5']) 2064 ae(filt(None, {ni: ['1', '2', '-4']}), ['4', '5'])
2053 # '6' or '7' 2065 # '6' or '7'
2054 ae(filt(None, {ni: ['6', '7', '-4']}), ['3', '4', '5']) 2066 ae(filt(None, {ni: ['6', '7', '-4']}), ['3', '4', '5'])
2056 ae(filt(None, {ni: ['6', '7', '-3']}), ['5']) 2068 ae(filt(None, {ni: ['6', '7', '-3']}), ['5'])
2057 # '6' and not '1' 2069 # '6' and not '1'
2058 ae(filt(None, {ni: ['6', '1', '-2', '-3']}), ['3', '5']) 2070 ae(filt(None, {ni: ['6', '1', '-2', '-3']}), ['3', '5'])
2059 # '2' or empty (implicit or) 2071 # '2' or empty (implicit or)
2060 ae(filt(None, {ni: ['-1', '2']}), ['1', '2', '5', '6', '7', '8']) 2072 ae(filt(None, {ni: ['-1', '2']}), ['1', '2', '5', '6', '7', '8'])
2073 # '2' or empty (explicit or)
2074 ae(filt(None, {ni: ['-1', '2', '-4']}),
2075 ['1', '2', '5', '6', '7', '8'])
2076 # empty or '2' (explicit or)
2077 ae(filt(None, {ni: ['2', '-1', '-4']}),
2078 ['1', '2', '5', '6', '7', '8'])
2079 # '2' and empty (should always return empty list)
2080 ae(filt(None, {ni: ['-1', '2', '-3']}), [])
2081 # empty and '2' (should always return empty list)
2082 ae(filt(None, {ni: ['2', '-1', '-3']}), [])
2083 # ('4' and empty) or ('2' or empty)
2084 ae(filt(None, {ni: ['4', '-1', '-3', '2', '-1', '-4', '-4']}),
2085 ['1', '2', '5', '6', '7', '8'])
2061 2086
2062 def testFilteringMany(self): 2087 def testFilteringMany(self):
2063 ae, iiter = self.filteringSetup() 2088 ae, iiter = self.filteringSetup()
2064 for f in iiter(): 2089 for f in iiter():
2065 ae(f(None, {'nosy': '2', 'status': '1'}, ('+','id'), (None,None)), 2090 ae(f(None, {'nosy': '2', 'status': '1'}, ('+','id'), (None,None)),

Roundup Issue Tracker: http://roundup-tracker.org/