Skip to content

Commit c2a3fdf

Browse files
fix: manual cleanup
1 parent 44573c1 commit c2a3fdf

3 files changed

Lines changed: 18 additions & 135 deletions

File tree

Lines changed: 5 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import importlib
22
import subprocess
33
import sys
4-
import textwrap
54
import warnings
65

7-
import pytest
8-
96
# TODO: Remove these tests with the compatibility bridge in the next breaking-change release.
107
INTERRUPT_MODEL_NAMES = (
118
"CreateBatchTransform",
@@ -62,8 +59,6 @@ def test_compatibility_exports_are_canonical_objects():
6259

6360
assert set(INTERRUPT_MODEL_NAMES) == set(legacy.__all__)
6461
assert set(INTERRUPT_MODEL_NAMES) <= set(common.__all__)
65-
assert set(legacy.__all__) <= set(dir(legacy))
66-
assert set(INTERRUPT_MODEL_NAMES) <= set(dir(common))
6762

6863

6964
def test_importing_common_does_not_load_resume_triggers_or_warn():
@@ -83,30 +78,16 @@ def test_importing_common_does_not_load_resume_triggers_or_warn():
8378
)
8479

8580

86-
@pytest.mark.parametrize(
87-
"imports",
88-
[
89-
"""
90-
from uipath.platform.resume_triggers import WaitUntil as canonical
91-
from uipath.platform.common import WaitUntil as legacy_root
92-
from uipath.platform.common.interrupt_models import WaitUntil as legacy_direct
93-
""",
94-
"""
95-
from uipath.platform.common.interrupt_models import WaitUntil as legacy_direct
96-
from uipath.platform.common import WaitUntil as legacy_root
97-
from uipath.platform.resume_triggers import WaitUntil as canonical
98-
""",
99-
],
100-
)
101-
def test_import_orders_are_cycle_safe(imports: str):
102-
indented_imports = textwrap.indent(imports.strip(), " ")
81+
def test_legacy_first_import_is_cycle_safe_and_warns():
10382
_run_python(
104-
f"""
83+
"""
10584
import warnings
10685
10786
with warnings.catch_warnings(record=True) as caught:
10887
warnings.simplefilter("always")
109-
{indented_imports}
88+
from uipath.platform.common.interrupt_models import WaitUntil as legacy_direct
89+
from uipath.platform.common import WaitUntil as legacy_root
90+
from uipath.platform.resume_triggers import WaitUntil as canonical
11091
11192
assert canonical is legacy_root is legacy_direct
11293
compatibility_warnings = [
@@ -118,66 +99,3 @@ def test_import_orders_are_cycle_safe(imports: str):
11899
assert compatibility_warnings
119100
"""
120101
)
121-
122-
123-
def test_legacy_imports_warn_at_caller_site():
124-
_run_python(
125-
"""
126-
import warnings
127-
128-
with warnings.catch_warnings(record=True) as caught:
129-
warnings.simplefilter("always")
130-
from uipath.platform.common import WaitUntil
131-
from uipath.platform.common.interrupt_models import WaitTask
132-
133-
compatibility_warnings = [
134-
item
135-
for item in caught
136-
if issubclass(item.category, DeprecationWarning)
137-
and "uipath.platform.resume_triggers" in str(item.message)
138-
]
139-
assert len(compatibility_warnings) == 2
140-
assert all(item.filename == "<string>" for item in compatibility_warnings), [
141-
item.filename for item in compatibility_warnings
142-
]
143-
"""
144-
)
145-
146-
147-
def test_cached_resolution_warns_once_per_name():
148-
_run_python(
149-
"""
150-
import warnings
151-
152-
import uipath.platform.common as common
153-
154-
with warnings.catch_warnings(record=True) as caught:
155-
warnings.simplefilter("always")
156-
common.WaitUntil
157-
common.WaitUntil
158-
common.WaitJob
159-
160-
compatibility_warnings = [
161-
item
162-
for item in caught
163-
if issubclass(item.category, DeprecationWarning)
164-
and "uipath.platform.resume_triggers" in str(item.message)
165-
]
166-
assert len(compatibility_warnings) == 2
167-
"""
168-
)
169-
170-
171-
def test_star_import_exports_all_interrupt_models():
172-
_run_python(
173-
"""
174-
import warnings
175-
176-
warnings.simplefilter("ignore", DeprecationWarning)
177-
178-
from uipath.platform.common.interrupt_models import * # noqa: F403
179-
180-
for name in ("InvokeProcess", "WaitUntil", "CreateTask", "WaitIntegrationEvent"):
181-
assert name in globals(), name
182-
"""
183-
)

packages/uipath-platform/tests/services/test_guardrails_decorators.py

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -989,32 +989,6 @@ def test_custom_validator_path_delegates_to_run(self):
989989
)
990990
assert result == _PASSED
991991

992-
def test_built_in_validator_uses_injected_service(self):
993-
"""BuiltInGuardrailValidator.run() delegates to an injected service."""
994-
from uipath.platform.guardrails.decorators.validators import (
995-
BuiltInGuardrailValidator,
996-
)
997-
from uipath.platform.guardrails.guardrails import BuiltInValidatorGuardrail
998-
999-
mock_built_in = MagicMock(spec=BuiltInValidatorGuardrail)
1000-
1001-
class _TestBuiltIn(BuiltInGuardrailValidator):
1002-
def get_built_in_guardrail(self, name, description, enabled_for_evals):
1003-
return mock_built_in
1004-
1005-
validator = _TestBuiltIn()
1006-
fake_service = MagicMock()
1007-
fake_service.evaluate_guardrail.return_value = _PASSED
1008-
validator._service = fake_service
1009-
evaluator = _make_evaluator(validator, "G", None, True)
1010-
1011-
result = evaluator({"text": "hello"}, GuardrailExecutionStage.PRE, None, None)
1012-
1013-
fake_service.evaluate_guardrail.assert_called_once_with(
1014-
{"text": "hello"}, mock_built_in
1015-
)
1016-
assert result == _PASSED
1017-
1018992
def test_built_in_validator_path_lazy_initializes_default_service(self):
1019993
"""BuiltInGuardrailValidator.run() creates the default service once."""
1020994
from uipath.platform.guardrails.decorators.validators import (
@@ -1071,28 +1045,6 @@ def get_built_in_guardrail(self, name, description, enabled_for_evals):
10711045
evaluator({"text": "hello"}, GuardrailExecutionStage.PRE, None, None)
10721046

10731047

1074-
# ---------------------------------------------------------------------------
1075-
# 15b. default_guardrails_service
1076-
# ---------------------------------------------------------------------------
1077-
1078-
1079-
class TestDefaultGuardrailsService:
1080-
def test_builds_guardrails_service_from_env(self, monkeypatch):
1081-
"""The default factory builds a GuardrailsService from env config."""
1082-
from uipath.platform.guardrails._guardrails_service import (
1083-
GuardrailsService,
1084-
default_guardrails_service,
1085-
)
1086-
1087-
monkeypatch.setenv("UIPATH_URL", "https://test.uipath.com")
1088-
monkeypatch.setenv("UIPATH_ACCESS_TOKEN", "token")
1089-
1090-
service = default_guardrails_service()
1091-
assert isinstance(service, GuardrailsService)
1092-
assert service._config.base_url == "https://test.uipath.com"
1093-
assert service._config.secret == "token"
1094-
1095-
10961048
# ---------------------------------------------------------------------------
10971049
# 16. Joke-agent integration scenarios (plain functions)
10981050
# ---------------------------------------------------------------------------

packages/uipath-platform/tests/services/test_guardrails_service.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
GuardrailsService,
1818
MapEnumParameterValue,
1919
)
20+
from uipath.platform.guardrails._guardrails_service import default_guardrails_service
2021

2122

2223
@pytest.fixture
@@ -29,6 +30,18 @@ def service(
2930
return GuardrailsService(config=config, execution_context=execution_context)
3031

3132

33+
class TestDefaultGuardrailsService:
34+
def test_builds_guardrails_service_from_env(self, monkeypatch):
35+
"""The default factory builds a GuardrailsService from env config."""
36+
monkeypatch.setenv("UIPATH_URL", "https://test.uipath.com")
37+
monkeypatch.setenv("UIPATH_ACCESS_TOKEN", "token")
38+
39+
service = default_guardrails_service()
40+
assert isinstance(service, GuardrailsService)
41+
assert service._config.base_url == "https://test.uipath.com"
42+
assert service._config.secret == "token"
43+
44+
3245
class TestGuardrailsService:
3346
"""Test GuardrailsService functionality."""
3447

0 commit comments

Comments
 (0)