2024-04-18 20:31:19 +00:00
|
|
|
from collections import defaultdict
|
|
|
|
|
2024-04-18 09:06:42 +00:00
|
|
|
from co3.components import Relation
|
|
|
|
|
|
|
|
from setups import vegetables as veg
|
|
|
|
|
|
|
|
|
2024-04-18 20:31:19 +00:00
|
|
|
tomato = veg.Tomato('t1', 10)
|
2024-04-18 09:06:42 +00:00
|
|
|
|
2024-04-18 20:31:19 +00:00
|
|
|
def test_co3_registry():
|
|
|
|
keys_to_groups = defaultdict(list)
|
2024-04-18 09:06:42 +00:00
|
|
|
|
2024-04-18 20:31:19 +00:00
|
|
|
# collect groups each key is associated
|
2024-05-01 23:46:25 +00:00
|
|
|
for group, keys in tomato.group_registry.items():
|
|
|
|
for key in keys:
|
|
|
|
keys_to_groups[key].append(group)
|
2024-04-18 09:06:42 +00:00
|
|
|
|
2024-05-01 23:46:25 +00:00
|
|
|
assert set(tomato.key_registry.get(None,{}).keys()) == set(keys_to_groups.get(None,[]))
|
|
|
|
|
|
|
|
# check against `registry`, should map keys to all groups
|
2024-05-02 03:02:14 +00:00
|
|
|
for key, group_dict in tomato.key_registry.items():
|
|
|
|
assert keys_to_groups.get(key) == list(group_dict.keys())
|
2024-04-18 09:06:42 +00:00
|
|
|
|
2024-04-18 20:31:19 +00:00
|
|
|
def test_co3_attributes():
|
|
|
|
assert tomato.attributes is not None
|
2024-04-18 09:06:42 +00:00
|
|
|
|
2024-04-18 20:31:19 +00:00
|
|
|
def test_co3_components():
|
|
|
|
assert tomato.components is not None
|
2024-04-18 09:06:42 +00:00
|
|
|
|
2024-04-18 20:31:19 +00:00
|
|
|
def test_co3_collation_attributes():
|
2024-05-01 23:46:25 +00:00
|
|
|
for group, keys in tomato.group_registry.items():
|
|
|
|
for key in keys:
|
|
|
|
assert tomato.collation_attributes(key, group) is not None
|
2024-04-18 09:06:42 +00:00
|
|
|
|
2024-04-18 20:31:19 +00:00
|
|
|
def test_co3_collate():
|
2024-05-01 23:46:25 +00:00
|
|
|
for group, keys in tomato.group_registry.items():
|
|
|
|
for key in keys:
|
|
|
|
if key is None: continue
|
2024-05-02 03:02:14 +00:00
|
|
|
assert tomato.collate(key, group=group) is not None
|