feat(phase-0): initialize project foundation, packaging, logging, configs, and tests

This commit is contained in:
Warehouse Twin Dev
2026-10-19 14:55:54 +05:30
commit 7ef65ce65d
42 changed files with 2607 additions and 0 deletions
+50
View File
@@ -0,0 +1,50 @@
"""Unit tests for environment validation and system requirements."""
from __future__ import annotations
import sys
from unittest.mock import MagicMock, patch
import pytest
from warehouse_twin import __version__
from warehouse_twin.cli import check_environment
def test_package_metadata():
"""Verify that package version and name are properly defined."""
assert __version__ == "0.1.0"
def test_python_version():
"""Ensure runtime Python meets the minimum requirement of >= 3.10."""
major, minor = sys.version_info[:2]
assert (major, minor) >= (3, 10), f"Python version {major}.{minor} is below minimum 3.10"
def test_required_dependencies_importable():
"""Verify that core simulation dependencies can be imported successfully."""
import simpy
import networkx
import pytest as pt
assert simpy.__version__ is not None
assert networkx.__version__ is not None
assert pt.__version__ is not None
def test_check_environment_passes():
"""Verify that the check_environment CLI routine executes and passes."""
exit_code = check_environment()
assert exit_code == 0
def test_check_environment_detects_low_disk(monkeypatch):
"""Verify that critical low disk space (<2GB) generates a failure return code."""
# Mock shutil.disk_usage to return 1 GB free
fake_usage = MagicMock()
fake_usage.free = 1 * (1024**3) # 1 GB
fake_usage.total = 100 * (1024**3)
with patch("shutil.disk_usage", return_value=fake_usage):
exit_code = check_environment()
assert exit_code == 1, "check_environment should fail when disk space is below 2 GB"