Ejemplo n.º 1
0
    def test_batch_job(self):
        from camelot.model.batch_job import BatchJob, BatchJobType

        batch_job_type = BatchJobType.get_or_create(u"Synchronize")
        with BatchJob.create(batch_job_type) as batch_job:
            batch_job.add_strings_to_message([u"Doing something"])
            batch_job.add_strings_to_message([u"Done"], color="green")
Ejemplo n.º 2
0
 def test_batch_job(self):
     from camelot.model.batch_job import BatchJob, BatchJobType
     batch_job_type = BatchJobType.get_or_create(u'Synchronize')
     self.assertTrue(unicode(batch_job_type))
     batch_job = BatchJob.create(batch_job_type)
     self.assertTrue(orm.object_session(batch_job))
     self.assertFalse(batch_job.is_canceled())
     batch_job.change_status('canceled')
     self.assertTrue(batch_job.is_canceled())
     # run batch job without exception
     with batch_job:
         batch_job.add_strings_to_message([u'Doing something'])
         batch_job.add_strings_to_message([u'Done'], color='green')
     self.assertEqual(batch_job.current_status, 'success')
     # run batch job with exception
     batch_job = BatchJob.create(batch_job_type)
     with batch_job:
         batch_job.add_strings_to_message([u'Doing something'])
         raise Exception('Something went wrong')
     self.assertEqual(batch_job.current_status, 'errors')
Ejemplo n.º 3
0
 def test_batch_job( self ):
     from camelot.model.batch_job import BatchJob, BatchJobType
     batch_job_type = BatchJobType.get_or_create( u'Synchronize' )
     self.assertTrue( unicode( batch_job_type ) )
     batch_job = BatchJob.create( batch_job_type )
     self.assertTrue( orm.object_session( batch_job ) )
     self.assertFalse( batch_job.is_canceled() )
     batch_job.change_status( 'canceled' )
     self.assertTrue( batch_job.is_canceled() )
     # run batch job without exception
     with batch_job:
         batch_job.add_strings_to_message( [ u'Doing something' ] )
         batch_job.add_strings_to_message( [ u'Done' ], color = 'green' )
     self.assertEqual( batch_job.current_status, 'success' )
     # run batch job with exception
     batch_job = BatchJob.create( batch_job_type )
     with batch_job:
         batch_job.add_strings_to_message( [ u'Doing something' ] )
         raise Exception('Something went wrong')
     self.assertEqual( batch_job.current_status, 'errors' )