def test_remove_pipes(self, pipes_list): network = ZeroNetwork() pipes_list1, pipes_list2 = _split_lists(pipes_list, 2) network.add_pipes(*pipes_list) network.remove_pipes(*pipes_list1) assert list(network.pipes.values()) == list(pipes_list2)
def test_output_nodes(self, pipes_list): network = ZeroNetwork() network.add_pipes(*pipes_list) assert list(network.input_nodes) == [ pipe.node_a for pipe in pipes_list if pipe.node_b == ZeroNode.OUT ]
def test_reverse_pipes_map(self, pipes_list): network = ZeroNetwork() network.add_pipes(*pipes_list) pipes_map = network.get_pipes_map(reverse=True) test_pipes_map = defaultdict( lambda: defaultdict(lambda: defaultdict(lambda: None))) for pipe in pipes_list: node_a = pipe.node_a.id if not isinstance(pipe.node_a, str) else pipe.node_a node_b = pipe.node_b.id if not isinstance(pipe.node_b, str) else pipe.node_b test_pipes_map[node_b][node_a][pipe.id] = pipe assert pipes_map == test_pipes_map
def test_add_pipes(self, pipes_list): network = ZeroNetwork() network.add_pipes(*pipes_list) assert list(network.pipes.values()) == pipes_list
def test_output_pipes(self, pipes_list, output_pipes_list): network = ZeroNetwork() network.add_pipes(*pipes_list) assert list(network.output_pipes) == output_pipes_list
def test_input_pipes(self, pipes_list, input_pipes_list): network = ZeroNetwork() network.add_pipes(*pipes_list) assert list(network.input_pipes) == input_pipes_list