diff --git a/src/oemof/network/network/nodes.py b/src/oemof/network/network/nodes.py index bc1e1e7..f64e1f6 100644 --- a/src/oemof/network/network/nodes.py +++ b/src/oemof/network/network/nodes.py @@ -11,6 +11,8 @@ SPDX-License-Identifier: MIT """ +import warnings + from .edge import Edge from .entity import Entity @@ -59,12 +61,26 @@ def __init__(self, *args, **kwargs): edge.output = o +_deprecation_warning = ( + "Usage of {} is deprecated. Use oemof.network.Node instead." +) + class Bus(Node): - pass + def __init__(self, *args, **kwargs): + warnings.warn( + _deprecation_warning.format(type(self)), + FutureWarning, + ) + super().__init__(*args, **kwargs) class Component(Node): - pass + def __init__(self, *args, **kwargs): + warnings.warn( + _deprecation_warning.format(type(self)), + FutureWarning, + ) + super().__init__(*args, **kwargs) class Sink(Component): diff --git a/tests/test_network_classes.py b/tests/test_network_classes.py index 507dfd4..dcc86b1 100644 --- a/tests/test_network_classes.py +++ b/tests/test_network_classes.py @@ -21,6 +21,8 @@ from oemof.network.energy_system import EnergySystem as EnSys from oemof.network.network import Bus +from oemof.network.network import Sink +from oemof.network.network import Source from oemof.network.network import Transformer from oemof.network.network.edge import Edge from oemof.network.network.entity import Entity @@ -124,7 +126,7 @@ def test_that_nodes_do_not_get_undead_flows(self): """ flow = object() old = Node(label="A reused label") - bus = Bus(label="bus", inputs={old: flow}) + bus = Node(label="bus", inputs={old: flow}) assert bus.inputs[old].flow == flow, ( ("\n Expected: {0}" + "\n Got : {1} instead").format( flow, bus.inputs[old].flow @@ -172,7 +174,7 @@ def test_modifying_outputs_after_construction(self): def test_modifying_inputs_after_construction(self): """One should be able to add and delete inputs of a node.""" node = Node("N1") - bus = Bus("N2") + bus = Node("N2") flow = "flow" assert node.inputs == {}, ( @@ -329,12 +331,22 @@ def setup_method(self): self.es = EnSys() def test_entity_registration(self): - b1 = Bus(label="") - self.es.add(b1) - assert self.es.nodes[0] == b1 - b2 = Bus(label="") - self.es.add(b2) - assert self.es.nodes[1] == b2 - t1 = Transformer(label="", inputs=[b1], outputs=[b2]) - self.es.add(t1) - assert t1 in self.es.nodes + n1 = Node(label="") + self.es.add(n1) + assert self.es.nodes[0] == n1 + n2 = Node(label="") + self.es.add(n2) + assert self.es.nodes[1] == n2 + n3 = Node(label="", inputs=[n1], outputs=[n2]) + self.es.add(n3) + assert n3 in self.es.nodes + +def test_deprecated_classes(): + with pytest.warns(FutureWarning): + Bus() + with pytest.warns(FutureWarning): + Sink() + with pytest.warns(FutureWarning): + Source() + with pytest.warns(FutureWarning): + Transformer()