server/test/unittest_multisources.py
branch3.5
changeset 2920 64322aa83a1d
parent 2072 8008e8812d76
child 2968 0e3460341023
child 3252 c0e10da6f1cf
equal deleted inserted replaced
2919:662f35236d1c 2920:64322aa83a1d
    28 
    28 
    29 repo2, cnx2 = init_test_database('sqlite', config=ExternalSource1Configuration('data'))
    29 repo2, cnx2 = init_test_database('sqlite', config=ExternalSource1Configuration('data'))
    30 cu = cnx2.cursor()
    30 cu = cnx2.cursor()
    31 ec1 = cu.execute('INSERT Card X: X title "C3: An external card", X wikiid "aaa"')[0][0]
    31 ec1 = cu.execute('INSERT Card X: X title "C3: An external card", X wikiid "aaa"')[0][0]
    32 cu.execute('INSERT Card X: X title "C4: Ze external card", X wikiid "zzz"')
    32 cu.execute('INSERT Card X: X title "C4: Ze external card", X wikiid "zzz"')
    33 aff1 = cu.execute('INSERT Affaire X: X ref "AFFREF", X in_state S WHERE S name "pitetre"')[0][0]
    33 aff1 = cu.execute('INSERT Affaire X: X ref "AFFREF"')[0][0]
    34 cnx2.commit()
    34 cnx2.commit()
    35 
    35 
    36 MTIME = datetime.now() - timedelta(0, 10)
    36 MTIME = datetime.now() - timedelta(0, 10)
    37 
    37 
    38 repo3, cnx3 = init_test_database('sqlite', config=ExternalSource2Configuration('data'))
    38 repo3, cnx3 = init_test_database('sqlite', config=ExternalSource2Configuration('data'))
   120 
   120 
   121     def test_synchronization(self):
   121     def test_synchronization(self):
   122         cu = cnx2.cursor()
   122         cu = cnx2.cursor()
   123         assert cu.execute('Any X WHERE X eid %(x)s', {'x': aff1}, 'x')
   123         assert cu.execute('Any X WHERE X eid %(x)s', {'x': aff1}, 'x')
   124         cu.execute('SET X ref "BLAH" WHERE X eid %(x)s', {'x': aff1}, 'x')
   124         cu.execute('SET X ref "BLAH" WHERE X eid %(x)s', {'x': aff1}, 'x')
   125         aff2 = cu.execute('INSERT Affaire X: X ref "AFFREUX", X in_state S WHERE S name "pitetre"')[0][0]
   125         aff2 = cu.execute('INSERT Affaire X: X ref "AFFREUX"')[0][0]
   126         cnx2.commit()
   126         cnx2.commit()
   127         try:
   127         try:
   128             # force sync
   128             # force sync
   129             self.repo.sources_by_uri['extern'].synchronize(MTIME)
   129             self.repo.sources_by_uri['extern'].synchronize(MTIME)
   130             self.failUnless(self.execute('Any X WHERE X has_text "blah"'))
   130             self.failUnless(self.execute('Any X WHERE X has_text "blah"'))
   265         affaire = self.execute('Affaire X WHERE X ref "AFFREF"').get_entity(0, 0)
   265         affaire = self.execute('Affaire X WHERE X ref "AFFREF"').get_entity(0, 0)
   266         self.execute('Any U WHERE U in_group G, (G name IN ("managers", "logilab") OR (X require_permission P?, P name "bla", P require_group G)), X eid %(x)s, U eid %(u)s',
   266         self.execute('Any U WHERE U in_group G, (G name IN ("managers", "logilab") OR (X require_permission P?, P name "bla", P require_group G)), X eid %(x)s, U eid %(u)s',
   267                      {'x': affaire.eid, 'u': ueid})
   267                      {'x': affaire.eid, 'u': ueid})
   268 
   268 
   269     def test_nonregr2(self):
   269     def test_nonregr2(self):
       
   270         self.session.user.fire_transition('deactivate')
   270         treid = self.session.user.latest_trinfo().eid
   271         treid = self.session.user.latest_trinfo().eid
   271         rset = self.execute('Any X ORDERBY D DESC WHERE E eid %(x)s, E wf_info_for X, X modification_date D',
   272         rset = self.execute('Any X ORDERBY D DESC WHERE E eid %(x)s, E wf_info_for X, X modification_date D',
   272                             {'x': treid})
   273                             {'x': treid})
   273         self.assertEquals(len(rset), 1)
   274         self.assertEquals(len(rset), 1)
   274         self.assertEquals(rset.rows[0], [self.session.user.eid])
   275         self.assertEquals(rset.rows[0], [self.session.user.eid])