Skip to content

Commit

Permalink
feat: add test to FakeRetriever
Browse files Browse the repository at this point in the history
  • Loading branch information
FacerAin committed Dec 6, 2023
1 parent a78245e commit 8405e05
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,24 @@
from app.agent.retriever import PineconeRetriever
from app.main import app


class FakeRetriever(object):
def __init__(self, *args, **kwargs):
pass

def get_relevant_doc_string(self, *args, **kwargs):
return "Hello"


client = TestClient(app)


def test_completion(monkeypatch):
def mockreturn(*args, **kwargs):
return "Hello"

def mockinitreturn(*args, **kwargs):
return None

monkeypatch.setattr(ExecutorAgent, "run", mockreturn)
monkeypatch.setattr(PineconeRetriever, "__init__", mockinitreturn)
monkeypatch.setattr("app.agent.retriever.PineconeRetriever", FakeRetriever)

req_body = {"query": "Hi"}
response = client.post("/api/v1/chat/completion", json=req_body)
Expand Down

0 comments on commit 8405e05

Please sign in to comment.