コード例 #1
0
 def testgetAllUniqueLabels(self):
     shutil.copy( self.xmlSourcePath , self.sessionPath )
     label_1= [ 'label_1', 'label_1_bis' ]
     label_2=  label_1 + [ 'label_2' ]
     transaction = Transaction( self.sessionPath , Transaction.WRITE )
     transaction.setJobLabels( self.jobID[0] , label_1 )
     transaction.setJobLabels( self.jobID[1] , label_2 )
     transaction.commit()
     transaction = Transaction( self.sessionPath , Transaction.READ )
     label_recieved = transaction.getJobLabels( self.jobID[1] )
     transaction.commit()
     s = set( label_1 + label_2 )
     unique = list( s )
     unique.sort()
     label_recieved.sort()
     self.assertEqual( label_recieved , unique )
コード例 #2
0
 def testSetAndGetJobLabel(self):
     shutil.copy( self.xmlSourcePath , self.sessionPath )
     #there is not labels yet in jobs
     transaction = Transaction( self.sessionPath , Transaction.READ )
     label_recieved = transaction.getJobLabels(self.jobID[0])
     transaction.commit()
     self.assertEqual( label_recieved , [] )
     #add one label
     label_send = ['label_1']
     transaction = Transaction( self.sessionPath , Transaction.WRITE )
     transaction.setJobLabels( self.jobID[0] , label_send )
     transaction.commit()
     #get one label
     transaction = Transaction( self.sessionPath , Transaction.READ )
     label_recieved = transaction.getJobLabels(self.jobID[0])
     transaction.commit()
     self.assertEqual( label_recieved , label_send )
     #add 2 labels
     label_send = ['label_2', 'label_2_bis']
     transaction = Transaction( self.sessionPath , Transaction.WRITE )
     transaction.setJobLabels( self.jobID[1] , label_send )
     transaction.commit()
     #get 2 labels
     transaction = Transaction( self.sessionPath , Transaction.READ )
     label_recieved = transaction.getJobLabels(self.jobID[1])
     transaction.commit()
     self.assertEqual( label_recieved , label_send )
     #add label in job which have already labels
     new_label = [ 'label_3', 'label_3_bis' ]
     transaction = Transaction( self.sessionPath , Transaction.WRITE )
     transaction.setJobLabels( self.jobID[1] , new_label )
     transaction.commit()
     #get 2 new labels
     transaction = Transaction( self.sessionPath , Transaction.READ )
     label_recieved = transaction.getJobLabels( self.jobID[1] )
     label_recieved = transaction.getJobLabels( self.jobID[1] )
     transaction.commit()
     self.assertEqual( label_recieved , new_label )