Mercurial > p > roundup > code
comparison test/db_test_base.py @ 6394:495fd3033280
Add test for multilink expression feature
Mark as xfail because mysql doesn't work at all.
See issue2551119.
| author | Ralf Schlatterbeck <rsc@runtux.com> |
|---|---|
| date | Fri, 07 May 2021 15:05:11 +0200 |
| parents | f2c31f5ec50b |
| children | 8baf81d1cfc1 |
comparison
equal
deleted
inserted
replaced
| 6393:51a1a9b0f567 | 6394:495fd3033280 |
|---|---|
| 91 return tracker | 91 return tracker |
| 92 | 92 |
| 93 def setupSchema(db, create, module): | 93 def setupSchema(db, create, module): |
| 94 mls = module.Class(db, "mls", name=String()) | 94 mls = module.Class(db, "mls", name=String()) |
| 95 mls.setkey("name") | 95 mls.setkey("name") |
| 96 keyword = module.Class(db, "keyword", name=String()) | |
| 97 keyword.setkey("name") | |
| 96 status = module.Class(db, "status", name=String(), mls=Multilink("mls")) | 98 status = module.Class(db, "status", name=String(), mls=Multilink("mls")) |
| 97 status.setkey("name") | 99 status.setkey("name") |
| 98 priority = module.Class(db, "priority", name=String(), order=String()) | 100 priority = module.Class(db, "priority", name=String(), order=String()) |
| 99 priority.setkey("name") | 101 priority.setkey("name") |
| 100 user = module.Class(db, "user", username=String(), | 102 user = module.Class(db, "user", username=String(), |
| 113 issue = module.IssueClass(db, "issue", title=String(indexme="yes"), | 115 issue = module.IssueClass(db, "issue", title=String(indexme="yes"), |
| 114 status=Link("status"), nosy=mynosy, deadline=Date(quiet=True), | 116 status=Link("status"), nosy=mynosy, deadline=Date(quiet=True), |
| 115 foo=Interval(quiet=True, default_value=date.Interval('-1w')), | 117 foo=Interval(quiet=True, default_value=date.Interval('-1w')), |
| 116 files=Multilink("file"), assignedto=Link('user', quiet=True, | 118 files=Multilink("file"), assignedto=Link('user', quiet=True, |
| 117 rev_multilink='issues'), priority=Link('priority'), | 119 rev_multilink='issues'), priority=Link('priority'), |
| 118 spam=Multilink('msg'), feedback=Link('msg')) | 120 spam=Multilink('msg'), feedback=Link('msg'), |
| 121 keywords=Multilink('keyword')) | |
| 119 stuff = module.Class(db, "stuff", stuff=String()) | 122 stuff = module.Class(db, "stuff", stuff=String()) |
| 120 session = module.Class(db, 'session', title=String()) | 123 session = module.Class(db, 'session', title=String()) |
| 121 msg = module.FileClass(db, "msg", date=Date(), | 124 msg = module.FileClass(db, "msg", date=Date(), |
| 122 author=Link("user", do_journal='no'), files=Multilink('file'), | 125 author=Link("user", do_journal='no'), files=Multilink('file'), |
| 123 inreplyto=String(), messageid=String(), | 126 inreplyto=String(), messageid=String(), |
| 1537 | 1540 |
| 1538 def testIndexingPropertiesOnImport(self): | 1541 def testIndexingPropertiesOnImport(self): |
| 1539 # import an issue | 1542 # import an issue |
| 1540 title = 'Bzzt' | 1543 title = 'Bzzt' |
| 1541 nodeid = self.db.issue.import_list(['title', 'messages', 'files', | 1544 nodeid = self.db.issue.import_list(['title', 'messages', 'files', |
| 1542 'spam', 'nosy', 'superseder'], [repr(title), '[]', '[]', | 1545 'spam', 'nosy', 'superseder', 'keywords'], [repr(title), '[]', |
| 1543 '[]', '[]', '[]']) | 1546 '[]', '[]', '[]', '[]', '[]']) |
| 1544 self.db.commit() | 1547 self.db.commit() |
| 1545 | 1548 |
| 1546 # Content of title attribute is indexed | 1549 # Content of title attribute is indexed |
| 1547 self.assertEqual(self.db.indexer.search([title], self.db.issue), | 1550 self.assertEqual(self.db.indexer.search([title], self.db.issue), |
| 1548 {str(nodeid):{}}) | 1551 {str(nodeid):{}}) |
| 1923 for filt in iiter(): | 1926 for filt in iiter(): |
| 1924 ae(filt(None, {'nosy': '3'}, ('+','id'), (None,None)), ['4']) | 1927 ae(filt(None, {'nosy': '3'}, ('+','id'), (None,None)), ['4']) |
| 1925 ae(filt(None, {'nosy': '-1'}, ('+','id'), (None,None)), ['1', '2']) | 1928 ae(filt(None, {'nosy': '-1'}, ('+','id'), (None,None)), ['1', '2']) |
| 1926 ae(filt(None, {'nosy': ['1','2']}, ('+', 'status'), | 1929 ae(filt(None, {'nosy': ['1','2']}, ('+', 'status'), |
| 1927 ('-', 'deadline')), ['4', '3']) | 1930 ('-', 'deadline')), ['4', '3']) |
| 1931 | |
| 1932 # Currently fails on the very first test for mysql | |
| 1933 @pytest.mark.xfail | |
| 1934 def testFilteringMultilinkExpression(self): | |
| 1935 ae, iiter = self.filteringSetup() | |
| 1936 kw1 = self.db.keyword.create(name='Key1') | |
| 1937 kw2 = self.db.keyword.create(name='Key2') | |
| 1938 kw3 = self.db.keyword.create(name='Key3') | |
| 1939 kw4 = self.db.keyword.create(name='Key4') | |
| 1940 self.db.issue.set('1', keywords=[kw1, kw2]) | |
| 1941 self.db.issue.set('2', keywords=[kw1, kw3]) | |
| 1942 self.db.issue.set('3', keywords=[kw2, kw3, kw4]) | |
| 1943 self.db.issue.set('4', keywords=[kw1, kw2, kw4]) | |
| 1944 self.db.commit() | |
| 1945 kw = 'keywords' | |
| 1946 for filt in iiter(): | |
| 1947 # '1' and '2' | |
| 1948 ae(filt(None, {kw: ['1', '2', '-3']}), | |
| 1949 ['1', '4']) | |
| 1950 # ('2' and '4') and '1' | |
| 1951 ae(filt(None, {kw: ['1', '2', '4', '-3', '-3']}), | |
| 1952 ['4']) | |
| 1953 # not '4' and '3' | |
| 1954 ae(filt(None, {kw: ['3', '4', '-2', '-3']}), | |
| 1955 ['2']) | |
| 1956 # (not '4' and '3') and '2' | |
| 1957 ae(filt(None, {kw: ['2', '3', '4', '-2', '-3', '-3']}), | |
| 1958 []) | |
| 1959 # '1' or '2' without explicit 'or' | |
| 1960 ae(filt(None, {kw: ['1', '2']}), | |
| 1961 ['1', '2', '3', '4']) | |
| 1962 # '1' or '2' with explicit 'or' | |
| 1963 ae(filt(None, {kw: ['1', '2', '-4']}), | |
| 1964 ['1', '2', '3', '4']) | |
| 1965 # '3' or '4' without explicit 'or' | |
| 1966 ae(filt(None, {kw: ['3', '4']}), | |
| 1967 ['2', '3', '4']) | |
| 1968 # '3' or '4' with explicit 'or' | |
| 1969 ae(filt(None, {kw: ['3', '4', '-4']}), | |
| 1970 ['2', '3', '4']) | |
| 1971 # ('3' and '4') or ('1' and '2') | |
| 1972 ae(filt(None, {kw: ['3', '4', '-3', '1', '2', '-3', '-4']}), | |
| 1973 ['1', '3', '4']) | |
| 1974 # '2' and empty | |
| 1975 ae(filt(None, {kw: ['2', '-1', '-3']}), | |
| 1976 []) | |
| 1977 self.db.issue.set('1', keywords=[]) | |
| 1978 self.db.commit() | |
| 1979 for filt in iiter(): | |
| 1980 ae(filt(None, {kw: ['-1']}), | |
| 1981 ['1']) | |
| 1982 # These do not work with any of the backends currently | |
| 1983 # '3' or empty (with explicit 'or') | |
| 1984 #ae(filt(None, {kw: ['3', '-1', '-4']}), | |
| 1985 # ['1', '2', '3']) | |
| 1986 # '3' or empty (without explicit 'or') | |
| 1987 #ae(filt(None, {kw: ['3', '-1']}), | |
| 1988 # ['1', '2', '3']) | |
| 1928 | 1989 |
| 1929 def testFilteringRevMultilink(self): | 1990 def testFilteringRevMultilink(self): |
| 1930 ae, iiter = self.filteringSetupTransitiveSearch('user') | 1991 ae, iiter = self.filteringSetupTransitiveSearch('user') |
| 1931 ni = 'nosy_issues' | 1992 ni = 'nosy_issues' |
| 1932 self.db.issue.set('6', nosy=['3', '4', '5']) | 1993 self.db.issue.set('6', nosy=['3', '4', '5']) |
| 2681 # classhandle = tool.get_class("user") # valid class | 2742 # classhandle = tool.get_class("user") # valid class |
| 2682 # FIXME there should be some test here | 2743 # FIXME there should be some test here |
| 2683 | 2744 |
| 2684 issue_class_spec = tool.do_specification(["issue"]) | 2745 issue_class_spec = tool.do_specification(["issue"]) |
| 2685 self.assertEqual(sorted (soutput), | 2746 self.assertEqual(sorted (soutput), |
| 2686 ['assignedto: <roundup.hyperdb.Link to "user">\n', | 2747 ['assignedto: <roundup.hyperdb.Link to "user">\n', |
| 2687 'deadline: <roundup.hyperdb.Date>\n', | 2748 'deadline: <roundup.hyperdb.Date>\n', |
| 2688 'feedback: <roundup.hyperdb.Link to "msg">\n', | 2749 'feedback: <roundup.hyperdb.Link to "msg">\n', |
| 2689 'files: <roundup.hyperdb.Multilink to "file">\n', | 2750 'files: <roundup.hyperdb.Multilink to "file">\n', |
| 2690 'foo: <roundup.hyperdb.Interval>\n', | 2751 'foo: <roundup.hyperdb.Interval>\n', |
| 2691 'messages: <roundup.hyperdb.Multilink to "msg">\n', | 2752 'keywords: <roundup.hyperdb.Multilink to "keyword">\n', |
| 2692 'nosy: <roundup.hyperdb.Multilink to "user">\n', | 2753 'messages: <roundup.hyperdb.Multilink to "msg">\n', |
| 2693 'priority: <roundup.hyperdb.Link to "priority">\n', | 2754 'nosy: <roundup.hyperdb.Multilink to "user">\n', |
| 2694 'spam: <roundup.hyperdb.Multilink to "msg">\n', | 2755 'priority: <roundup.hyperdb.Link to "priority">\n', |
| 2695 'status: <roundup.hyperdb.Link to "status">\n', | 2756 'spam: <roundup.hyperdb.Multilink to "msg">\n', |
| 2696 'superseder: <roundup.hyperdb.Multilink to "issue">\n', | 2757 'status: <roundup.hyperdb.Link to "status">\n', |
| 2697 'title: <roundup.hyperdb.String>\n']) | 2758 'superseder: <roundup.hyperdb.Multilink to "issue">\n', |
| 2759 'title: <roundup.hyperdb.String>\n']) | |
| 2698 | 2760 |
| 2699 #userclassprop=tool.do_list(["mls"]) | 2761 #userclassprop=tool.do_list(["mls"]) |
| 2700 #tool.print_designator = False | 2762 #tool.print_designator = False |
| 2701 #userclassprop=tool.do_get(["realname","user1"]) | 2763 #userclassprop=tool.do_get(["realname","user1"]) |
| 2702 | 2764 |
| 2791 # force any post-init stuff to happen | 2853 # force any post-init stuff to happen |
| 2792 self.db.post_init() | 2854 self.db.post_init() |
| 2793 props = self.db.issue.getprops() | 2855 props = self.db.issue.getprops() |
| 2794 keys = sorted(props.keys()) | 2856 keys = sorted(props.keys()) |
| 2795 self.assertEqual(keys, ['activity', 'actor', 'assignedto', 'creation', | 2857 self.assertEqual(keys, ['activity', 'actor', 'assignedto', 'creation', |
| 2796 'creator', 'deadline', 'feedback', 'files', 'fixer', 'foo', 'id', 'messages', | 2858 'creator', 'deadline', 'feedback', 'files', 'fixer', 'foo', |
| 2797 'nosy', 'priority', 'spam', 'status', 'superseder', 'title']) | 2859 'id', 'keywords', 'messages', 'nosy', 'priority', 'spam', |
| 2860 'status', 'superseder', 'title']) | |
| 2798 self.assertEqual(self.db.issue.get('1', "fixer"), None) | 2861 self.assertEqual(self.db.issue.get('1', "fixer"), None) |
| 2799 | 2862 |
| 2800 def testRemoveProperty(self): | 2863 def testRemoveProperty(self): |
| 2801 self.db.issue.create(title="spam", status='1') | 2864 self.db.issue.create(title="spam", status='1') |
| 2802 self.db.commit() | 2865 self.db.commit() |
| 2804 del self.db.issue.properties['title'] | 2867 del self.db.issue.properties['title'] |
| 2805 self.db.post_init() | 2868 self.db.post_init() |
| 2806 props = self.db.issue.getprops() | 2869 props = self.db.issue.getprops() |
| 2807 keys = sorted(props.keys()) | 2870 keys = sorted(props.keys()) |
| 2808 self.assertEqual(keys, ['activity', 'actor', 'assignedto', 'creation', | 2871 self.assertEqual(keys, ['activity', 'actor', 'assignedto', 'creation', |
| 2809 'creator', 'deadline', 'feedback', 'files', 'foo', 'id', 'messages', | 2872 'creator', 'deadline', 'feedback', 'files', 'foo', 'id', |
| 2810 'nosy', 'priority', 'spam', 'status', 'superseder']) | 2873 'keywords', 'messages', 'nosy', 'priority', 'spam', 'status', |
| 2874 'superseder']) | |
| 2811 self.assertEqual(self.db.issue.list(), ['1']) | 2875 self.assertEqual(self.db.issue.list(), ['1']) |
| 2812 | 2876 |
| 2813 def testAddRemoveProperty(self): | 2877 def testAddRemoveProperty(self): |
| 2814 self.db.issue.create(title="spam", status='1') | 2878 self.db.issue.create(title="spam", status='1') |
| 2815 self.db.commit() | 2879 self.db.commit() |
| 2819 self.db.post_init() | 2883 self.db.post_init() |
| 2820 props = self.db.issue.getprops() | 2884 props = self.db.issue.getprops() |
| 2821 keys = sorted(props.keys()) | 2885 keys = sorted(props.keys()) |
| 2822 self.assertEqual(keys, ['activity', 'actor', 'assignedto', 'creation', | 2886 self.assertEqual(keys, ['activity', 'actor', 'assignedto', 'creation', |
| 2823 'creator', 'deadline', 'feedback', 'files', 'fixer', 'foo', 'id', | 2887 'creator', 'deadline', 'feedback', 'files', 'fixer', 'foo', 'id', |
| 2824 'messages', 'nosy', 'priority', 'spam', 'status', 'superseder']) | 2888 'keywords', 'messages', 'nosy', 'priority', 'spam', 'status', |
| 2889 'superseder']) | |
| 2825 self.assertEqual(self.db.issue.list(), ['1']) | 2890 self.assertEqual(self.db.issue.list(), ['1']) |
| 2826 | 2891 |
| 2827 def testNosyMail(self) : | 2892 def testNosyMail(self) : |
| 2828 """Creates one issue with two attachments, one smaller and one larger | 2893 """Creates one issue with two attachments, one smaller and one larger |
| 2829 than the set max_attachment_size. | 2894 than the set max_attachment_size. |
