From 3dbde84a28ef646fc3782282343fd31044b1e76b Mon Sep 17 00:00:00 2001 From: Stefano Fiorucci Date: Thu, 7 Mar 2024 08:52:25 +0100 Subject: [PATCH] test: monkeypatch some env vars in Predefined Pipelines tests (#7321) * ci: skip some tests if the OPENAI API key is not set * better idea: monkeypatch the env var --- test/core/pipeline/test_pipeline.py | 3 ++- test/core/pipeline/test_templates.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/core/pipeline/test_pipeline.py b/test/core/pipeline/test_pipeline.py index e8ded90fa..b2c5fb7a0 100644 --- a/test/core/pipeline/test_pipeline.py +++ b/test/core/pipeline/test_pipeline.py @@ -700,7 +700,8 @@ def test_describe_no_outputs(): assert p.outputs() == {} -def test_from_template(): +def test_from_template(monkeypatch): + monkeypatch.setenv("OPENAI_API_KEY", "fake_key") pipe = Pipeline.from_template(PredefinedPipeline.INDEXING) assert pipe.get_component("cleaner") diff --git a/test/core/pipeline/test_templates.py b/test/core/pipeline/test_templates.py index 46a2149f9..4f9e6a402 100644 --- a/test/core/pipeline/test_templates.py +++ b/test/core/pipeline/test_templates.py @@ -44,7 +44,8 @@ class TestPipelineTemplate: assert len(tpl.template_content) # Building a pipeline directly using all default components specified in a predefined or custom template. - def test_build_pipeline_with_default_components(self): + def test_build_pipeline_with_default_components(self, monkeypatch): + monkeypatch.setenv("OPENAI_API_KEY", "fake_key") rendered = PipelineTemplate.from_predefined(PredefinedPipeline.INDEXING).render() pipeline = Pipeline.loads(rendered)