def setUp(self): with open('/tmp/sample1.csv', 'w') as f: f.write(DATA_FILES["sample1"]) with open('/tmp/sample2.csv', 'w') as f: f.write(DATA_FILES["sample2"]) self.pyworkflow = Workflow("My Workflow", root_dir="/tmp") self.read_csv_node_1 = Node(GOOD_NODES["read_csv_node"]) self.read_csv_node_2 = Node({ "name": "Read CSV", "node_id": "2", "node_type": "io", "node_key": "ReadCsvNode", "is_global": False, "options": { "file": "/tmp/sample2.csv", "sep": ";", }, "option_replace": { "sep": { "node_id": "1", "is_global": True, } } }) self.join_node = Node(GOOD_NODES["join_node"]) self.write_csv_node = Node({ "name": "Write CSV", "node_id": "4", "node_type": "io", "node_key": "WriteCsvNode", "is_global": False, "options": { "file": "/tmp/sample_out.csv" } }) self.string_flow_node = Node(GOOD_NODES["string_input"]) self.string_global_flow_node = Node(GOOD_NODES["global_flow_var"]) self.nodes = [ self.read_csv_node_1, self.read_csv_node_2, self.join_node, self.write_csv_node, self.string_flow_node, self.string_global_flow_node, ] self.edges = [("1", "3"), ("2", "3"), ("3", "4"), ("7", "3")]
def test_add_custom_node(self): with open(self.workflow.node_path('custom_nodes', 'good_custom_node.py'), 'w') as f: f.write((DATA_FILES['good_custom_node'])) custom_node_info = { "name": "Custom Node", "node_id": "50", "node_type": "custom_node", "node_key": "MyGoodCustomNode", "is_global": False, } node_to_add = Node(custom_node_info) added_node = self.add_node(custom_node_info, "50") self.assertDictEqual(node_to_add.__dict__, added_node.__dict__)
def test_get_flow_var(self): retrieved_node = self.workflow.get_flow_var("1") global_flow_var = Node(self.global_flow_var) self.assertDictEqual(retrieved_node.__dict__, global_flow_var.__dict__)
def add_node(self, node_info, node_id): node_info["node_id"] = node_id node_to_add = Node(node_info) return self.workflow.update_or_add_node(node_to_add)
def test_add_string_node(self): node_to_add = Node(self.global_flow_var) added_node = self.add_node(self.global_flow_var, "1") self.assertDictEqual(node_to_add.__dict__, added_node.__dict__)
def test_get_node(self): retrieved_node = self.workflow.get_node("1") read_csv_node = Node(self.read_csv_node) self.assertDictEqual(retrieved_node.__dict__, read_csv_node.__dict__)
def test_add_write_csv_node(self): node_to_add = Node(self.write_csv_node) added_node = self.add_node(self.write_csv_node, "2") self.assertDictEqual(node_to_add.__dict__, added_node.__dict__)
def test_add_read_csv_node(self): node_to_add = Node(self.read_csv_node) added_node = self.add_node(self.read_csv_node, "1") self.assertDictEqual(node_to_add.__dict__, added_node.__dict__)