|
@@ -5,7 +5,7 @@ from httpx import AsyncClient
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestFilamentsAPI:
|
|
class TestFilamentsAPI:
|
|
|
- """Integration tests for /api/v1/filaments/ endpoints."""
|
|
|
|
|
|
|
+ """Integration tests for /api/v1/filament-catalog/ (material types) endpoints."""
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
@pytest.fixture
|
|
|
async def filament_factory(self, db_session):
|
|
async def filament_factory(self, db_session):
|
|
@@ -36,7 +36,7 @@ class TestFilamentsAPI:
|
|
|
@pytest.mark.integration
|
|
@pytest.mark.integration
|
|
|
async def test_list_filaments_empty(self, async_client: AsyncClient):
|
|
async def test_list_filaments_empty(self, async_client: AsyncClient):
|
|
|
"""Verify empty list when no filaments exist."""
|
|
"""Verify empty list when no filaments exist."""
|
|
|
- response = await async_client.get("/api/v1/filaments/")
|
|
|
|
|
|
|
+ response = await async_client.get("/api/v1/filament-catalog/")
|
|
|
assert response.status_code == 200
|
|
assert response.status_code == 200
|
|
|
assert isinstance(response.json(), list)
|
|
assert isinstance(response.json(), list)
|
|
|
|
|
|
|
@@ -45,7 +45,7 @@ class TestFilamentsAPI:
|
|
|
async def test_list_filaments_with_data(self, async_client: AsyncClient, filament_factory, db_session):
|
|
async def test_list_filaments_with_data(self, async_client: AsyncClient, filament_factory, db_session):
|
|
|
"""Verify list returns existing filaments."""
|
|
"""Verify list returns existing filaments."""
|
|
|
await filament_factory(name="Test Filament")
|
|
await filament_factory(name="Test Filament")
|
|
|
- response = await async_client.get("/api/v1/filaments/")
|
|
|
|
|
|
|
+ response = await async_client.get("/api/v1/filament-catalog/")
|
|
|
assert response.status_code == 200
|
|
assert response.status_code == 200
|
|
|
data = response.json()
|
|
data = response.json()
|
|
|
assert any(f["name"] == "Test Filament" for f in data)
|
|
assert any(f["name"] == "Test Filament" for f in data)
|
|
@@ -62,7 +62,7 @@ class TestFilamentsAPI:
|
|
|
"brand": "Bambu",
|
|
"brand": "Bambu",
|
|
|
"cost_per_kg": 30.0,
|
|
"cost_per_kg": 30.0,
|
|
|
}
|
|
}
|
|
|
- response = await async_client.post("/api/v1/filaments/", json=data)
|
|
|
|
|
|
|
+ response = await async_client.post("/api/v1/filament-catalog/", json=data)
|
|
|
assert response.status_code == 200
|
|
assert response.status_code == 200
|
|
|
result = response.json()
|
|
result = response.json()
|
|
|
assert result["name"] == "New PETG"
|
|
assert result["name"] == "New PETG"
|
|
@@ -73,7 +73,7 @@ class TestFilamentsAPI:
|
|
|
async def test_get_filament(self, async_client: AsyncClient, filament_factory, db_session):
|
|
async def test_get_filament(self, async_client: AsyncClient, filament_factory, db_session):
|
|
|
"""Verify single filament can be retrieved."""
|
|
"""Verify single filament can be retrieved."""
|
|
|
filament = await filament_factory(name="Get Test")
|
|
filament = await filament_factory(name="Get Test")
|
|
|
- response = await async_client.get(f"/api/v1/filaments/{filament.id}")
|
|
|
|
|
|
|
+ response = await async_client.get(f"/api/v1/filament-catalog/{filament.id}")
|
|
|
assert response.status_code == 200
|
|
assert response.status_code == 200
|
|
|
assert response.json()["name"] == "Get Test"
|
|
assert response.json()["name"] == "Get Test"
|
|
|
|
|
|
|
@@ -81,7 +81,7 @@ class TestFilamentsAPI:
|
|
|
@pytest.mark.integration
|
|
@pytest.mark.integration
|
|
|
async def test_get_filament_not_found(self, async_client: AsyncClient):
|
|
async def test_get_filament_not_found(self, async_client: AsyncClient):
|
|
|
"""Verify 404 for non-existent filament."""
|
|
"""Verify 404 for non-existent filament."""
|
|
|
- response = await async_client.get("/api/v1/filaments/9999")
|
|
|
|
|
|
|
+ response = await async_client.get("/api/v1/filament-catalog/9999")
|
|
|
assert response.status_code == 404
|
|
assert response.status_code == 404
|
|
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
@pytest.mark.asyncio
|
|
@@ -90,7 +90,7 @@ class TestFilamentsAPI:
|
|
|
"""Verify filament can be updated."""
|
|
"""Verify filament can be updated."""
|
|
|
filament = await filament_factory(name="Original")
|
|
filament = await filament_factory(name="Original")
|
|
|
response = await async_client.patch(
|
|
response = await async_client.patch(
|
|
|
- f"/api/v1/filaments/{filament.id}", json={"name": "Updated", "cost_per_kg": 35.0}
|
|
|
|
|
|
|
+ f"/api/v1/filament-catalog/{filament.id}", json={"name": "Updated", "cost_per_kg": 35.0}
|
|
|
)
|
|
)
|
|
|
assert response.status_code == 200
|
|
assert response.status_code == 200
|
|
|
result = response.json()
|
|
result = response.json()
|
|
@@ -102,8 +102,8 @@ class TestFilamentsAPI:
|
|
|
async def test_delete_filament(self, async_client: AsyncClient, filament_factory, db_session):
|
|
async def test_delete_filament(self, async_client: AsyncClient, filament_factory, db_session):
|
|
|
"""Verify filament can be deleted."""
|
|
"""Verify filament can be deleted."""
|
|
|
filament = await filament_factory()
|
|
filament = await filament_factory()
|
|
|
- response = await async_client.delete(f"/api/v1/filaments/{filament.id}")
|
|
|
|
|
|
|
+ response = await async_client.delete(f"/api/v1/filament-catalog/{filament.id}")
|
|
|
assert response.status_code == 200
|
|
assert response.status_code == 200
|
|
|
# Verify deleted
|
|
# Verify deleted
|
|
|
- response = await async_client.get(f"/api/v1/filaments/{filament.id}")
|
|
|
|
|
|
|
+ response = await async_client.get(f"/api/v1/filament-catalog/{filament.id}")
|
|
|
assert response.status_code == 404
|
|
assert response.status_code == 404
|