1515import ads .config
1616from ads .aqua .constants import AQUA_GA_LIST
1717from ads .aqua .extension .common_handler import CompatibilityCheckHandler
18+ from ads .aqua .extension .utils import ui_compatability_check
1819
1920
2021class TestDataset :
@@ -28,6 +29,9 @@ def setUp(self, ipython_init_mock) -> None:
2829 self .common_handler = CompatibilityCheckHandler (MagicMock (), MagicMock ())
2930 self .common_handler .request = MagicMock ()
3031
32+ def tearDown (self ) -> None :
33+ ui_compatability_check .cache_clear ()
34+
3135 def test_get_ok (self ):
3236 """Test to check if ok is returned when ODSC_MODEL_COMPARTMENT_OCID is set."""
3337 with patch .dict (
@@ -36,15 +40,22 @@ def test_get_ok(self):
3640 ):
3741 reload (ads .config )
3842 reload (ads .aqua )
43+ reload (ads .aqua .extension .utils )
3944 reload (ads .aqua .extension .common_handler )
4045
4146 with patch (
4247 "ads.aqua.extension.base_handler.AquaAPIhandler.finish"
4348 ) as mock_finish :
44- mock_finish .side_effect = lambda x : x
45- self .common_handler .request .path = "aqua/hello"
46- result = self .common_handler .get ()
47- assert result ["status" ] == "ok"
49+ with patch (
50+ "ads.aqua.extension.utils.fetch_service_compartment"
51+ ) as mock_fetch_service_compartment :
52+ mock_fetch_service_compartment .return_value = (
53+ TestDataset .SERVICE_COMPARTMENT_ID
54+ )
55+ mock_finish .side_effect = lambda x : x
56+ self .common_handler .request .path = "aqua/hello"
57+ result = self .common_handler .get ()
58+ assert result ["status" ] == "ok"
4859
4960 def test_get_compatible_status (self ):
5061 """Test to check if compatible is returned when ODSC_MODEL_COMPARTMENT_OCID is not set
@@ -55,12 +66,13 @@ def test_get_compatible_status(self):
5566 ):
5667 reload (ads .config )
5768 reload (ads .aqua )
69+ reload (ads .aqua .extension .utils )
5870 reload (ads .aqua .extension .common_handler )
5971 with patch (
6072 "ads.aqua.extension.base_handler.AquaAPIhandler.finish"
6173 ) as mock_finish :
6274 with patch (
63- "ads.aqua.extension.common_handler .fetch_service_compartment"
75+ "ads.aqua.extension.utils .fetch_service_compartment"
6476 ) as mock_fetch_service_compartment :
6577 mock_fetch_service_compartment .return_value = None
6678 mock_finish .side_effect = lambda x : x
@@ -77,12 +89,13 @@ def test_raise_not_compatible_error(self):
7789 ):
7890 reload (ads .config )
7991 reload (ads .aqua )
92+ reload (ads .aqua .extension .utils )
8093 reload (ads .aqua .extension .common_handler )
8194 with patch (
8295 "ads.aqua.extension.base_handler.AquaAPIhandler.finish"
8396 ) as mock_finish :
8497 with patch (
85- "ads.aqua.extension.common_handler .fetch_service_compartment"
98+ "ads.aqua.extension.utils .fetch_service_compartment"
8699 ) as mock_fetch_service_compartment :
87100 mock_fetch_service_compartment .return_value = None
88101 mock_finish .side_effect = lambda x : x
0 commit comments