Пример #1
0
def test_ComponentManager_add_components(components):
    config = build_simulation_configuration()
    cm = ComponentManager()
    cm.configuration = config
    cm.add_managers(components)
    assert cm._managers == OrderedComponentSet(*ComponentManager._flatten(components))

    config = build_simulation_configuration()
    cm = ComponentManager()
    cm.configuration = config
    cm.add_components(components)
    assert cm._components == OrderedComponentSet(*ComponentManager._flatten(components))
Пример #2
0
def test_ComponentManager_add_components_unnamed(components):
    config = build_simulation_configuration()
    cm = ComponentManager()
    cm.configuration = config
    with pytest.raises(ComponentConfigError, match='no name'):
        cm.add_managers(components)

    config = build_simulation_configuration()
    cm = ComponentManager()
    cm.configuration = config
    with pytest.raises(ComponentConfigError, match='no name'):
        cm.add_components(components)
Пример #3
0
def test_add_components():
    config = build_simulation_configuration()
    cm = ComponentManager()
    cm.configuration = config

    assert not cm._managers
    managers = [MockGenericComponent(f'manager_{i}') for i in range(5)]
    components = [MockGenericComponent(f'component_{i}') for i in range(5)]
    cm.add_managers(managers)
    cm.add_components(components)
    assert cm._managers == OrderedComponentSet(*managers)
    assert cm._components == OrderedComponentSet(*components)
    for c in managers + components:
        assert config[c.name].to_dict() == c.configuration_defaults[c.name]

    assert cm.list_components() == {c.name: c for c in components}