chore: Upgrade pydantic Config to ConfigDict

This commit is contained in:
Chris Coutinho
2025-10-24 06:18:13 +02:00
parent 81ca799410
commit 13f76a7734
3 changed files with 26 additions and 25 deletions
+4 -8
View File
@@ -2,7 +2,7 @@
from typing import List, Optional, Union
from pydantic import BaseModel, Field
from pydantic import BaseModel, ConfigDict, Field
from .base import BaseResponse, IdResponse, StatusResponse
@@ -38,8 +38,7 @@ class Nutrition(BaseModel):
None, description="Unsaturated fat (e.g., '40 g')"
)
class Config:
populate_by_name = True
model_config = ConfigDict(populate_by_name=True)
class RecipeStub(BaseModel):
@@ -91,9 +90,7 @@ class Recipe(BaseModel):
)
nutrition: Optional[Nutrition] = Field(None, description="Nutrition information")
class Config:
populate_by_name = True
extra = "allow" # Allow additional schema.org fields
model_config = ConfigDict(populate_by_name=True, extra="allow")
class Category(BaseModel):
@@ -127,8 +124,7 @@ class VisibleInfoBlocks(BaseModel):
)
tools: Optional[bool] = Field(None, description="Show tools list")
class Config:
populate_by_name = True
model_config = ConfigDict(populate_by_name=True)
class CookbookConfig(BaseModel):
@@ -273,9 +273,9 @@ async def test_file_list_permissions(alice_mcp_client, bob_mcp_client):
if not result.isError:
response_data = json.loads(result.content[0].text)
if not isinstance(response_data, list):
response_data = [response_data] if response_data else []
file_names = [f["name"] for f in response_data]
# Extract files from DirectoryListing response
files = response_data.get("files", [])
file_names = [f["name"] for f in files]
logger.info(f"Alice can see files: {file_names}")
# Alice should see her own files
@@ -291,9 +291,9 @@ async def test_file_list_permissions(alice_mcp_client, bob_mcp_client):
if not result.isError:
response_data = json.loads(result.content[0].text)
if not isinstance(response_data, list):
response_data = [response_data] if response_data else []
file_names = [f["name"] for f in response_data]
# Extract files from DirectoryListing response
files = response_data.get("files", [])
file_names = [f["name"] for f in files]
logger.info(f"Bob can see files: {file_names}")
# Bob should see his own file, but not Alice's private file
@@ -379,12 +379,12 @@ async def test_folder_share_permissions(alice_mcp_client, bob_mcp_client):
if not result.isError:
response_data = json.loads(result.content[0].text)
if not isinstance(response_data, list):
response_data = [response_data] if response_data else []
logger.info(f"Bob can see {len(response_data)} files in shared folder")
# Extract files from DirectoryListing response
files = response_data.get("files", [])
logger.info(f"Bob can see {len(files)} files in shared folder")
# Bob should see the file in the shared folder
file_names = [f["name"] for f in response_data]
file_names = [f["name"] for f in files]
assert "document.txt" in file_names, (
"Bob should see the file in shared folder"
)
+12 -7
View File
@@ -470,16 +470,21 @@ async def test_mcp_webdav_workflow(
logger.info(f"Directory listing response: {listing_text}")
listing_data = json.loads(listing_text)
# Ensure listing_data is a list
if not isinstance(listing_data, list):
logger.warning(
f"Expected directory listing to be a list, got: {type(listing_data)}"
)
listing_data = [listing_data] if listing_data else []
# Extract files from DirectoryListing response
assert "files" in listing_data, "Expected 'files' field in directory listing"
files = listing_data["files"]
assert isinstance(files, list), (
f"Expected files to be a list, got: {type(files)}"
)
# Verify metadata
assert listing_data["path"] == test_dir
assert listing_data["total_count"] >= 1
assert listing_data["files_count"] >= 1
# Find our file in the listing
found_file = None
for item in listing_data:
for item in files:
if isinstance(item, dict) and item.get("name") == test_file:
found_file = item
break