Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow no components in add_components #47

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/infrasys/component_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
ISAlreadyAttached,
ISNotStored,
ISOperationNotAllowed,
ISInvalidParameter,
)
from infrasys.models import make_label, get_class_and_name_from_label

Expand Down Expand Up @@ -50,8 +49,7 @@ def add(self, *components: Component, deserialization_in_progress=False) -> None
Raised if a component is already attached to a system.
"""
if not components:
msg = "add_associations requires at least one component"
raise ISInvalidParameter(msg)
return

for component in components:
self._add(component, deserialization_in_progress)
Expand Down
4 changes: 1 addition & 3 deletions tests/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

from infrasys.exceptions import (
ISAlreadyAttached,
ISInvalidParameter,
ISNotStored,
ISOperationNotAllowed,
ISConflictingArguments,
Expand All @@ -32,8 +31,7 @@ def test_system():
gen = SimpleGenerator(name="test-gen", active_power=1.0, rating=1.0, bus=bus, available=True)
subsystem = SimpleSubsystem(name="test-subsystem", generators=[gen])
system.add_components(geo, bus, gen, subsystem)
with pytest.raises(ISInvalidParameter):
system.add_components()
assert system.add_components() is None

gen2 = system.get_component(SimpleGenerator, "test-gen")
assert gen2 is gen
Expand Down
Loading