chore: Upgrade pydantic Config to ConfigDict
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
from typing import List, Optional, Union
|
from typing import List, Optional, Union
|
||||||
|
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, ConfigDict, Field
|
||||||
|
|
||||||
from .base import BaseResponse, IdResponse, StatusResponse
|
from .base import BaseResponse, IdResponse, StatusResponse
|
||||||
|
|
||||||
@@ -38,8 +38,7 @@ class Nutrition(BaseModel):
|
|||||||
None, description="Unsaturated fat (e.g., '40 g')"
|
None, description="Unsaturated fat (e.g., '40 g')"
|
||||||
)
|
)
|
||||||
|
|
||||||
class Config:
|
model_config = ConfigDict(populate_by_name=True)
|
||||||
populate_by_name = True
|
|
||||||
|
|
||||||
|
|
||||||
class RecipeStub(BaseModel):
|
class RecipeStub(BaseModel):
|
||||||
@@ -91,9 +90,7 @@ class Recipe(BaseModel):
|
|||||||
)
|
)
|
||||||
nutrition: Optional[Nutrition] = Field(None, description="Nutrition information")
|
nutrition: Optional[Nutrition] = Field(None, description="Nutrition information")
|
||||||
|
|
||||||
class Config:
|
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
||||||
populate_by_name = True
|
|
||||||
extra = "allow" # Allow additional schema.org fields
|
|
||||||
|
|
||||||
|
|
||||||
class Category(BaseModel):
|
class Category(BaseModel):
|
||||||
@@ -127,8 +124,7 @@ class VisibleInfoBlocks(BaseModel):
|
|||||||
)
|
)
|
||||||
tools: Optional[bool] = Field(None, description="Show tools list")
|
tools: Optional[bool] = Field(None, description="Show tools list")
|
||||||
|
|
||||||
class Config:
|
model_config = ConfigDict(populate_by_name=True)
|
||||||
populate_by_name = True
|
|
||||||
|
|
||||||
|
|
||||||
class CookbookConfig(BaseModel):
|
class CookbookConfig(BaseModel):
|
||||||
|
|||||||
@@ -273,9 +273,9 @@ async def test_file_list_permissions(alice_mcp_client, bob_mcp_client):
|
|||||||
|
|
||||||
if not result.isError:
|
if not result.isError:
|
||||||
response_data = json.loads(result.content[0].text)
|
response_data = json.loads(result.content[0].text)
|
||||||
if not isinstance(response_data, list):
|
# Extract files from DirectoryListing response
|
||||||
response_data = [response_data] if response_data else []
|
files = response_data.get("files", [])
|
||||||
file_names = [f["name"] for f in response_data]
|
file_names = [f["name"] for f in files]
|
||||||
logger.info(f"Alice can see files: {file_names}")
|
logger.info(f"Alice can see files: {file_names}")
|
||||||
|
|
||||||
# Alice should see her own files
|
# 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:
|
if not result.isError:
|
||||||
response_data = json.loads(result.content[0].text)
|
response_data = json.loads(result.content[0].text)
|
||||||
if not isinstance(response_data, list):
|
# Extract files from DirectoryListing response
|
||||||
response_data = [response_data] if response_data else []
|
files = response_data.get("files", [])
|
||||||
file_names = [f["name"] for f in response_data]
|
file_names = [f["name"] for f in files]
|
||||||
logger.info(f"Bob can see files: {file_names}")
|
logger.info(f"Bob can see files: {file_names}")
|
||||||
|
|
||||||
# Bob should see his own file, but not Alice's private file
|
# 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:
|
if not result.isError:
|
||||||
response_data = json.loads(result.content[0].text)
|
response_data = json.loads(result.content[0].text)
|
||||||
if not isinstance(response_data, list):
|
# Extract files from DirectoryListing response
|
||||||
response_data = [response_data] if response_data else []
|
files = response_data.get("files", [])
|
||||||
logger.info(f"Bob can see {len(response_data)} files in shared folder")
|
logger.info(f"Bob can see {len(files)} files in shared folder")
|
||||||
|
|
||||||
# Bob should see the file in the 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, (
|
assert "document.txt" in file_names, (
|
||||||
"Bob should see the file in shared folder"
|
"Bob should see the file in shared folder"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -470,16 +470,21 @@ async def test_mcp_webdav_workflow(
|
|||||||
logger.info(f"Directory listing response: {listing_text}")
|
logger.info(f"Directory listing response: {listing_text}")
|
||||||
listing_data = json.loads(listing_text)
|
listing_data = json.loads(listing_text)
|
||||||
|
|
||||||
# Ensure listing_data is a list
|
# Extract files from DirectoryListing response
|
||||||
if not isinstance(listing_data, list):
|
assert "files" in listing_data, "Expected 'files' field in directory listing"
|
||||||
logger.warning(
|
files = listing_data["files"]
|
||||||
f"Expected directory listing to be a list, got: {type(listing_data)}"
|
assert isinstance(files, list), (
|
||||||
)
|
f"Expected files to be a list, got: {type(files)}"
|
||||||
listing_data = [listing_data] if listing_data else []
|
)
|
||||||
|
|
||||||
|
# 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
|
# Find our file in the listing
|
||||||
found_file = None
|
found_file = None
|
||||||
for item in listing_data:
|
for item in files:
|
||||||
if isinstance(item, dict) and item.get("name") == test_file:
|
if isinstance(item, dict) and item.get("name") == test_file:
|
||||||
found_file = item
|
found_file = item
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in New Issue
Block a user