Beispiel #1
0
 def test_sqlalchemy_command( self ):
     model_context = self.context
     from camelot.model.batch_job import BatchJobType
     # create a batch job to test with
     bt = BatchJobType( name = 'audit' )
     model_context.session.add( bt )
     bt.flush()
     # begin issue a query through the model_context
     model_context.session.query( BatchJobType ).update( values = {'name':'accounting audit'},
                                                         synchronize_session = 'evaluate' )
     # end issue a query through the model_context
     #
     # the batch job should have changed
     self.assertEqual( bt.name, 'accounting audit' )
Beispiel #2
0
 def test_sqlalchemy_command( self ):
     model_context = self.context
     from camelot.model.batch_job import BatchJobType
     # create a batch job to test with
     bt = BatchJobType( name = 'audit' )
     model_context.session.add( bt )
     bt.flush()
     # begin issue a query through the model_context
     model_context.session.query( BatchJobType ).update( values = {'name':'accounting audit'},
                                                         synchronize_session = 'evaluate' )
     # end issue a query through the model_context
     #
     # the batch job should have changed
     self.assertEqual( bt.name, 'accounting audit' )
Beispiel #3
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")
Beispiel #4
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')
Beispiel #5
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' )