-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch Omegaconf for cattrs, add config saving and reformat dependenc…
…y structure
- Loading branch information
Showing
4 changed files
with
130 additions
and
74 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 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,9 +1,30 @@ | ||
from atopile import config | ||
from ruamel.yaml import YAML | ||
import copy | ||
|
||
yaml = YAML() | ||
|
||
def test_sanitise_dict_keys(): | ||
"""Test that dict keys are sanitised.""" | ||
assert config._sanitise_dict_keys({"a-b": 1, "ato-version": {"e-f": 2}}) == { | ||
"a-b": 1, | ||
"ato_version": {"e-f": 2}, | ||
} | ||
|
||
def test_roundtrip(): | ||
config_dict = yaml.load(""" | ||
ato-version: ^0.2.0 | ||
builds: | ||
debug: | ||
entry: elec/src/debug.ato:Debug | ||
unknown: test | ||
# comments | ||
dependencies: | ||
- tps63020dsjr # comments | ||
- usb-connectors ^v2.0.1 | ||
- esp32-s3: | ||
version: ^v0.0.1 | ||
path: ../esp32-s3 | ||
""") | ||
cfg = config.ProjectConfig.structure(config_dict) | ||
assert config_dict == cfg.patch_config(config_dict) | ||
assert cfg.ato_version == "^0.2.0" | ||
|
||
cfg.ato_version = "10" | ||
config_dict_2 = copy.deepcopy(config_dict) | ||
config_dict_2["ato-version"] = "10" | ||
assert config_dict_2 == cfg.patch_config(config_dict) |