Skip to content

Commit

Permalink
Isolate vcr_config import into tests/integration
Browse files Browse the repository at this point in the history
Signed-off-by: Teo <[email protected]>
  • Loading branch information
teocns committed Jan 12, 2025
1 parent 4261f51 commit 0650e92
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tests/integration/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

import agentops

from tests.fixtures.vcr import vcr_config

@pytest.fixture
def agentops_session():
Expand Down
33 changes: 32 additions & 1 deletion tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import agentops
from agentops.singleton import clear_singletons
from tests.fixtures.event import llm_event_spy
from tests.fixtures.vcr import vcr_config

# Common JWT tokens used across tests
JWTS = ["some_jwt", "some_jwt2", "some_jwt3"]
Expand All @@ -24,6 +23,38 @@ def setup_teardown():
agentops.end_all_sessions() # teardown part


# @contextlib.contextmanager
# @pytest.fixture(autouse=True)
# def mock_req() -> Iterator[requests_mock.Mocker]:
# """
# Centralized request mocking for all tests.
# Mocks common API endpoints with standard responses.
# """
# with requests_mock.Mocker() as m:
# url = "https://api.agentops.ai"
#
# # Mock API endpoints
# m.post(url + "/v2/create_events", json={"status": "ok"})
# m.post(url + "/v2/developer_errors", json={"status": "ok"})
# m.post(url + "/v2/update_session", json={"status": "success", "token_cost": 5})
# m.post("https://pypi.org/pypi/agentops/json", status_code=404)
#
# # Use iterator for JWT tokens in session creation
# jwt_tokens = iter(JWTS)
#
# def create_session_response(request, context):
# context.status_code = 200
# try:
# return {"status": "success", "jwt": next(jwt_tokens)}
# except StopIteration:
# return {"status": "success", "jwt": "some_jwt"} # Fallback JWT
#
# m.post(url + "/v2/create_session", json=create_session_response)
# m.post(url + "/v2/reauthorize_jwt", json={"status": "success", "jwt": "some_jwt"})
#
# yield m


@pytest.fixture(scope="session")
def api_key() -> str:
"""Standard API key for testing"""
Expand Down

0 comments on commit 0650e92

Please sign in to comment.