Skip to content

Commit a0e8a28

Browse files
Adding UTs
1 parent f8fde33 commit a0e8a28

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

tests/unitary/with_extras/aqua/test_common_handler.py

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,25 @@
1414
import ads.aqua
1515
import ads.config
1616

17-
from ads.aqua.extension.common_handler import CompatibilityCheckHandler
17+
from ads.aqua.extension.common_handler import (
18+
CompatibilityCheckHandler,
19+
AquaVersionHandler,
20+
)
1821

1922

2023
class TestDataset:
2124
SERVICE_COMPARTMENT_ID = "ocid1.compartment.oc1..<OCID>"
2225

2326

24-
class TestEvaluationHandler(unittest.TestCase):
27+
class TestCompatibilityCheckHandler(unittest.TestCase):
2528
@patch.object(IPythonHandler, "__init__")
2629
def setUp(self, ipython_init_mock) -> None:
2730
ipython_init_mock.return_value = None
2831
self.common_handler = CompatibilityCheckHandler(MagicMock(), MagicMock())
2932
self.common_handler.request = MagicMock()
3033

3134
def test_get_ok(self):
32-
"""Test to check if ok is returned when ODSC_MODEL_COMPARTMENT_OCID is set."""
35+
"""Test to check if ok is returned."""
3336
reload(ads.config)
3437
reload(ads.aqua)
3538
reload(ads.aqua.extension.utils)
@@ -42,3 +45,26 @@ def test_get_ok(self):
4245
self.common_handler.request.path = "aqua/hello"
4346
result = self.common_handler.get()
4447
assert result["status"] == "ok"
48+
49+
50+
class TestAquaVersionHandler(unittest.TestCase):
51+
@patch.object(IPythonHandler, "__init__")
52+
def setUp(self, ipython_init_mock) -> None:
53+
ipython_init_mock.return_value = None
54+
self.version_handler = AquaVersionHandler(MagicMock(), MagicMock())
55+
self.version_handler.request = MagicMock()
56+
57+
@patch("ads.common.utils.read_file")
58+
def test_get(self, mock_read_file):
59+
reload(ads.config)
60+
reload(ads.aqua)
61+
reload(ads.aqua.extension.utils)
62+
reload(ads.aqua.extension.common_handler)
63+
mock_read_file.return_value = '{"installed":{"aqua":"1.0.4","ads":"2.13.12"}}'
64+
with patch(
65+
"ads.aqua.extension.base_handler.AquaAPIhandler.finish"
66+
) as mock_finish:
67+
mock_finish.side_effect = lambda x: x
68+
self.version_handler.request.path = "aqua/aqua_version"
69+
result = self.version_handler.get()
70+
assert result == {"installed": {"aqua": "1.0.4", "ads": "2.13.12"}}

0 commit comments

Comments
 (0)