aboutsummaryrefslogtreecommitdiff
path: root/tests/test_api.py
diff options
context:
space:
mode:
authorDmitrii Agibov <dmitrii.agibov@arm.com>2022-07-21 14:06:03 +0100
committerBenjamin Klimczak <benjamin.klimczak@arm.com>2022-08-19 10:23:23 +0100
commita8ee1aee3e674c78a77801d1bf2256881ab6b4b9 (patch)
tree8463b24ba0446a49b3e012477b0834c3b5415b86 /tests/test_api.py
parent76ec769ad8f8ed53ec3ff829fdd34d53db8229fd (diff)
downloadmlia-a8ee1aee3e674c78a77801d1bf2256881ab6b4b9.tar.gz
MLIA-549 Refactor API module to support several target profiles
- Move target specific details out of API module - Move common logic for workflow event handler into a separate class Change-Id: Ic4a22657b722af1c1fead1d478f606ac57325788
Diffstat (limited to 'tests/test_api.py')
-rw-r--r--tests/test_api.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/tests/test_api.py b/tests/test_api.py
index 09bc509..e8df7af 100644
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -7,14 +7,16 @@ from unittest.mock import MagicMock
import pytest
from mlia.api import get_advice
+from mlia.api import get_advisor
from mlia.core.common import AdviceCategory
from mlia.core.context import Context
from mlia.core.context import ExecutionContext
+from mlia.devices.ethosu.advisor import EthosUInferenceAdvisor
def test_get_advice_no_target_provided(test_keras_model: Path) -> None:
"""Test getting advice when no target provided."""
- with pytest.raises(Exception, match="Target is not provided"):
+ with pytest.raises(Exception, match="Target profile is not provided"):
get_advice(None, test_keras_model, "all") # type: ignore
@@ -78,7 +80,7 @@ def test_get_advice(
) -> None:
"""Test getting advice with valid parameters."""
advisor_mock = MagicMock()
- monkeypatch.setattr("mlia.api._get_advisor", MagicMock(return_value=advisor_mock))
+ monkeypatch.setattr("mlia.api.get_advisor", MagicMock(return_value=advisor_mock))
get_advice(
"ethos-u55-256",
@@ -92,5 +94,12 @@ def test_get_advice(
assert isinstance(context, Context)
assert context.advice_category == expected_category
- assert context.event_handlers is not None
- assert context.config_parameters is not None
+
+def test_get_advisor(
+ test_keras_model: Path,
+) -> None:
+ """Test function for getting the advisor."""
+ ethos_u55_advisor = get_advisor(
+ ExecutionContext(), "ethos-u55-256", str(test_keras_model)
+ )
+ assert isinstance(ethos_u55_advisor, EthosUInferenceAdvisor)