Skip to content

Commit

Permalink
Fix precommit
Browse files Browse the repository at this point in the history
  • Loading branch information
Dobson committed Sep 10, 2024
1 parent 6c7168d commit a6636ce
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions tests/test_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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'
assert node.pull_check() == "dummy_patch"
assert node.pull_set({"volume": 1}) == "dummy_node - 1"

0 comments on commit a6636ce

Please sign in to comment.