-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathtest_installation.py
More file actions
79 lines (66 loc) · 2.3 KB
/
test_installation.py
File metadata and controls
79 lines (66 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Test script to verify that vpplib can be installed and used with the minimal requirements.
"""
import sys
import importlib
def test_imports():
"""Test importing key modules from vpplib."""
modules = [
'vpplib',
'vpplib.component',
'vpplib.environment',
'vpplib.heat_pump',
'vpplib.photovoltaic',
'vpplib.wind_power',
'vpplib.electrical_energy_storage'
]
failed_imports = []
for module in modules:
try:
importlib.import_module(module)
print(f"✓ Successfully imported {module}")
except ImportError as e:
failed_imports.append((module, str(e)))
print(f"✗ Failed to import {module}: {e}")
if failed_imports:
print("\nThe following imports failed:")
for module, error in failed_imports:
print(f" - {module}: {error}")
return False
else:
print("\nAll imports successful!")
return True
def test_component_creation():
"""Test creating basic components."""
from vpplib.environment import Environment
# Create environment
try:
env = Environment(timebase=15, timezone='Europe/Berlin')
print("✓ Successfully created Environment")
except Exception as e:
print(f"✗ Failed to create Environment: {e}")
return False
# Test importing component classes
try:
from vpplib.photovoltaic import Photovoltaic
from vpplib.wind_power import WindPower
from vpplib.electrical_energy_storage import ElectricalEnergyStorage
from vpplib.heat_pump import HeatPump
print("✓ Successfully imported all component classes")
return True
except Exception as e:
print(f"✗ Failed to import component classes: {e}")
return False
if __name__ == "__main__":
print("Testing vpplib installation...\n")
import_success = test_imports()
print("\n" + "-"*50 + "\n")
component_success = test_component_creation()
if import_success and component_success:
print("\nAll tests passed! vpplib is installed correctly.")
sys.exit(0)
else:
print("\nSome tests failed. Please check the error messages above.")
sys.exit(1)