Merged spool price testing into existing test methods

This commit is contained in:
pdsccode
2024-01-07 14:24:14 +01:00
parent 05dfb611cf
commit 28a70d5190
2 changed files with 6 additions and 44 deletions

View File

@@ -33,6 +33,7 @@ def test_update_spool(random_filament: dict[str, Any]):
lot_nr = "987654321"
comment = "abcdefghåäö"
archived = True
price = 25
result = httpx.patch(
f"{URL}/api/v1/spool/{spool['id']}",
json={
@@ -43,6 +44,7 @@ def test_update_spool(random_filament: dict[str, Any]):
"lot_nr": lot_nr,
"comment": comment,
"archived": archived,
"price": price,
},
)
result.raise_for_status()
@@ -71,6 +73,7 @@ def test_update_spool(random_filament: dict[str, Any]):
assert spool["lot_nr"] == lot_nr
assert spool["comment"] == comment
assert spool["archived"] == archived
assert spool["price"] == price
# Clean up
httpx.delete(f"{URL}/api/v1/spool/{spool['id']}").raise_for_status()
@@ -100,37 +103,6 @@ def test_update_spool_both_used_and_remaining_weight(random_filament: dict[str,
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"],
"price": 50,
},
)
result.raise_for_status()
spool = result.json()
# Execute
price = 25
result = httpx.patch(
f"{URL}/api/v1/spool/{spool['id']}",
json={
"price": price,
},
)
result.raise_for_status()
# Verify
spool = result.json()
assert spool["price"] == 25
# 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."""
# Execute