def test_Step_data(self): data = { 'token': '%action1.step1.token%', 'action': '%action2.step1.action%', 'control': True, } expect = { 'token': '1234', 'action': 'add', 'control': True, } step1 = Step(url='http://test.com', data=data, name='step1') step1.results = {'token': '1234'} action1 = Action([step1], 'action1') step2 = Step(url='/', name='step1') step2.results = {'action': 'add'} action2 = Action([step2], 'action2') Actions([action1, action2]) self.assertEqual(step1.data, expect)
def test_Step_get_variable(self): # add step1 step1 = Step(url='http://test.com', name='step1') step1.results = {'rc': '_rc1'} # should not be found withoud connection with action self.assertEqual(step1.get_variable('action1.step1.rc'), 'None') action1 = Action([step1], 'action1') # should be found after connection self.assertEqual(step1.get_variable('action1.step1.rc'), '_rc1') # add step2 step2 = Step(url='http://test.com/auth', name='step1') step2.results = {'rc': '_rc2'} action2 = Action([step2], 'action2') # should not be found for step1 and found for step2 self.assertEqual(step1.get_variable('action2.step1.rc'), 'None') self.assertEqual(step2.get_variable('action2.step1.rc'), '_rc2') Actions([action1, action2]) # should be found for step1 after connect action with parent self.assertEqual(step1.get_variable('action2.step1.rc'), '_rc2')
def test_Step_get_value(self): step = Step(url='http://test.com') step.results = { 'key1': 'value1', 'key2': { 'key3': 'value3', 'key4': { 'key5': 'value5' } } } self.assertEqual(step.get_value('key1'.split('.')), 'value1') self.assertEqual(step.get_value('key2.key3'.split('.')), 'value3') self.assertEqual(step.get_value('key2.key4'.split('.')), {'key5': 'value5'}) self.assertEqual(step.get_value('key2.key4.key5'.split('.')), 'value5') self.assertIsNone(step.get_value('key6'.split('.')))
def test_Step_url(self): step = Step(url='http://test.com?token=%action1.step1.token%', name='step1') step.results = {'token': '1234'} Action([step], 'action1') self.assertEqual(step.url, 'http://test.com?token=1234')