Skip to content

Commit

Permalink
Merge pull request #47 from NREL/fix/allow-empty-list
Browse files Browse the repository at this point in the history
Allow no components in add_components
  • Loading branch information
daniel-thom authored Oct 24, 2024
2 parents ae517df + b868218 commit 5e1c61d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
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

0 comments on commit 5e1c61d

Please sign in to comment.