Skip to content

Commit

Permalink
chore: fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Vedantsahai18 committed Dec 20, 2024
1 parent 978fd01 commit c88e8d7
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 82 deletions.
9 changes: 4 additions & 5 deletions agents-api/tests/test_entry_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

from uuid import UUID

# from fastapi import HTTPException
# from uuid_extensions import uuid7
# from ward import raises, test
from fastapi import HTTPException
from uuid_extensions import uuid7
from ward import raises, test

from agents_api.autogen.openapi_model import (
CreateEntryRequest,
Expand All @@ -23,8 +23,7 @@
)
from tests.fixtures import pg_dsn, test_developer, test_developer_id, test_session

# MODEL = "gpt-4o-mini"

MODEL = "gpt-4o-mini"

@test("query: create entry no session")
async def _(dsn=pg_dsn, developer=test_developer):
Expand Down
154 changes: 77 additions & 77 deletions agents-api/tests/test_session_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Tests verify the SQL queries without actually executing them against a database.
# """

# from uuid_extensions import uuid7
# from ward import raises, test
from uuid_extensions import uuid7
from ward import raises, test

from agents_api.autogen.openapi_model import (
CreateOrUpdateSessionRequest,
Expand Down Expand Up @@ -36,11 +36,11 @@
)


# @test("query: create session sql")
# async def _(
# dsn=pg_dsn, developer_id=test_developer_id, agent=test_agent, user=test_user
# ):
# """Test that a session can be successfully created."""
@test("query: create session sql")
async def _(
dsn=pg_dsn, developer_id=test_developer_id, agent=test_agent, user=test_user
):
"""Test that a session can be successfully created."""

pool = await create_db_pool(dsn=dsn)
session_id = uuid7()
Expand All @@ -61,11 +61,11 @@
assert result.id == session_id


# @test("query: create or update session sql")
# async def _(
# dsn=pg_dsn, developer_id=test_developer_id, agent=test_agent, user=test_user
# ):
# """Test that a session can be successfully created or updated."""
@test("query: create or update session sql")
async def _(
dsn=pg_dsn, developer_id=test_developer_id, agent=test_agent, user=test_user
):
"""Test that a session can be successfully created or updated."""

pool = await create_db_pool(dsn=dsn)
session_id = uuid7()
Expand All @@ -87,39 +87,39 @@
assert result.updated_at is not None


# @test("query: get session exists")
# async def _(dsn=pg_dsn, developer_id=test_developer_id, session=test_session):
# """Test retrieving an existing session."""
@test("query: get session exists")
async def _(dsn=pg_dsn, developer_id=test_developer_id, session=test_session):
"""Test retrieving an existing session."""

# pool = await create_db_pool(dsn=dsn)
# result = await get_session(
# developer_id=developer_id,
# session_id=session.id,
# connection_pool=pool,
# )
pool = await create_db_pool(dsn=dsn)
result = await get_session(
developer_id=developer_id,
session_id=session.id,
connection_pool=pool,
)

assert result is not None
assert isinstance(result, Session)
assert result.id == session.id


# @test("query: get session does not exist")
# async def _(dsn=pg_dsn, developer_id=test_developer_id):
# """Test retrieving a non-existent session."""
@test("query: get session does not exist")
async def _(dsn=pg_dsn, developer_id=test_developer_id):
"""Test retrieving a non-existent session."""

# session_id = uuid7()
# pool = await create_db_pool(dsn=dsn)
# with raises(Exception):
# await get_session(
# session_id=session_id,
# developer_id=developer_id,
# connection_pool=pool,
# )
session_id = uuid7()
pool = await create_db_pool(dsn=dsn)
with raises(Exception):
await get_session(
session_id=session_id,
developer_id=developer_id,
connection_pool=pool,
)


# @test("query: list sessions")
# async def _(dsn=pg_dsn, developer_id=test_developer_id, session=test_session):
# """Test listing sessions with default pagination."""
@test("query: list sessions")
async def _(dsn=pg_dsn, developer_id=test_developer_id, session=test_session):
"""Test listing sessions with default pagination."""

