15
15
import ads .config
16
16
from ads .aqua .constants import AQUA_GA_LIST
17
17
from ads .aqua .extension .common_handler import CompatibilityCheckHandler
18
+ from ads .aqua .extension .utils import ui_compatability_check
18
19
19
20
20
21
class TestDataset :
@@ -28,6 +29,9 @@ def setUp(self, ipython_init_mock) -> None:
28
29
self .common_handler = CompatibilityCheckHandler (MagicMock (), MagicMock ())
29
30
self .common_handler .request = MagicMock ()
30
31
32
+ def tearDown (self ) -> None :
33
+ ui_compatability_check .cache_clear ()
34
+
31
35
def test_get_ok (self ):
32
36
"""Test to check if ok is returned when ODSC_MODEL_COMPARTMENT_OCID is set."""
33
37
with patch .dict (
@@ -36,15 +40,22 @@ def test_get_ok(self):
36
40
):
37
41
reload (ads .config )
38
42
reload (ads .aqua )
43
+ reload (ads .aqua .extension .utils )
39
44
reload (ads .aqua .extension .common_handler )
40
45
41
46
with patch (
42
47
"ads.aqua.extension.base_handler.AquaAPIhandler.finish"
43
48
) 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"
48
59
49
60
def test_get_compatible_status (self ):
50
61
"""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):
55
66
):
56
67
reload (ads .config )
57
68
reload (ads .aqua )
69
+ reload (ads .aqua .extension .utils )
58
70
reload (ads .aqua .extension .common_handler )
59
71
with patch (
60
72
"ads.aqua.extension.base_handler.AquaAPIhandler.finish"
61
73
) as mock_finish :
62
74
with patch (
63
- "ads.aqua.extension.common_handler .fetch_service_compartment"
75
+ "ads.aqua.extension.utils .fetch_service_compartment"
64
76
) as mock_fetch_service_compartment :
65
77
mock_fetch_service_compartment .return_value = None
66
78
mock_finish .side_effect = lambda x : x
@@ -77,12 +89,13 @@ def test_raise_not_compatible_error(self):
77
89
):
78
90
reload (ads .config )
79
91
reload (ads .aqua )
92
+ reload (ads .aqua .extension .utils )
80
93
reload (ads .aqua .extension .common_handler )
81
94
with patch (
82
95
"ads.aqua.extension.base_handler.AquaAPIhandler.finish"
83
96
) as mock_finish :
84
97
with patch (
85
- "ads.aqua.extension.common_handler .fetch_service_compartment"
98
+ "ads.aqua.extension.utils .fetch_service_compartment"
86
99
) as mock_fetch_service_compartment :
87
100
mock_fetch_service_compartment .return_value = None
88
101
mock_finish .side_effect = lambda x : x
0 commit comments