Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Skip integration tests if env var is missing #6703

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions test/components/embedders/test_openai_document_embedder.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from typing import List

import numpy as np
Expand Down Expand Up @@ -163,6 +164,7 @@ def test_run_on_empty_list(self):
assert result["documents"] is not None
assert not result["documents"] # empty list

@pytest.mark.skipif("OPENAI_API_KEY" not in os.environ, reason="OPENAI_API_KEY is not set")
@pytest.mark.integration
def test_run(self):
docs = [
Expand Down
3 changes: 3 additions & 0 deletions test/components/embedders/test_openai_text_embedder.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

import pytest
from openai import OpenAIError

Expand Down Expand Up @@ -74,6 +76,7 @@ def test_run_wrong_input_format(self):
with pytest.raises(TypeError, match="OpenAITextEmbedder expects a string as an input"):
embedder.run(text=list_integers_input)

@pytest.mark.skipif("OPENAI_API_KEY" not in os.environ, reason="OPENAI_API_KEY is not set")
@pytest.mark.integration
def test_run(self):
model = "text-similarity-ada-001"
Expand Down
3 changes: 3 additions & 0 deletions test/pipelines/test_indexing_pipeline.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

import pytest

from haystack.pipeline_utils.indexing import build_indexing_pipeline
Expand Down Expand Up @@ -65,6 +67,7 @@ def test_embedding_model_not_found(self):
with pytest.raises(ValueError, match="Could not find an embedder"):
build_indexing_pipeline(document_store=document_store, embedding_model="invalid_model")

@pytest.mark.skipif("OPENAI_API_KEY" not in os.environ, reason="OPENAI_API_KEY is not set")
@pytest.mark.integration
def test_open_ai_embedding_model(self):
document_store = InMemoryDocumentStore()
Expand Down
3 changes: 3 additions & 0 deletions test/pipelines/test_rag_pipelines.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

import pytest

from haystack.dataclasses import Answer
Expand All @@ -6,6 +8,7 @@
from haystack.testing.factory import document_store_class


@pytest.mark.skipif("OPENAI_API_KEY" not in os.environ, reason="OPENAI_API_KEY is not set")
@pytest.mark.integration
def test_rag_pipeline(mock_chat_completion):
rag_pipe = build_rag_pipeline(document_store=InMemoryDocumentStore())
Expand Down