1843 ) |
1843 ) |
1844 |
1844 |
1845 |
1845 |
1846 def test_source_specified_0_0(self): |
1846 def test_source_specified_0_0(self): |
1847 self._test('Card X WHERE X cw_source S, S eid 1', |
1847 self._test('Card X WHERE X cw_source S, S eid 1', |
1848 [('OneFetchStep', [('Any X WHERE X is Card', |
1848 [('OneFetchStep', [('Any X WHERE X cw_source 1, X is Card', |
1849 [{'X': 'Card'}])], |
1849 [{'X': 'Card'}])], |
1850 None, None, |
1850 None, None, |
1851 [self.system],{}, []) |
1851 [self.system],{}, []) |
1852 ]) |
1852 ]) |
1853 |
1853 |
1854 def test_source_specified_0_1(self): |
1854 def test_source_specified_0_1(self): |
1855 self._test('Any X, S WHERE X is Card, X cw_source S, S eid 1', |
1855 self._test('Any X, S WHERE X is Card, X cw_source S, S eid 1', |
1856 [('OneFetchStep', [('Any X,1 WHERE X is Card', |
1856 [('OneFetchStep', [('Any X,1 WHERE X is Card, X cw_source 1', |
1857 [{'X': 'Card'}])], |
1857 [{'X': 'Card'}])], |
1858 None, None, |
1858 None, None, |
1859 [self.system],{}, []) |
1859 [self.system],{}, []) |
1860 ]) |
1860 ]) |
1861 |
1861 |
1862 def test_source_specified_1_0(self): |
1862 def test_source_specified_1_0(self): |
1863 self._test('Card X WHERE X cw_source S, S name "system"', |
1863 self._test('Card X WHERE X cw_source S, S name "system"', |
1864 [('OneFetchStep', [('Any X WHERE X is Card', |
1864 [('OneFetchStep', [('Any X WHERE X cw_source S, S name "system", X is Card', |
1865 [{'X': 'Card'}])], |
1865 [{'X': 'Card', 'S': 'CWSource'}])], |
1866 None, None, |
1866 None, None, |
1867 [self.system],{}, []) |
1867 [self.system],{}, []) |
1868 ]) |
1868 ]) |
1869 |
1869 |
1870 def test_source_specified_1_1(self): |
1870 def test_source_specified_1_1(self): |
1873 'S name SN', |
1873 'S name SN', |
1874 [{'S': 'CWSource', 'SN': 'String', 'X': 'Card'}])], |
1874 [{'S': 'CWSource', 'SN': 'String', 'X': 'Card'}])], |
1875 None, None, [self.system], {}, []) |
1875 None, None, [self.system], {}, []) |
1876 ]) |
1876 ]) |
1877 |
1877 |
|
1878 def test_source_specified_1_2(self): |
|
1879 sols = [] |
|
1880 for sol in X_ALL_SOLS: |
|
1881 sol = sol.copy() |
|
1882 sol['S'] = 'CWSource' |
|
1883 sols.append(sol) |
|
1884 self._test('Any X WHERE X cw_source S, S name "cards"', |
|
1885 [('OneFetchStep', [('Any X WHERE X cw_source S, S name "cards"', |
|
1886 sols)], |
|
1887 None, None, |
|
1888 [self.system],{}, []) |
|
1889 ]) |
|
1890 |
1878 def test_source_specified_2_0(self): |
1891 def test_source_specified_2_0(self): |
1879 self._test('Card X WHERE X cw_source S, NOT S eid 1', |
1892 self._test('Card X WHERE X cw_source S, NOT S eid 1', |
1880 [('OneFetchStep', [('Any X WHERE X is Card', |
1893 [('OneFetchStep', [('Any X WHERE X cw_source S, NOT S eid 1, X is Card, S is CWSource', |
|
1894 [{'X': 'Card', 'S': 'CWSource'}])], |
|
1895 None, None, |
|
1896 [self.cards],{}, []) |
|
1897 ]) |
|
1898 self._test('Card X WHERE NOT X cw_source S, S eid 1', |
|
1899 [('OneFetchStep', [('Any X WHERE NOT EXISTS(X cw_source 1), X is Card', |
1881 [{'X': 'Card'}])], |
1900 [{'X': 'Card'}])], |
1882 None, None, |
1901 None, None, |
1883 [self.cards],{}, []) |
1902 [self.cards],{}, []) |
1884 ]) |
1903 ]) |
1885 self._test('Card X WHERE NOT X cw_source S, S eid 1', |
1904 |
1886 [('OneFetchStep', [('Any X WHERE X is Card', |
1905 def test_source_specified_2_1(self): |
1887 [{'X': 'Card'}])], |
1906 self._test('Card X WHERE X cw_source S, NOT S name "system"', |
|
1907 [('OneFetchStep', [('Any X WHERE X cw_source S, NOT S name "system", X is Card, S is CWSource', |
|
1908 [{'X': 'Card', 'S': 'CWSource'}])], |
1888 None, None, |
1909 None, None, |
1889 [self.cards],{}, []) |
1910 [self.cards],{}, []) |
1890 ]) |
1911 ]) |
1891 |
|
1892 def test_source_specified_2_1(self): |
|
1893 self._test('Card X WHERE X cw_source S, NOT S name "system"', |
|
1894 [('OneFetchStep', [('Any X WHERE X is Card', |
|
1895 [{'X': 'Card'}])], |
|
1896 None, None, |
|
1897 [self.cards],{}, []) |
|
1898 ]) |
|
1899 self._test('Card X WHERE NOT X cw_source S, S name "system"', |
1912 self._test('Card X WHERE NOT X cw_source S, S name "system"', |
1900 [('OneFetchStep', [('Any X WHERE X is Card', |
1913 [('OneFetchStep', [('Any X WHERE NOT EXISTS(X cw_source S), S name "system", X is Card, S is CWSource', |
1901 [{'X': 'Card'}])], |
1914 [{'X': 'Card', 'S': 'CWSource'}])], |
1902 None, None, |
1915 None, None, |
1903 [self.cards],{}, []) |
1916 [self.cards],{}, []) |
1904 ]) |
1917 ]) |
1905 |
1918 |
1906 def test_source_conflict_1(self): |
1919 def test_source_conflict_1(self): |
1914 ex = self.assertRaises(BadRQLQuery, |
1927 ex = self.assertRaises(BadRQLQuery, |
1915 self._test, 'Card X WHERE X cw_source S, S name "systeme"', []) |
1928 self._test, 'Card X WHERE X cw_source S, S name "systeme"', []) |
1916 self.assertEqual(str(ex), 'source conflict for term X') |
1929 self.assertEqual(str(ex), 'source conflict for term X') |
1917 |
1930 |
1918 def test_source_conflict_3(self): |
1931 def test_source_conflict_3(self): |
1919 ex = self.assertRaises(BadRQLQuery, |
1932 self._test('CWSource X WHERE X cw_source S, S name "cards"', |
1920 self._test, 'CWSource X WHERE X cw_source S, S name "cards"', []) |
1933 [('OneFetchStep', |
1921 self.assertEqual(str(ex), 'source conflict for term X') |
1934 [(u'Any X WHERE X cw_source S, S name "cards", X is CWSource', |
|
1935 [{'S': 'CWSource', 'X': 'CWSource'}])], |
|
1936 None, None, |
|
1937 [self.system], |
|
1938 {}, [])]) |
1922 |
1939 |
1923 def test_ambigous_cross_relation_source_specified(self): |
1940 def test_ambigous_cross_relation_source_specified(self): |
1924 self.repo._type_source_cache[999999] = ('Note', 'cards', 999999) |
1941 self.repo._type_source_cache[999999] = ('Note', 'cards', 999999) |
1925 self.cards.support_relations['see_also'] = True |
1942 self.cards.support_relations['see_also'] = True |
1926 self.cards.cross_relations.add('see_also') |
1943 self.cards.cross_relations.add('see_also') |