Skip to content

Commit

Permalink
Add backwards-compat. patching with deprecation warning
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonDaniel committed Sep 20, 2024
1 parent 0c4c3e4 commit 0acb4ab
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
18 changes: 14 additions & 4 deletions neon_utils/signal_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,20 @@ def init_signal_handlers():

else:
LOG.warning("FS signals are deprecated. Signal methods will have no effect.")
_create_signal = Mock(return_value=False)
_check_for_signal = Mock(return_value=False)
_wait_for_signal_clear = Mock(return_value=False)
_wait_for_signal_create = Mock(return_value=False)
if patch_imports:
log_deprecation("Import patching will be deprecated. Disable in "
"configuration by setting `signal`.`patch_imports` "
"to `False`", "2.0.0")
import ovos_utils.signal
_create_signal = ovos_utils.signal.create_signal
_check_for_signal = ovos_utils.signal.check_for_signal
_wait_for_signal_clear = _fs_wait_for_signal_clear
_wait_for_signal_create = _fs_wait_for_signal_create
else:
_create_signal = Mock(return_value=False)
_check_for_signal = Mock(return_value=False)
_wait_for_signal_clear = Mock(return_value=False)
_wait_for_signal_create = Mock(return_value=False)


def check_signal_manager_available() -> bool:
Expand Down
1 change: 0 additions & 1 deletion tests/neon_skill_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,6 @@ def test_speak_emit_response_valid(self):
message.context.pop('destination')
self.assertEqual(message.context, msg.context)

@unittest.skip("Class is deprecated and test fails with signal deprecation")
def test_speak_wait(self):
from neon_utils.signal_utils import create_signal, check_for_signal, \
wait_for_signal_clear
Expand Down
1 change: 0 additions & 1 deletion tests/signal_util_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ def test_signal_utils_manager_available(self):
self.assertEqual(ovos_utils.signal.create_signal,
neon_utils.signal_utils._manager_create_signal)

@unittest.skip("File-based signal handling is deprecated")
def test_signal_utils_manager_unavailable(self):
import ovos_utils.signal
neon_utils.signal_utils.init_signal_handlers()
Expand Down

0 comments on commit 0acb4ab

Please sign in to comment.