def test_create_relations(self): op1 = parsed_node.ParsedNode(dummy_mapper.DummyMapper(None, 'task1')) op1.downstream_names = ['task2', 'task3'] op1.error_xml = 'fail1' op2 = parsed_node.ParsedNode(dummy_mapper.DummyMapper(None, 'task2')) op2.downstream_names = ['task3'] op2.error_xml = 'fail1' op3 = parsed_node.ParsedNode(dummy_mapper.DummyMapper(None, 'task3')) op3.downstream_names = ['end1'] op3.error_xml = 'fail1' end = parsed_node.ParsedNode(dummy_mapper.DummyMapper(None, 'end1')) fail = parsed_node.ParsedNode(dummy_mapper.DummyMapper(None, 'fail1')) op_dict = { 'task1': op1, 'task2': op2, 'task3': op3, 'end1': end, 'fail1': fail } self.parser.OPERATORS.update(op_dict) self.parser.create_relations() self.assertIn('task3.set_downstream(fail1)', self.parser.relations) self.assertIn('task3.set_downstream(end1)', self.parser.relations) self.assertIn('task1.set_downstream(task2)', self.parser.relations) self.assertIn('task1.set_downstream(task3)', self.parser.relations) self.assertIn('task2.set_downstream(task3)', self.parser.relations) self.assertIn('task2.set_downstream(fail1)', self.parser.relations) self.assertIn('task1.set_downstream(fail1)', self.parser.relations)
def test_update_trigger_rules(self): op1 = parsed_node.ParsedNode(dummy_mapper.DummyMapper(None, 'task1')) op1.downstream_names = ['task2', 'task3'] op1.error_xml = 'fail1' op2 = parsed_node.ParsedNode(dummy_mapper.DummyMapper(None, 'task2')) op2.downstream_names = ['task3'] op2.error_xml = 'fail1' op3 = parsed_node.ParsedNode(dummy_mapper.DummyMapper(None, 'task3')) op3.downstream_names = ['end1'] op3.error_xml = 'fail1' end = parsed_node.ParsedNode(dummy_mapper.DummyMapper(None, 'end1')) fail = parsed_node.ParsedNode(dummy_mapper.DummyMapper(None, 'fail1')) op_dict = {'task1': op1, 'task2': op2, 'task3': op3, 'end1': end, 'fail1': fail} self.parser.OPERATORS.update(op_dict) self.parser.create_relations() self.parser.update_trigger_rules() self.assertFalse(op1.is_ok) self.assertFalse(op1.is_error) self.assertTrue(op2.is_ok) self.assertFalse(op2.is_error) self.assertTrue(op3.is_ok) self.assertFalse(op2.is_error) self.assertTrue(end.is_ok) self.assertFalse(end.is_error) self.assertFalse(fail.is_ok) self.assertTrue(fail.is_error)
def test_create_relations(self): oozie_node = ET.Element("dummy") op1 = parsed_node.ParsedNode( dummy_mapper.DummyMapper(oozie_node=oozie_node, name="task1")) op1.downstream_names = ["task2", "task3"] op1.error_xml = "fail1" op2 = parsed_node.ParsedNode( dummy_mapper.DummyMapper(oozie_node=oozie_node, name="task2")) op2.downstream_names = ["task3", "task4"] op2.error_xml = "fail1" op3 = parsed_node.ParsedNode( dummy_mapper.DummyMapper(oozie_node=oozie_node, name="task3")) op3.downstream_names = ["end1"] op3.error_xml = "fail1" op4 = mock.Mock( **{ "first_task_id": "task4_first", "last_task_id": "task4_last", "get_downstreams.return_value": ["task1", "task2", "task3"], "get_error_downstream_name.return_value": "fail1", }) end = parsed_node.ParsedNode( dummy_mapper.DummyMapper(oozie_node=oozie_node, name="end1")) fail = parsed_node.ParsedNode( dummy_mapper.DummyMapper(oozie_node=oozie_node, name="fail1")) op_dict = { "task1": op1, "task2": op2, "task3": op3, "task4": op4, "end1": end, "fail1": fail } self.parser.workflow.nodes.update(op_dict) self.parser.create_relations() self.assertEqual( self.parser.workflow.relations, { Relation(from_task_id="task1", to_task_id="fail1"), Relation(from_task_id="task1", to_task_id="task2"), Relation(from_task_id="task1", to_task_id="task3"), Relation(from_task_id="task2", to_task_id="fail1"), Relation(from_task_id="task2", to_task_id="task3"), Relation(from_task_id="task2", to_task_id="task4_first"), Relation(from_task_id="task3", to_task_id="end1"), Relation(from_task_id="task3", to_task_id="fail1"), Relation(from_task_id="task4_last", to_task_id="fail1"), Relation(from_task_id="task4_last", to_task_id="task1"), Relation(from_task_id="task4_last", to_task_id="task2"), Relation(from_task_id="task4_last", to_task_id="task3"), }, )
def test_create_mapper(self): mapper = dummy_mapper.DummyMapper(oozie_node=None, task_id='test_id', trigger_rule=TriggerRule.DUMMY) # make sure everything is getting initialized correctly self.assertEqual('test_id', mapper.task_id) self.assertEqual(TriggerRule.DUMMY, mapper.trigger_rule)
def test_create_mapper(self): mapper = dummy_mapper.DummyMapper(oozie_node=self.oozie_node, name="test_id", trigger_rule=TriggerRule.DUMMY) # make sure everything is getting initialized correctly self.assertEqual("test_id", mapper.name) self.assertEqual(TriggerRule.DUMMY, mapper.trigger_rule)
def test_write_operators(self): node = parsed_node.ParsedNode(dummy_mapper.DummyMapper(None, 'task1')) ops = {'task1': node} fp = io.StringIO() oozie_converter.write_operators(fp, ops, indent=0) fp.seek(0) self.assertEqual(node.operator.convert_to_text(), fp.read())
def test_write_operators(self): node = ParsedNode( dummy_mapper.DummyMapper(oozie_node=Element("test"), name="task1")) nodes = {"task1": node} file = io.StringIO() self.converter.write_nodes(file=file, nodes=nodes, indent=0) file.seek(0) self.assertEqual(node.mapper.convert_to_text(), file.read())
def test_update_trigger_rules(self): oozie_node = ET.Element("dummy") op1 = parsed_node.ParsedNode( dummy_mapper.DummyMapper(oozie_node=oozie_node, name="task1")) op1.downstream_names = ["task2", "task3"] op1.error_xml = "fail1" op2 = parsed_node.ParsedNode( dummy_mapper.DummyMapper(oozie_node=oozie_node, name="task2")) op2.downstream_names = ["task3"] op2.error_xml = "fail1" op3 = parsed_node.ParsedNode( dummy_mapper.DummyMapper(oozie_node=oozie_node, name="task3")) op3.downstream_names = ["end1"] op3.error_xml = "fail1" end = parsed_node.ParsedNode( dummy_mapper.DummyMapper(oozie_node=oozie_node, name="end1")) fail = parsed_node.ParsedNode( dummy_mapper.DummyMapper(oozie_node=oozie_node, name="fail1")) op_dict = { "task1": op1, "task2": op2, "task3": op3, "end1": end, "fail1": fail } self.parser.workflow.nodes.update(op_dict) self.parser.create_relations() self.parser.update_trigger_rules() self.assertFalse(op1.is_ok) self.assertFalse(op1.is_error) self.assertTrue(op2.is_ok) self.assertFalse(op2.is_error) self.assertTrue(op3.is_ok) self.assertFalse(op2.is_error) self.assertTrue(end.is_ok) self.assertFalse(end.is_error) self.assertFalse(fail.is_ok) self.assertTrue(fail.is_error)
def setUp(self): op1 = dummy_mapper.DummyMapper(None, 'task1') self.p_node = parsed_node.ParsedNode(op1)
def setUp(self): oozie_node = Element("dummy") op1 = dummy_mapper.DummyMapper(oozie_node=oozie_node, name="task1") self.p_node = parsed_node.ParsedNode(op1)
def test_convert_to_text(self): mapper = dummy_mapper.DummyMapper(oozie_node=None, task_id='test_id', trigger_rule=TriggerRule.DUMMY) ast.parse(mapper.convert_to_text())
def test_convert_to_text(self): mapper = dummy_mapper.DummyMapper(oozie_node=self.oozie_node, name="test_id", trigger_rule=TriggerRule.DUMMY) ast.parse(mapper.convert_to_text())