|
|
""" |
|
|
Debug script for HVAC Load Calculator. |
|
|
This script runs the tests and fixes any issues found. |
|
|
""" |
|
|
|
|
|
import os |
|
|
import sys |
|
|
import unittest |
|
|
from pathlib import Path |
|
|
|
|
|
|
|
|
sys.path.append(str(Path(__file__).parent.parent)) |
|
|
|
|
|
|
|
|
from tests.test_calculator import TestBuildingModel, TestCoolingLoadCalculator, TestDataIO |
|
|
from tests.test_integration import TestIntegration |
|
|
|
|
|
def run_tests(): |
|
|
"""Run all tests and report results.""" |
|
|
|
|
|
suite = unittest.TestSuite() |
|
|
|
|
|
|
|
|
suite.addTest(unittest.makeSuite(TestBuildingModel)) |
|
|
suite.addTest(unittest.makeSuite(TestCoolingLoadCalculator)) |
|
|
suite.addTest(unittest.makeSuite(TestDataIO)) |
|
|
suite.addTest(unittest.makeSuite(TestIntegration)) |
|
|
|
|
|
|
|
|
runner = unittest.TextTestRunner(verbosity=2) |
|
|
result = runner.run(suite) |
|
|
|
|
|
|
|
|
return result |
|
|
|
|
|
def fix_issues(): |
|
|
"""Fix any issues found during testing.""" |
|
|
|
|
|
os.makedirs("test_output", exist_ok=True) |
|
|
|
|
|
|
|
|
result = run_tests() |
|
|
|
|
|
|
|
|
if result.failures or result.errors: |
|
|
print("Tests failed. Fixing issues...") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print("Running tests again to verify fixes...") |
|
|
result = run_tests() |
|
|
|
|
|
if result.failures or result.errors: |
|
|
print("Issues still exist. Manual intervention required.") |
|
|
return False |
|
|
else: |
|
|
print("All issues fixed.") |
|
|
return True |
|
|
else: |
|
|
print("All tests passed. No issues to fix.") |
|
|
return True |
|
|
|
|
|
if __name__ == "__main__": |
|
|
fix_issues() |
|
|
|