server/test/unittest_querier.py
brancholdstable
changeset 8860 e5db11a399be
parent 8349 fdb796435d7b
parent 8853 f61755c05c89
child 8866 64f24ecad177
equal deleted inserted replaced
8859:6ed22ac7257c 8860:e5db11a399be
  1515             res = self.execute('Any X WHERE X has_text %(text)s', {'text': 'aff1'})
  1515             res = self.execute('Any X WHERE X has_text %(text)s', {'text': 'aff1'})
  1516             self.assertEqual(res.rows, [[aff1.eid]])
  1516             self.assertEqual(res.rows, [[aff1.eid]])
  1517             res = self.execute('Any X WHERE X has_text %(text)s', {'text': 'aff2'})
  1517             res = self.execute('Any X WHERE X has_text %(text)s', {'text': 'aff2'})
  1518             self.assertEqual(res.rows, [[aff2.eid]])
  1518             self.assertEqual(res.rows, [[aff2.eid]])
  1519 
  1519 
       
  1520     def test_set_relations_eid(self):
       
  1521         req = self.request()
       
  1522         # create 3 email addresses
       
  1523         a1 = req.create_entity('EmailAddress', address=u'a1')
       
  1524         a2 = req.create_entity('EmailAddress', address=u'a2')
       
  1525         a3 = req.create_entity('EmailAddress', address=u'a3')
       
  1526         # SET relations using '>=' operator on eids
       
  1527         req.execute('SET U use_email A WHERE U login "admin", A eid >= %s' % a2.eid)
       
  1528         self.assertEqual(
       
  1529             [[a2.eid], [a3.eid]],
       
  1530             req.execute('Any A ORDERBY A WHERE U use_email A, U login "admin"').rows)
       
  1531         # DELETE
       
  1532         req.execute('DELETE U use_email A WHERE U login "admin", A eid > %s' % a2.eid)
       
  1533         self.assertEqual(
       
  1534             [[a2.eid]],
       
  1535             req.execute('Any A ORDERBY A WHERE U use_email A, U login "admin"').rows)
       
  1536         req.execute('DELETE U use_email A WHERE U login "admin"')
       
  1537         # SET relations using '<' operator on eids
       
  1538         req.execute('SET U use_email A WHERE U login "admin", A eid < %s' % a2.eid)
       
  1539         self.assertEqual(
       
  1540             [[a1.eid]],
       
  1541             req.execute('Any A ORDERBY A WHERE U use_email A, U login "admin"').rows)
       
  1542 
  1520 if __name__ == '__main__':
  1543 if __name__ == '__main__':
  1521     unittest_main()
  1544     unittest_main()