Updated most python dependencies
Primarily FastAPI and Pydantic to v2. Also ruff to latest. Updated some code to support Pydantic v2
This commit is contained in:
@@ -240,6 +240,7 @@ def length_from_weight(*, weight: float, diameter: float, density: float) -> flo
|
||||
|
||||
Returns:
|
||||
float: Length in mm
|
||||
|
||||
"""
|
||||
volume_cm3 = weight / density
|
||||
volume_mm3 = volume_cm3 * 1000
|
||||
@@ -256,6 +257,7 @@ def assert_dicts_compatible(actual: Any, expected: Any, path: str = "") -> None:
|
||||
|
||||
Raises:
|
||||
AssertionError: If dictionaries are not compatible.
|
||||
|
||||
"""
|
||||
# Check if both inputs are dictionaries
|
||||
if not (isinstance(actual, dict) and isinstance(expected, dict)):
|
||||
|
||||
@@ -95,6 +95,44 @@ def test_update_filament(random_vendor: dict[str, Any]):
|
||||
httpx.delete(f"{URL}/api/v1/filament/{filament['id']}").raise_for_status()
|
||||
|
||||
|
||||
def test_update_filament_cant_set_none(random_vendor: dict[str, Any]):
|
||||
"""Test updating a filament and setting density and diameter fields to None, should result in 422 error."""
|
||||
# Setup
|
||||
result = httpx.post(
|
||||
f"{URL}/api/v1/filament",
|
||||
json={
|
||||
"name": "Filament X",
|
||||
"vendor_id": random_vendor["id"],
|
||||
"material": "PLA",
|
||||
"price": 100,
|
||||
"density": 1.25,
|
||||
"diameter": 1.75,
|
||||
"weight": 1000,
|
||||
"spool_weight": 250,
|
||||
"article_number": "123456789",
|
||||
"comment": "abcdefghåäö",
|
||||
"settings_extruder_temp": 200,
|
||||
"settings_bed_temp": 60,
|
||||
"color_hex": "FF0000",
|
||||
"external_id": "external_id1",
|
||||
},
|
||||
)
|
||||
result.raise_for_status()
|
||||
added_filament = result.json()
|
||||
|
||||
# Execute
|
||||
result = httpx.patch(
|
||||
f"{URL}/api/v1/filament/{added_filament['id']}",
|
||||
json={"density": None, "diameter": None},
|
||||
)
|
||||
|
||||
# Verify
|
||||
assert result.status_code == 422
|
||||
|
||||
# Clean up
|
||||
httpx.delete(f"{URL}/api/v1/filament/{added_filament['id']}").raise_for_status()
|
||||
|
||||
|
||||
def test_update_filament_not_found():
|
||||
"""Test updating a filament that does not exist."""
|
||||
# Execute
|
||||
|
||||
Reference in New Issue
Block a user