Changed to show filament price if no spool price set and added tests
This commit is contained in:
@@ -185,3 +185,15 @@ def test_add_spool_both_used_and_remaining_weight(random_filament: dict[str, Any
|
||||
},
|
||||
)
|
||||
assert result.status_code == 400 # Cannot set both used and remaining weight
|
||||
|
||||
def test_add_spool_price(random_filament: dict[str, Any]):
|
||||
"""Test adding a spool to the database."""
|
||||
# Execute
|
||||
result = httpx.post(
|
||||
f"{URL}/api/v1/spool",
|
||||
json={
|
||||
"filament_id": random_filament["id"],
|
||||
"price": 25,
|
||||
},
|
||||
)
|
||||
assert result.status_code == 400 # Cannot set price
|
||||
@@ -16,6 +16,7 @@ def test_get_spool(random_filament: dict[str, Any]):
|
||||
location = "The Pantry"
|
||||
lot_nr = "123456789"
|
||||
comment = "abcdefghåäö"
|
||||
price = 25
|
||||
archived = True
|
||||
result = httpx.post(
|
||||
f"{URL}/api/v1/spool",
|
||||
@@ -27,6 +28,7 @@ def test_get_spool(random_filament: dict[str, Any]):
|
||||
"location": location,
|
||||
"lot_nr": lot_nr,
|
||||
"comment": comment,
|
||||
"price": price,
|
||||
"archived": archived,
|
||||
},
|
||||
)
|
||||
|
||||
@@ -99,6 +99,27 @@ def test_update_spool_both_used_and_remaining_weight(random_filament: dict[str,
|
||||
# Clean up
|
||||
httpx.delete(f"{URL}/api/v1/spool/{spool['id']}").raise_for_status()
|
||||
|
||||
def test_update_spool_price(random_filament: dict[str, Any]):
|
||||
"""Test updating a spool in the database."""
|
||||
# Setup
|
||||
result = httpx.post(
|
||||
f"{URL}/api/v1/spool",
|
||||
json={"filament_id": random_filament["id"]},
|
||||
)
|
||||
result.raise_for_status()
|
||||
spool = result.json()
|
||||
|
||||
# Execute
|
||||
result = httpx.patch(
|
||||
f"{URL}/api/v1/spool/{spool['id']}",
|
||||
json={
|
||||
"price": 750,
|
||||
},
|
||||
)
|
||||
assert result.status_code == 400 # Cannot update both used and remaining weight
|
||||
|
||||
# Clean up
|
||||
httpx.delete(f"{URL}/api/v1/spool/{spool['id']}").raise_for_status()
|
||||
|
||||
def test_update_spool_not_found(random_filament: dict[str, Any]):
|
||||
"""Test updating a spool that does not exist."""
|
||||
|
||||
Reference in New Issue
Block a user