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

feat(agents-api): Add route tests #451

Merged
merged 3 commits into from
Aug 10, 2024

Conversation

creatorrr
Copy link
Contributor

@creatorrr creatorrr commented Aug 9, 2024

Signed-off-by: Diwank Tomer diwank@julep.ai


🚀 This description was created by Ellipsis for commit d0b3e6b

Summary:

This PR adds comprehensive route tests for agents and users, updates client management, and modifies API key handling for improved test coverage and client management.

Key points:

  • Added route tests for agents and users in agents-api/tests.
  • Updated client management with get_cozo_client in agents_api/clients/cozo.py.
  • Modified API key handling in agents_api/env.py to generate a random key if not set.
  • Enhanced create_agent function to include jobs in response.
  • Replaced julep clients with fastapi.testclient.TestClient in tests.
  • Added comprehensive route tests for agent and user operations, including creation, update, deletion, and retrieval.
  • Validated status codes for user operations, ensuring unauthorized access returns 403 and correct codes for other operations.
  • Used ward for test definitions and make_request for HTTP requests.

Generated with ❤️ by ellipsis.dev

Signed-off-by: Diwank Tomer <diwank@julep.ai>
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Changes requested. Reviewed everything up to afe3be8 in 30 seconds

More details
  • Looked at 1519 lines of code in 10 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_UFngILdBdb2AIblW


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@@ -32,7 +32,12 @@
temporal_task_queue = env.str("TEMPORAL_TASK_QUEUE", default="memory-task-queue")

# auth
api_key: str = env.str("AGENTS_API_KEY")
_random_generated_key = "".join(str(random.randint(0, 9)) for _ in range(32))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a randomly generated API key as a fallback is potentially insecure and could lead to unpredictable behavior. Consider requiring the API key to be set explicitly and fail initialization if it's not provided.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good to me! Incremental review on dd52045 in 27 seconds

More details
  • Looked at 173 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. agents-api/tests/test_user_routes.py:1
  • Draft comment:
    This file seems unrelated to the agents API as described in the PR title and description. Please confirm if this file was intended to be part of this PR.
  • Reason this comment was not posted:
    Confidence of 0% on close inspection, compared to threshold of 50%.

Workflow ID: wflow_af6B2ueAAUsVvuKI


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Signed-off-by: Diwank Tomer <diwank@julep.ai>
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Changes requested. Incremental review on d0b3e6b in 45 seconds

More details
  • Looked at 235 lines of code in 11 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_NiCph8MFML8BsyWa


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@@ -27,4 +27,4 @@ async def create_or_update_agent(
data=data,
)

return ResourceCreatedResponse(id=agent.id, created_at=agent.created_at)
return ResourceCreatedResponse(id=agent.id, created_at=agent.created_at, jobs=[])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The jobs field in the ResourceCreatedResponse is always set to an empty list, which might not reflect the actual state of jobs associated with the agent. Consider modifying the response to include actual job data if applicable.

Suggested change
return ResourceCreatedResponse(id=agent.id, created_at=agent.created_at, jobs=[])
return ResourceCreatedResponse(id=agent.id, created_at=agent.created_at, jobs=agent.jobs)

@@ -20,4 +20,4 @@ async def create_user(
data=data,
)

return ResourceCreatedResponse(id=user.id, created_at=user.created_at)
return ResourceCreatedResponse(id=user.id, created_at=user.created_at, jobs=[])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The jobs field in the ResourceCreatedResponse is always set to an empty list, which might not reflect the actual state of jobs associated with the user. Consider modifying the response to include actual job data if applicable.

Suggested change
return ResourceCreatedResponse(id=user.id, created_at=user.created_at, jobs=[])
return ResourceCreatedResponse(id=user.id, created_at=user.created_at, jobs=user.jobs)

@@ -14,4 +14,5 @@
async def delete_user(
user_id: UUID4, x_developer_id: Annotated[UUID4, Depends(get_developer_id)]
) -> ResourceDeletedResponse:
print(user_id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of print for logging in production code is not recommended as it can lead to unintentional logging of sensitive information. Consider using a logging framework with appropriate log levels.

@whiterabbit1983 whiterabbit1983 merged commit 0ee50d4 into dev-tasks-disable-routes Aug 10, 2024
2 of 6 checks passed
@whiterabbit1983 whiterabbit1983 deleted the f/route-tests branch August 10, 2024 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants