def test_only_nodes_with_namespace(self, target_namespace, expected_namespaces): pipeline = Pipeline( [ node(identity, "A", "B", namespace="katie"), node(identity, "B", "C", namespace="lisa"), node(identity, "C", "D", namespace="john"), node(identity, "D", "E", namespace="katie.lisa"), node(identity, "E", "F", namespace="lisa.john"), node(identity, "F", "G", namespace="katie.lisa.john"), ] ) resulting_pipeline = pipeline.only_nodes_with_namespaces(target_namespace) for actual_node, expected_namespace in zip( sorted(resulting_pipeline.nodes), expected_namespaces ): assert actual_node.namespace == expected_namespace
def test_only_nodes_with_namespace_empty(self, namespace): pipeline = Pipeline([node(identity, "A", "B", namespace=namespace)]) pattern = r"Pipeline does not contain nodes" with pytest.raises(ValueError, match=pattern): pipeline.only_nodes_with_namespaces("non_existent")