server/test/unittest_msplanner.py
branchstable
changeset 6796 e70ca9abfc51
parent 6794 140d42b41b31
child 6943 406a41c25e13
equal deleted inserted replaced
6795:f29d24c3d687 6796:e70ca9abfc51
    13 # FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
    13 # FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
    14 # details.
    14 # details.
    15 #
    15 #
    16 # You should have received a copy of the GNU Lesser General Public License along
    16 # You should have received a copy of the GNU Lesser General Public License along
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
       
    18 """unit tests for module cubicweb.server.msplanner"""
       
    19 
       
    20 from __future__ import with_statement
    18 
    21 
    19 from logilab.common.decorators import clear_cache
    22 from logilab.common.decorators import clear_cache
    20 
    23 
    21 from yams.buildobjs import RelationDefinition
    24 from yams.buildobjs import RelationDefinition
    22 from rql import BadRQLQuery
    25 from rql import BadRQLQuery
  2011                      None, None, [self.cards], {}, [])
  2014                      None, None, [self.cards], {}, [])
  2012                     ])
  2015                     ])
  2013 
  2016 
  2014     def test_source_conflict_1(self):
  2017     def test_source_conflict_1(self):
  2015         self.repo._type_source_cache[999999] = ('Note', 'cards', 999999)
  2018         self.repo._type_source_cache[999999] = ('Note', 'cards', 999999)
  2016         ex = self.assertRaises(BadRQLQuery,
  2019         with self.assertRaises(BadRQLQuery) as cm:
  2017                                self._test, 'Any X WHERE X cw_source S, S name "system", X eid %(x)s',
  2020             self._test('Any X WHERE X cw_source S, S name "system", X eid %(x)s',
  2018                                [], {'x': 999999})
  2021                        [], {'x': 999999})
  2019         self.assertEqual(str(ex), 'source conflict for term %(x)s')
  2022         self.assertEqual(str(cm.exception), 'source conflict for term %(x)s')
  2020 
  2023 
  2021     def test_source_conflict_2(self):
  2024     def test_source_conflict_2(self):
  2022         ex = self.assertRaises(BadRQLQuery,
  2025         with self.assertRaises(BadRQLQuery) as cm:
  2023                                self._test, 'Card X WHERE X cw_source S, S name "systeme"', [])
  2026             self._test('Card X WHERE X cw_source S, S name "systeme"', [])
  2024         self.assertEqual(str(ex), 'source conflict for term X')
  2027         self.assertEqual(str(cm.exception), 'source conflict for term X')
  2025 
  2028 
  2026     def test_source_conflict_3(self):
  2029     def test_source_conflict_3(self):
  2027         self.skipTest('oops')
  2030         self.skipTest('oops')
  2028         self._test('CWSource X WHERE X cw_source S, S name "cards"',
  2031         self._test('CWSource X WHERE X cw_source S, S name "cards"',
  2029                    [('OneFetchStep',
  2032                    [('OneFetchStep',