diff --git a/tests/test_extensions.py b/tests/test_extensions.py index 4faa8379..752de934 100644 --- a/tests/test_extensions.py +++ b/tests/test_extensions.py @@ -146,6 +146,7 @@ def new_pull_distributed(self, vqip, of_type=None, tag="default"): assert_dict_almost_equal(vq, node.empty_vqip()) assert node.tank.storage["volume"] == 5 + def test_handler_extensions(temp_extension_registry): from wsimod.arcs.arcs import Arc from wsimod.extensions import ( @@ -165,16 +166,17 @@ def test_handler_extensions(temp_extension_registry): # 1. Patch a handler @register_node_patch("dummy_node", "pull_check_handler", item="default") def dummy_patch(*args, **kwargs): - return 'dummy_patch' - + return "dummy_patch" + # 2. Patch a handler with access to self @register_node_patch("dummy_node", "pull_set_handler", item="default", is_attr=True) def dummy_patch(self): def f(vqip, *args, **kwargs): return f"{self.name} - {vqip['volume']}" + return f - + apply_patches(model) - assert node.pull_check() == 'dummy_patch' - assert node.pull_set({'volume': 1}) == 'dummy_node - 1' \ No newline at end of file + assert node.pull_check() == "dummy_patch" + assert node.pull_set({"volume": 1}) == "dummy_node - 1"