diff --git a/src/oemof/network/network/nodes.py b/src/oemof/network/network/nodes.py index bc1e1e7..0a4b6c9 100644 --- a/src/oemof/network/network/nodes.py +++ b/src/oemof/network/network/nodes.py @@ -24,9 +24,18 @@ class Node(Entity): inputs: list or dict, optional Either a list of this nodes' input nodes or a dictionary mapping input nodes to corresponding inflows (i.e. input values). + List will be converted to dictionary with values set to None. outputs: list or dict, optional Either a list of this nodes' output nodes or a dictionary mapping output nodes to corresponding outflows (i.e. output values). + List will be converted to dictionary with values set to None. + + Attributes + ---------- + inputs: dict + A dictionary mapping input nodes to corresponding inflows. + outputs: dict + A dictionary mapping output nodes to corresponding outflows. """ def __init__(self, *args, **kwargs): diff --git a/tests/test_energy_system.py b/tests/test_energy_system.py index 9af475e..6e602f5 100644 --- a/tests/test_energy_system.py +++ b/tests/test_energy_system.py @@ -42,6 +42,30 @@ def test_add_nodes(self): assert node2 in self.es.nodes assert (node1, node2) in self.es.flows().keys() + def test_add_flow_assignment(self): + assert not self.es.nodes + + node0 = Node(label="node0") + node1 = Node(label="node1") + node2 = Node(label="node2", inputs={node0: Edge()}) + + self.es.add(node0, node1, node2) + + assert (node0, node2) in self.es.flows().keys() + assert (node1, node2) not in self.es.flows().keys() + assert (node2, node1) not in self.es.flows().keys() + + node2.inputs[node1] = Edge() + + assert (node0, node2) in self.es.flows().keys() + assert (node1, node2) in self.es.flows().keys() + assert (node2, node1) not in self.es.flows().keys() + + node2.outputs[node1] = Edge() + assert (node0, node2) in self.es.flows().keys() + assert (node1, node2) in self.es.flows().keys() + assert (node2, node1) 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.