def test_pipeline_validate(self, mocked_init): p = Pipeline() p._uid = 'pipeline.0000' p._state = 'test' with self.assertRaises(ValueError): p._validate() p = Pipeline() p._uid = 'pipeline.0000' p._stages = list() p._state = states.INITIAL with self.assertRaises(MissingError): p._validate() p = Pipeline() p._uid = 'pipeline.0000' s = mock.MagicMock(spec=Stage) s._validate = mock.MagicMock(return_value=True) p._stages = [s] p._state = states.INITIAL p._validate()
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})
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'])