From cd040cabe84215c10de1d6391f3654f2eb357289 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrik=20Sch=C3=B6nfeldt?= Date: Wed, 27 Sep 2023 21:26:36 +0200 Subject: [PATCH] Add simple test for adding Nodes and Flows --- tests/test_energy_system.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/test_energy_system.py b/tests/test_energy_system.py index 4084202..9af475e 100644 --- a/tests/test_energy_system.py +++ b/tests/test_energy_system.py @@ -14,6 +14,7 @@ """ from oemof.network import energy_system as es +from oemof.network.network import Edge from oemof.network.network.nodes import Node @@ -21,6 +22,26 @@ 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.