Exemplo n.º 1
0
    def test_pipeline_decrement_stage(self, mocked_init):

        p = Pipeline()
        p._completed_flag = mock.Mock()
        p._completed_flag.is_set = mock.MagicMock(side_effect=[False, True])
        p._cur_stage = 2
        p._stage_count = 2

        p._decrement_stage()
        self.assertEqual(p._stage_count, 2)
        self.assertEqual(p._cur_stage, 1)
        self.assertFalse(p._completed_flag.is_set(), False)

        p._decrement_stage()
        self.assertEqual(p._stage_count, 2)
        self.assertEqual(p._cur_stage, 0)
        self.assertFalse(p._completed_flag.is_set(), False)
Exemplo n.º 2
0
    def test_pipeline_to_dict(self, mocked_init):

        p = Pipeline()
        p._uid  = 'pipeline.0000'
        p._name = 'test_pipeline'
        p._stages = list()
        p._state = states.INITIAL
        p._state_history = [states.INITIAL]
        p._stage_count = len(p._stages)
        p._cur_stage = 0
        p._completed_flag = mock.Mock()
        p._completed_flag.is_set = mock.MagicMock(return_value=False)

        d = p.to_dict()
        self.assertEqual(d, {'uid': 'pipeline.0000',
                             'name': 'test_pipeline',
                             'state': states.INITIAL,
                             'state_history': [states.INITIAL],
                             'completed': False})
Exemplo n.º 3
0
    def test_pipeline_properties(self, mocked_init):

        p = Pipeline()
        p._name = 'test_pipe'
        self.assertEqual(p.name, 'test_pipe')
        self.assertEqual(p.luid, 'test_pipe')

        p = Pipeline()
        p._stages = ['test_stage']
        self.assertEqual(p.stages, ['test_stage'])

        p = Pipeline()
        p._state = 'test_state'
        self.assertEqual(p.state, 'test_state')

        p = Pipeline()
        p._uid = 'pipeline.0000'
        p._name = None
        self.assertEqual(p.uid, 'pipeline.0000')
        self.assertEqual(p.luid, 'pipeline.0000')

        p = Pipeline()
        p._lock = 'test_lock'
        self.assertEqual(p.lock, 'test_lock')

        p = Pipeline()
        p._completed_flag = mock.Mock()
        p._completed_flag.is_set = mock.MagicMock(return_value='flag_set')
        self.assertEqual(p.completed, 'flag_set')

        p = Pipeline()
        p._cur_stage = 'some_stage'
        self.assertEqual(p.current_stage, 'some_stage')

        p = Pipeline()
        p._state_history = ['state1','state2']
        self.assertEqual(p.state_history, ['state1','state2'])