Added test cases for finding empty spool fields

This commit is contained in:
Donkie
2023-09-08 20:32:19 +02:00
parent f47eacd2a9
commit 9a7375d781
3 changed files with 188 additions and 29 deletions

View File

@@ -67,6 +67,23 @@ def random_vendor():
httpx.delete(f"{URL}/api/v1/vendor/{vendor['id']}").raise_for_status()
@pytest.fixture()
def random_empty_vendor():
"""Return a random vendor with only required fields specified."""
# Add vendor
result = httpx.post(
f"{URL}/api/v1/vendor",
json={"name": ""},
)
result.raise_for_status()
vendor = result.json()
yield vendor
# Delete vendor
httpx.delete(f"{URL}/api/v1/vendor/{vendor['id']}").raise_for_status()
@pytest.fixture()
def random_filament(random_vendor: dict[str, Any]):
"""Return a random filament."""
@@ -95,6 +112,47 @@ def random_filament(random_vendor: dict[str, Any]):
httpx.delete(f"{URL}/api/v1/filament/{filament['id']}").raise_for_status()
@pytest.fixture()
def random_empty_filament():
"""Return a random filament with only required fields specified."""
# Add filament
result = httpx.post(
f"{URL}/api/v1/filament",
json={
"density": 1.25,
"diameter": 1.75,
},
)
result.raise_for_status()
filament = result.json()
yield filament
# Delete filament
httpx.delete(f"{URL}/api/v1/filament/{filament['id']}").raise_for_status()
@pytest.fixture()
def random_empty_filament_empty_vendor(random_empty_vendor: dict[str, Any]):
"""Return a random filament with only required fields specified and a vendor with only required fields specified."""
# Add filament
result = httpx.post(
f"{URL}/api/v1/filament",
json={
"vendor_id": random_empty_vendor["id"],
"density": 1.25,
"diameter": 1.75,
},
)
result.raise_for_status()
filament = result.json()
yield filament
# Delete filament
httpx.delete(f"{URL}/api/v1/filament/{filament['id']}").raise_for_status()
def length_from_weight(*, weight: float, diameter: float, density: float) -> float:
"""Calculate the length of a piece of filament.