101 lines
1.4 KiB
Python
101 lines
1.4 KiB
Python
from pathlib import Path
|
|
|
|
from app.auto.config import (
|
|
load_auto_config,
|
|
)
|
|
|
|
|
|
PROJECT_ROOT = (
|
|
Path(__file__)
|
|
.resolve()
|
|
.parents[1]
|
|
)
|
|
|
|
AUTO_CONFIG_FILE = (
|
|
PROJECT_ROOT
|
|
/ "config"
|
|
/ "auto.yaml"
|
|
)
|
|
|
|
|
|
def main():
|
|
|
|
config = load_auto_config(
|
|
AUTO_CONFIG_FILE
|
|
)
|
|
|
|
print()
|
|
print("=" * 70)
|
|
print("AUTO CONFIG")
|
|
print("=" * 70)
|
|
|
|
print(
|
|
"Version:",
|
|
config.version,
|
|
)
|
|
|
|
print(
|
|
"Check interval:",
|
|
config.check_interval,
|
|
)
|
|
|
|
print(
|
|
"Base speed:",
|
|
config.co2.base_speed,
|
|
)
|
|
|
|
print(
|
|
"Hysteresis:",
|
|
config.co2.hysteresis,
|
|
)
|
|
|
|
print(
|
|
"Thresholds:"
|
|
)
|
|
|
|
for ppm, speed in (
|
|
config.co2.thresholds
|
|
):
|
|
print(
|
|
f" CO2 >= {ppm:<4} "
|
|
f"-> speed {speed}"
|
|
)
|
|
|
|
assert config.version == 1
|
|
|
|
assert (
|
|
config.check_interval
|
|
== 5.0
|
|
)
|
|
|
|
assert (
|
|
config.co2.base_speed
|
|
== 1
|
|
)
|
|
|
|
assert (
|
|
config.co2.hysteresis
|
|
== 100
|
|
)
|
|
|
|
assert (
|
|
config.co2.thresholds
|
|
== (
|
|
(800, 2),
|
|
(1000, 3),
|
|
(1300, 4),
|
|
(1600, 5),
|
|
(2000, 6),
|
|
)
|
|
)
|
|
|
|
print()
|
|
print("=" * 70)
|
|
print(
|
|
"AUTO CONFIG TEST PASSED"
|
|
)
|
|
print("=" * 70)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main() |