Exemple #1
0
 def test_CondExecEnv1(self):
     import cStringIO
     test_stream = cStringIO.StringIO()
     logger = StreamLogger(level=DEBUG, stream=test_stream)
     exp_cfg = {
         'logger': Logger(),
     }
     env_cfg = {'logger': logger}
     env = LoggedExecutionEnvironment(exp_cfg, env_cfg)
     env.addCallable(TestEnv._b1,
                     action_kwargs=None,
                     action_input=None,
                     action_output=('source1', ))
     env.addCallable(TestEnv._b2,
                     action_kwargs=None,
                     action_input=None,
                     action_output=('source2', ))
     env.addCallable(TestEnv._b3,
                     action_kwargs=None,
                     action_input=('source1', 'source2'),
                     action_output=('product', ))
     env.execute()
     self.assertIn('product', env.varkeys())
     self.assertEqual('val1__val2', env.var('product'))
     nls = count_lines(test_stream)
     self.assertEqual(nls, 5)
Exemple #2
0
 def test_LoggedExecEnv1(self):
     import cStringIO
     test_stream = cStringIO.StringIO()
     logger = StreamLogger(level=DEBUG, stream=test_stream)
     exp_cfg = {
         'logger': Logger(),
     }
     env_cfg = {'logger': logger}
     env = LoggedExecutionEnvironment(exp_cfg, env_cfg)
     env.addCallable(TestEnv._a2, {'a': 'a', 'b': 'b', 'c': 'c', 'd': -1})
     env.addCallable(TestEnv._a3)
     env.execute()
     nls = count_lines(test_stream)
     self.assertEqual(nls, 4)
Exemple #3
0
 def test_postActionCb2(self):
     import cStringIO
     test_stream = cStringIO.StringIO()
     logger = StreamLogger(level=DEBUG, stream=test_stream)
     exp_cfg = {
         'logger': Logger(),
     }
     env_cfg = {'logger': logger}
     env = LoggedExecutionEnvironment(exp_cfg, env_cfg)
     env.addCallable(TestEnv._a2, {'a': 'a', 'b': 'b', 'c': 'c', 'd': -1})
     env.addCallable(TestEnv._a3)
     # add custom post action callback
     env.postActionCallback = TestEnv._postActionCb2
     # and execute
     env.execute()
     nls = count_lines(test_stream)
     self.assertEqual(nls, 15)