kotaemon/tests/conftest.py
2023-10-24 11:12:22 +07:00

30 lines
685 B
Python

import pytest
@pytest.fixture(scope="function")
def mock_google_search(monkeypatch):
import googlesearch
def result(*args, **kwargs):
yield googlesearch.SearchResult(
url="https://www.cinnamon.is/en/",
title="Cinnamon AI",
description="Cinnamon AI is an enterprise AI company.",
)
monkeypatch.setattr(googlesearch, "search", result)
def if_haystack_not_installed():
try:
import haystack # noqa: F401
except ImportError:
return True
else:
return False
skip_when_haystack_not_installed = pytest.mark.skipif(
if_haystack_not_installed(), reason="Haystack is not installed"
)