pool = await create_db_pool(dsn=dsn)
result = await list_sessions(
Expand All @@ -129,14 +129,14 @@
connection_pool=pool,
)

# assert isinstance(result, list)
# assert len(result) >= 1
# assert any(s.id == session.id for s in result)
assert isinstance(result, list)
assert len(result) >= 1
assert any(s.id == session.id for s in result)


# @test("query: list sessions with filters")
# async def _(dsn=pg_dsn, developer_id=test_developer_id, session=test_session):
# """Test listing sessions with specific filters."""
@test("query: list sessions with filters")
async def _(dsn=pg_dsn, developer_id=test_developer_id, session=test_session):
"""Test listing sessions with specific filters."""

pool = await create_db_pool(dsn=dsn)
result = await list_sessions(
Expand All @@ -153,15 +153,15 @@
), f"Result is not a list of sessions, {result}, {session.situation}"


# @test("query: count sessions")
# async def _(dsn=pg_dsn, developer_id=test_developer_id, session=test_session):
# """Test counting the number of sessions for a developer."""
@test("query: count sessions")
async def _(dsn=pg_dsn, developer_id=test_developer_id, session=test_session):
"""Test counting the number of sessions for a developer."""

# pool = await create_db_pool(dsn=dsn)
# count = await count_sessions(
# developer_id=developer_id,
# connection_pool=pool,
# )
pool = await create_db_pool(dsn=dsn)
count = await count_sessions(
developer_id=developer_id,
connection_pool=pool,
)

assert isinstance(count, dict)
assert count["count"] >= 1
Expand Down Expand Up @@ -190,9 +190,9 @@ async def _(
connection_pool=pool,
)

# assert result is not None
# assert isinstance(result, ResourceUpdatedResponse)
# assert result.updated_at > session.created_at
assert result is not None
assert isinstance(result, ResourceUpdatedResponse)
assert result.updated_at > session.created_at

updated_session = await get_session(
developer_id=developer_id,
Expand All @@ -202,11 +202,11 @@ async def _(
assert updated_session.forward_tool_calls is True


# @test("query: patch session sql")
# async def _(
# dsn=pg_dsn, developer_id=test_developer_id, session=test_session, agent=test_agent
# ):
# """Test that a session can be successfully patched."""
@test("query: patch session sql")
async def _(
dsn=pg_dsn, developer_id=test_developer_id, session=test_session, agent=test_agent
):
"""Test that a session can be successfully patched."""

pool = await create_db_pool(dsn=dsn)
data = PatchSessionRequest(
Expand All @@ -219,9 +219,9 @@ async def _(
connection_pool=pool,
)

# assert result is not None
# assert isinstance(result, ResourceUpdatedResponse)
# assert result.updated_at > session.created_at
assert result is not None
assert isinstance(result, ResourceUpdatedResponse)
assert result.updated_at > session.created_at

patched_session = await get_session(
developer_id=developer_id,
Expand All @@ -232,23 +232,23 @@ async def _(
assert patched_session.metadata == {"test": "metadata"}


# @test("query: delete session sql")
# async def _(dsn=pg_dsn, developer_id=test_developer_id, session=test_session):
# """Test that a session can be successfully deleted."""
@test("query: delete session sql")
async def _(dsn=pg_dsn, developer_id=test_developer_id, session=test_session):
"""Test that a session can be successfully deleted."""

# pool = await create_db_pool(dsn=dsn)
# delete_result = await delete_session(
# developer_id=developer_id,
# session_id=session.id,
# connection_pool=pool,
# )
pool = await create_db_pool(dsn=dsn)
delete_result = await delete_session(
developer_id=developer_id,
session_id=session.id,
connection_pool=pool,
)

# assert delete_result is not None
# assert isinstance(delete_result, ResourceDeletedResponse)
assert delete_result is not None
assert isinstance(delete_result, ResourceDeletedResponse)

# with raises(Exception):
# await get_session(
# developer_id=developer_id,
# session_id=session.id,
# connection_pool=pool,
# )
with raises(Exception):
await get_session(
developer_id=developer_id,
session_id=session.id,
connection_pool=pool,
)

0 comments on commit c88e8d7

Please sign in to comment.