Skip to content

Commit 2432a0c

Browse files
committed
Test adding agents from entrypoints
1 parent fba01c7 commit 2432a0c

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/test_registry.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# limitations under the License.
1616

1717
import copy
18+
from typing import Any
19+
from unittest.mock import patch
1820

1921
import pytest
2022

@@ -31,6 +33,7 @@
3133
)
3234
from cloudai.models.scenario import ReportConfig
3335
from cloudai.models.workload import TestDefinition
36+
from cloudai.registration import register_entrypoint_agents
3437

3538

3639
class MyTestDefinition(TestDefinition):
@@ -322,3 +325,20 @@ def test_get_command_gen_strategy_not_found(self, registry: Registry):
322325
with pytest.raises(KeyError) as exc_info:
323326
registry.get_command_gen_strategy(MySystem, AnotherTestDefinition)
324327
assert exc_info.match("Command gen strategy for 'MySystem, AnotherTestDefinition' not found.")
328+
329+
330+
def test_entrypoint_agent_type_verified():
331+
class MockEP:
332+
def __init__(self, load_value: Any):
333+
self._load_value = load_value
334+
self.name = "name"
335+
self.value = "value"
336+
337+
def load(self):
338+
return self._load_value
339+
340+
with (
341+
patch("cloudai.registration.entry_points", return_value=[MockEP(str)]),
342+
pytest.warns(UserWarning, match="(not a subclass of BaseAgent)"),
343+
):
344+
register_entrypoint_agents()

0 commit comments

Comments
 (0)