diff --git a/tests/unit/test_registry.py b/tests/unit/test_registry.py index 7554f7b08..91872d343 100644 --- a/tests/unit/test_registry.py +++ b/tests/unit/test_registry.py @@ -85,10 +85,28 @@ async def async_test_function(num: int) -> int: ) ) + # Create a file for the deprecated function + with open(os.path.join(tmp_path, "deprecated_function.py"), "w") as f: + f.write( + textwrap.dedent( + """ + from tracecat_registry import registry + + @registry.register( + description="This is a deprecated function", + namespace="test", + deprecated="This function is deprecated", + ) + """ + ) + ) + yield test_module + finally: # Clean up del sys.modules["test_module"] + del sys.modules["test_deprecated_module"] def test_udf_can_be_registered(mock_package): @@ -122,6 +140,18 @@ def test_udf_validate_args(mock_package): udf.validate_args(num="not a number") +def test_deprecated_function_can_be_registered(mock_deprecated_package): + """Test that a deprecated function can be registered.""" + repo = Repository() + repo._register_udfs_from_package(mock_deprecated_package) + + udf = repo.get("test.deprecated_function") + assert udf is not None + + # Check descriptors + assert udf.deprecated == "This function is deprecated" + + def test_registry_function_can_be_called(mock_package): """We need to test that the ordering of the workflow tasks is correct.""" repo = Repository()