Skip to content

Commit

Permalink
Add get_side_effects function
Browse files Browse the repository at this point in the history
  • Loading branch information
hugorodgerbrown committed Feb 12, 2024
1 parent 25a1b53 commit 74fdba9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions side_effects/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ def register_side_effect(label: str, func: Callable) -> None:
_registry.add(label, func)


def get_side_effects(label: str) -> List[Callable]:
return _registry[label]


def run_side_effects(
label: str, *args: Any, return_value: Any | None = None, **kwargs: Any
) -> None:
Expand Down
7 changes: 7 additions & 0 deletions tests/test_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ def test_func2() -> None:
registry.register_side_effect("foo", test_func1)
self.assertTrue(registry._registry.contains("foo", test_func1))

def test_get_side_effects(self) -> None:
def test_func1() -> None:
pass

registry.register_side_effect("foo", test_func1)
self.assertEqual(registry.get_side_effects("foo"), [test_func1])

@mock.patch("side_effects.registry.settings.TEST_MODE", False)
def test_run_side_effects(self) -> None:
def test_func(x: list) -> None:
Expand Down

0 comments on commit 74fdba9

Please sign in to comment.