Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -421,10 +421,6 @@ async def extract_data(
value = await CollectionUtils.get_value(
caller, cast(Collection, foreign_collection), [value], field["foreign_key_target"]
)
try:
value = int(value)
except ValueError:
pass
record[field["foreign_key"]] = value

return record, one_to_one_relations
Expand Down
47 changes: 47 additions & 0 deletions src/agent_toolkit/tests/resources/collections/test_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,53 @@ def test_add_with_uuid_should_work_with_uuid_as_obj_or_str(self):
],
)

def test_add_should_not_change_json_api_deserialization_data(self):
request = RequestCollection(
RequestMethod.POST,
self.collection_book,
body={
"data": {
"attributes": {
"name": "Foundation",
},
"relationships": {
"author": {"data": {"type": "author", "id": "123e4567-e89b-12d3-a456-426614174000"}}
},
},
"type": "book",
},
query={
"collection_name": "book",
"timezone": "Europe/Paris",
},
headers={},
client_ip="127.0.0.1",
)
crud_resource = CrudResource(
self.datasource_composite,
self.datasource,
self.permission_service,
self.ip_white_list_service,
self.options,
)
with patch.object(
self.collection_book,
"create",
new_callable=AsyncMock,
return_value=[
{
"name": "Foundation",
"id": "123e4567-e89b-12d3-a456-42661417400a",
"author_id": "123e4567-e89b-12d3-a456-426614174000",
}
],
) as mock_create:
self.loop.run_until_complete(crud_resource.add(request))
mock_create.assert_awaited_with(
FAKE_USER, [{"name": "Foundation", "author_id": UUID("123e4567-e89b-12d3-a456-426614174000")}]
)
mock_create.assert_awaited_once()

# list
def test_list(self):
mock_orders = [{"id": 10, "cost": 200}, {"id": 11, "cost": 201}]
Expand Down