diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4ea28ff --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +__pycache__/ +*.pyc +*.pyo +*.pyd +.pytest_cache/ +.DS_Store +.env +node_modules/ +dist/ +build/ diff --git a/balancer/__pycache__/core.cpython-311.pyc b/balancer/__pycache__/core.cpython-311.pyc deleted file mode 100644 index 87c07de..0000000 Binary files a/balancer/__pycache__/core.cpython-311.pyc and /dev/null differ diff --git a/balancer/__pycache__/test_balancer.cpython-311-pytest-9.0.2.pyc b/balancer/__pycache__/test_balancer.cpython-311-pytest-9.0.2.pyc deleted file mode 100644 index 6f98c7b..0000000 Binary files a/balancer/__pycache__/test_balancer.cpython-311-pytest-9.0.2.pyc and /dev/null differ diff --git a/balancer/core.py b/balancer/core.py index a6840c4..29373a9 100644 --- a/balancer/core.py +++ b/balancer/core.py @@ -6,6 +6,17 @@ class InventoryItem: def __init__(self, sku: str, batch_id: str, current_stock: int, expiry_date: datetime.date, daily_burn_rate: float): + if not sku or not isinstance(sku, str): + raise ValueError("SKU must be a non-empty string.") + if not batch_id or not isinstance(batch_id, str): + raise ValueError("Batch ID must be a non-empty string.") + if not isinstance(current_stock, int) or current_stock < 0: + raise ValueError("Current stock must be a non-negative integer.") + if not isinstance(expiry_date, datetime.date): + raise TypeError("Expiry date must be a datetime.date object.") + if not isinstance(daily_burn_rate, (int, float)) or daily_burn_rate < 0: + raise ValueError("Daily burn rate must be a non-negative number.") + self.sku = sku self.batch_id = batch_id self.current_stock = current_stock