Added additional integration tests for measure and add

This commit is contained in:
Matt Gerega
2024-03-28 09:29:39 -04:00
parent 19c414da4b
commit a6ae808389
4 changed files with 204 additions and 5 deletions

View File

@@ -368,12 +368,13 @@ async def measure(db: AsyncSession, spool_id: int, weight: float) -> models.Spoo
if initial_weight is None:
initial_weight = filament_info[0] + empty_weight
# if the measurement is greater than the initial weight, raise an error
if weight > initial_weight:
raise SpoolMeasureError("Measured weight is greater than the initial weight of the spool.")
# Calculate the current gross weight (initial_weight - used_weight)
current_use = initial_weight - spool_info[1]
# if the measurement is greater than the initial weight, raise an error
if weight > current_use:
raise SpoolMeasureError("Measured weight cannot increase.")
# Calculate the weight used since last measure
weight_to_use = current_use - weight