def test_get_next_step_error_with_next_steps(self): flag1 = [ Flag(action='mod1_flag2', args={'arg1': '3'}), Flag(action='mod1_flag2', args={'arg1': '-1'}) ] flag2 = [ Flag(action='mod1_flag2', args={'arg1': '-1'}), Flag(action='mod1_flag2', args={'arg1': '3'}) ] next_steps = [ NextStep(flags=flag1, name='name1'), NextStep(name='name2') ] error_steps = [ NextStep(flags=flag2, name='error1'), NextStep(name='error2') ] step = Step(app='HelloWorld', action='helloWorld', next_steps=next_steps, errors=error_steps) step.output = 2 self.assertEqual(step.get_next_step({}, error=True), 'error2') step.output = 1 self.assertEqual(step.get_next_step({}, error=True), 'error1')
def test_get_next_step(self): flag1 = [ Flag(action='mod1_flag2', args={'arg1': '3'}), Flag(action='mod1_flag2', args={'arg1': '-1'}) ] next_steps = [ NextStep(flags=flag1, name='name1'), NextStep(name='name2') ] step = Step(app='HelloWorld', action='helloWorld', next_steps=next_steps) step.output = ActionResult(2, 'Success') self.assertEqual(step.get_next_step({}), 'name2') step.output = ActionResult(1, 'Success') self.assertEqual(step.get_next_step({}), 'name1')
def test_get_next_step_with_errors(self): flags1 = [ Flag(action='regMatch', args={ 'regex': Argument(key='regex', value='(.*)', format='str') }) ] flags2 = [ Flag(action='regMatch', args={ 'regex': Argument(key='regex', value='(.*)', format='str') }), Flag( action='regMatch', args={'regex': Argument(key='regex', value='a', format='str')}) ] next_step1 = NextStep(name='name1', flags=flags1) next_step2 = NextStep(name='name2', flags=flags2) step1 = Step(next_steps=[next_step2, next_step1], errors=[]) step1.output = 'aaaa' self.assertEqual(step1.get_next_step(), next_step2.name) self.assertEqual(step1.next_up, next_step2.name) step1.output = 'aaa' self.assertIsNone(step1.get_next_step(error=True)) self.assertEqual(step1.next_up, next_step2.name) step2 = Step(next_steps=[next_step1], errors=[next_step2]) step2.output = 'bbbb' self.assertEqual(step2.get_next_step(), next_step1.name) step2.output = 'aaa' self.assertEqual(step2.get_next_step(error=True), next_step2.name) self.assertEqual(step2.next_up, next_step2.name) step3 = Step(next_steps=[], errors=[next_step2, next_step1]) self.assertIsNone(step3.get_next_step()) step3.output = 'bbbbb' self.assertEqual(step3.get_next_step(error=True), next_step1.name) self.assertEqual(step3.next_up, next_step1.name) step3.output = 'aaa' self.assertEqual(step3.get_next_step(error=True), next_step2.name) self.assertEqual(step3.next_up, next_step2.name)
def test_get_next_step(self): flags1 = [ Flag(action='regMatch', args={ 'regex': Argument(key='regex', value='(.*)', format='str') }) ] flags2 = [ Flag(action='regMatch', args={ 'regex': Argument(key='regex', value='(.*)', format='str') }), Flag( action='regMatch', args={'regex': Argument(key='regex', value='a', format='str')}) ] next_step1 = NextStep(name='name1', flags=[]) next_step2 = NextStep(name='name2', flags=flags1) next_step3 = NextStep(name='name3', flags=flags2) step1 = Step(next_steps=[next_step1]) self.assertEqual(step1.get_next_step(), next_step1.name) self.assertEqual(step1.next_up, next_step1.name) step1.output = 'aaaa' self.assertEqual(step1.get_next_step(), next_step1.name) self.assertEqual(step1.next_up, next_step1.name) step2 = Step(next_steps=[next_step2]) step2.output = 'aaaa' self.assertEqual(step2.get_next_step(), next_step2.name) self.assertEqual(step2.next_up, next_step2.name) step3 = Step(next_steps=[next_step3]) step3.output = 'aaaa' self.assertEqual(step3.get_next_step(), next_step3.name) self.assertEqual(step3.next_up, next_step3.name) step3.output = None self.assertIsNone(step3.get_next_step()) self.assertEqual(step3.next_up, next_step3.name) step4 = Step(next_steps=[next_step1, next_step2]) step4.output = 'aaaa' self.assertEqual(step4.get_next_step(), next_step1.name) self.assertEqual(step4.next_up, next_step1.name) step4.output = None self.assertEqual(step4.get_next_step(), next_step1.name) self.assertEqual(step4.next_up, next_step1.name) step4 = Step(next_steps=[next_step2, next_step1]) step4.output = 6 self.assertEqual(step4.get_next_step(), next_step2.name) self.assertEqual(step4.next_up, next_step2.name) step5 = Step(next_steps=[next_step3, next_step2]) step5.output = 6 self.assertEqual(step5.get_next_step(), next_step2.name) self.assertEqual(step5.next_up, next_step2.name) step5.output = 'aaa' self.assertEqual(step5.get_next_step(), next_step3.name) self.assertEqual(step5.next_up, next_step3.name)
def test_get_next_step_no_next_steps(self): step = Step(app='HelloWorld', action='helloWorld') step.output = 'something' self.assertIsNone(step.get_next_step({}))