Skip to content

Commit

Permalink
Add simple test for adding Nodes and Flows
Browse files Browse the repository at this point in the history
  • Loading branch information
p-snft committed Sep 27, 2023
1 parent f5bba34 commit cd040ca
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/test_energy_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,34 @@
"""

from oemof.network import energy_system as es
from oemof.network.network import Edge
from oemof.network.network.nodes import Node


class TestsEnergySystem:
def setup_method(self):
self.es = es.EnergySystem()

def test_add_nodes(self):
assert not self.es.nodes

node1 = Node(label="node1")
self.es.add(node1)
assert self.es.nodes
assert node1 in self.es.nodes
assert not self.es.flows()

# Note that node2 is not added, but the Flow is already
# registred. We do not assert the latter fact as this is not a
# guaranteed functionality.
node2 = Node(label="node2", inputs={node1: Edge()})
assert node2 not in self.es.nodes

# When both nodes are registred, also the Flow needs to be there.
self.es.add(node2)
assert node2 in self.es.nodes
assert (node1, node2) in self.es.flows().keys()

def test_that_node_additions_are_signalled(self):
"""
When a node gets `add`ed, a corresponding signal should be emitted.
Expand Down

0 comments on commit cd040ca

Please sign in to comment.