-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove old automations, and adding a test that checks automation yaml…
… against the Python code
- Loading branch information
1 parent
4dcf43b
commit 3b9d134
Showing
9 changed files
with
75 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import annotations | ||
|
||
from .constant_duty_cycle import ConstantDutyCycle | ||
from .only_record_temperature import OnlyRecordTemperature | ||
from .thermostat import Thermostat |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# -*- coding: utf-8 -*- | ||
# test automation_yamls | ||
from __future__ import annotations | ||
|
||
from yaml import load # type: ignore | ||
from yaml import Loader # type: ignore | ||
|
||
from pioreactor.automations import * # noqa: F403, F401 | ||
from pioreactor.background_jobs.dosing_control import DosingController | ||
from pioreactor.background_jobs.led_control import LEDController | ||
from pioreactor.background_jobs.temperature_control import TemperatureController | ||
from pioreactor.mureq import get | ||
|
||
|
||
def get_specific_yaml(path): | ||
data = get(f"https://raw.githubusercontent.com/Pioreactor/pioreactorui/master/{path}") | ||
return load(data.content, Loader=Loader) | ||
|
||
|
||
def test_automations_and_their_yamls_have_the_same_data(): | ||
for automation_name, klass in LEDController.available_automations.items(): | ||
data = get_specific_yaml(f"contrib/automations/led/{automation_name}.yaml") | ||
assert data["automation_name"] == automation_name | ||
|
||
for field in data["fields"]: | ||
key = field["key"] | ||
assert field["unit"] == klass.published_settings[key]["unit"] | ||
|
||
for setting in klass.published_settings: | ||
assert any([f["key"] == setting for f in data["fields"]]) | ||
|
||
for automation_name, klass in DosingController.available_automations.items(): | ||
data = get_specific_yaml(f"contrib/automations/dosing/{automation_name}.yaml") | ||
assert data["automation_name"] == automation_name | ||
|
||
for field in data["fields"]: | ||
key = field["key"] | ||
assert field["unit"] == klass.published_settings[key]["unit"] | ||
|
||
for setting in klass.published_settings: | ||
assert any([f["key"] == setting for f in data["fields"]]) | ||
|
||
for automation_name, klass in TemperatureController.available_automations.items(): | ||
data = get_specific_yaml(f"contrib/automations/temperature/{automation_name}.yaml") | ||
assert data["automation_name"] == automation_name | ||
|
||
for field in data["fields"]: | ||
key = field["key"] | ||
assert field["unit"] == klass.published_settings[key]["unit"] | ||
|
||
for setting in klass.published_settings: | ||
assert any([f["key"] == setting for f in data["fields"]]) | ||
|
||
|
||
# TODO: turn off plugin loading with a env variable. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters