reactivate skipped tests due to sqlite bug which is now fixed (sqlite 3.6.13)
"""hooks to ensure use_email / primary_email relations consistency:organization: Logilab:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr"""__docformat__="restructuredtext en"fromcubicweb.server.hooksmanagerimportHookfromcubicweb.server.poolimportPreCommitOperationclassSetUseEmailRelationOp(PreCommitOperation):"""delay this operation to commit to avoid conflict with a late rql query already setting the relation """rtype='use_email'fromeid=toeid=None# make pylint happydefcondition(self):"""check entity has use_email set for the email address"""returnnotself.session.unsafe_execute('Any X WHERE X eid %(x)s, X use_email Y, Y eid %(y)s',{'x':self.fromeid,'y':self.toeid},'x')defprecommit_event(self):session=self.sessionifself.condition():session.unsafe_execute('SET X %s Y WHERE X eid %%(x)s, Y eid %%(y)s'%self.rtype,{'x':self.fromeid,'y':self.toeid},'x')classSetPrimaryEmailRelationOp(SetUseEmailRelationOp):rtype='primary_email'defcondition(self):"""check entity has no primary_email set"""returnnotself.session.unsafe_execute('Any X WHERE X eid %(x)s, X primary_email Y',{'x':self.fromeid},'x')classSetPrimaryEmailHook(Hook):"""notify when a bug or story or version has its state modified"""events=('after_add_relation',)accepts=('use_email',)defcall(self,session,fromeid,rtype,toeid):subjtype=session.describe(fromeid)[0]eschema=self.vreg.schema[subjtype]if'primary_email'ineschema.subject_relations():SetPrimaryEmailRelationOp(session,vreg=self.vreg,fromeid=fromeid,toeid=toeid)classSetUseEmailHook(Hook):"""notify when a bug or story or version has its state modified"""events=('after_add_relation',)accepts=('primary_email',)defcall(self,session,fromeid,rtype,toeid):subjtype=session.describe(fromeid)[0]eschema=self.vreg.schema[subjtype]if'use_email'ineschema.subject_relations():SetUseEmailRelationOp(session,vreg=self.vreg,fromeid=fromeid,toeid=toeid)