hooks/test/unittest_syncschema.py
changeset 4829 3b79a0fc91db
parent 4766 162b2b127b15
parent 4826 7eba168407c3
child 4845 dc351b96f596
equal deleted inserted replaced
4823:e833520870ee 4829:3b79a0fc91db
   254         self.failUnless('Transition' in self.schema['messageid'].subjects())
   254         self.failUnless('Transition' in self.schema['messageid'].subjects())
   255         self.failUnless('WorkflowTransition' in self.schema['messageid'].subjects())
   255         self.failUnless('WorkflowTransition' in self.schema['messageid'].subjects())
   256         self.execute('Any X WHERE X is_instance_of BaseTransition, X messageid "hop"')
   256         self.execute('Any X WHERE X is_instance_of BaseTransition, X messageid "hop"')
   257 
   257 
   258     def test_change_fulltextindexed(self):
   258     def test_change_fulltextindexed(self):
   259         target = self.request().create_entity(u'EmailAddress', address=u'rick.roll@dance.com')
   259         req = self.request()
       
   260         target = req.create_entity(u'Email', messageid=u'1234',
       
   261                                    subject=u'rick.roll@dance.com')
       
   262         self.commit()
       
   263         rset = req.execute('Any X WHERE X has_text "rick.roll"')
       
   264         self.assertIn(target.eid, [item[0] for item in rset])
       
   265         assert req.execute('SET A fulltextindexed FALSE '
       
   266                             'WHERE E is CWEType, E name "Email", A is CWAttribute,'
       
   267                             'A from_entity E, A relation_type R, R name "subject"')
       
   268         self.commit()
       
   269         rset = req.execute('Any X Where X has_text "rick.roll"')
       
   270         self.failIf(rset)
       
   271         assert req.execute('SET A fulltextindexed TRUE '
       
   272                            'WHERE A from_entity E, A relation_type R, '
       
   273                            'E name "Email", R name "subject"')
       
   274         self.commit()
       
   275         rset = req.execute('Any X WHERE X has_text "rick.roll"')
       
   276         self.assertIn(target.eid, [item[0] for item in rset])
       
   277 
       
   278     def test_change_fulltext_container(self):
       
   279         req = self.request()
       
   280         target = req.create_entity(u'EmailAddress', address=u'rick.roll@dance.com')
       
   281         target.set_relations(reverse_use_email=req.user)
       
   282         self.commit()
       
   283         rset = req.execute('Any X WHERE X has_text "rick.roll"')
       
   284         self.assertIn(req.user.eid, [item[0] for item in rset])
       
   285         assert self.execute('SET R fulltext_container NULL '
       
   286                             'WHERE R name "use_email"')
   260         self.commit()
   287         self.commit()
   261         rset = self.execute('Any X Where X has_text "rick.roll"')
   288         rset = self.execute('Any X Where X has_text "rick.roll"')
   262         self.assertIn(target.eid, [item[0] for item in rset])
   289         self.assertIn(target.eid, [item[0] for item in rset])
   263 
   290         assert self.execute('SET R fulltext_container "subject" '
   264         assert self.execute('''SET A fulltextindexed False
   291                             'WHERE R name "use_email"')
   265                         WHERE E is CWEType,
   292         self.commit()
   266                               E name "EmailAddress",
   293         rset = req.execute('Any X WHERE X has_text "rick.roll"')
   267                               A is CWAttribute,
   294         self.assertIn(req.user.eid, [item[0] for item in rset])
   268                               A from_entity E,
   295 
   269                               A relation_type R,
       
   270                               R name "address"
       
   271                     ''')
       
   272         self.commit()
       
   273         rset = self.execute('Any X Where X has_text "rick.roll"')
       
   274         self.assertNotIn(target.eid, [item[0] for item in rset])
       
   275