Files
Zamil Majdyandmajdyz 8df7f7350f [AGPT-594] Introduce Event Logging (#169)
* Introduce event logging, captured event: All non-Get HTTP operations.
* Refactor routes.py on each API: removed redundant try-catch for unknown exception, use JsonResponse
* Fix broken api_test.py due to DB seeding being removed.

---------

Co-authored-by: majdyz <[email protected]>
2024-04-04 17:38:06 +02:00

72 lines
3.1 KiB
Python

import pytest
from dotenv import load_dotenv
from codex.app import db_client
from codex.common.ai_model import OpenAIChatClient
from codex.common.logging_config import setup_logging
from codex.common.model import ObjectFieldModel, ObjectTypeModel, create_object_type
load_dotenv()
setup_logging(local=True)
@pytest.mark.asyncio
@pytest.mark.integration_test
async def test_create_nested_object_type():
if not OpenAIChatClient._configured:
OpenAIChatClient.configure({})
await db_client.connect()
object_type = ObjectTypeModel(
name="SyncExternalCalendarRequest",
description="Request model for synchronizing a professional's schedule with an external calendar service. Includes credentials for accessing the external calendar, as well as the ID of the professional's schedule to be synchronized.",
Fields=[
ObjectFieldModel(
name="scheduleId",
description="The unique identifier for the professional's schedule to synchronize.",
type="int",
),
ObjectFieldModel(
name="syncOptions",
description="Optional parameters defining how the synchronization should be performed.",
type="SyncOptions",
related_types=[
ObjectTypeModel(
name="SyncOptions",
description="Defines options for how the synchronization with an external calendar is performed.",
Fields=[
ObjectFieldModel(
name="importAppointments",
description="Whether to import appointments from the external calendar into the ProfAvail schedule.",
type="bool",
),
ObjectFieldModel(
name="exportAppointments",
description="Whether to export appointments from the ProfAvail schedule to the external calendar.",
type="bool",
),
ObjectFieldModel(
name="syncRange",
description="The range of dates to synchronize, formatted as 'YYYY-MM-DD to YYYY-MM-DD'.",
type="str",
),
],
)
],
),
],
)
created_objects = await create_object_type(object_type, {})
assert created_objects is not None
assert len(created_objects) == 2
assert "SyncExternalCalendarRequest" in created_objects
assert created_objects["SyncExternalCalendarRequest"] is not None
assert len(created_objects["SyncExternalCalendarRequest"].Fields) == 2 # type: ignore
assert (
len(created_objects["SyncExternalCalendarRequest"].Fields[1].RelatedTypes) == 1 # type: ignore
)
assert "SyncOptions" in created_objects
assert created_objects["SyncOptions"] is not None