Skip to content

Commit 789d2e2

Browse files
add unit tests
1 parent 3fd1b2c commit 789d2e2

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

tests/unitary/with_extras/aqua/test_cli.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@
44
# Copyright (c) 2024 Oracle and/or its affiliates.
55
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
66

7+
import os
78
import logging
89
import subprocess
10+
import pytest
911
from unittest import TestCase
1012
from unittest.mock import patch
11-
13+
from importlib import reload
1214
from parameterized import parameterized
1315

16+
import ads.aqua
17+
import ads.config
1418
from ads.aqua.cli import AquaCommand
1519

1620

@@ -24,6 +28,12 @@ class TestAquaCLI(TestCase):
2428
datefmt="%m/%d/%Y %I:%M:%S %p",
2529
level=logging.INFO,
2630
)
31+
SERVICE_COMPARTMENT_ID = "ocid1.compartment.oc1..<OCID>"
32+
33+
def setUp(self):
34+
os.environ["ODSC_MODEL_COMPARTMENT_OCID"] = TestAquaCLI.SERVICE_COMPARTMENT_ID
35+
reload(ads.aqua)
36+
reload(ads.aqua.cli)
2737

2838
def test_entrypoint(self):
2939
"""Tests CLI entrypoint."""
@@ -45,3 +55,10 @@ def test_aquacommand(self, name, arg, expected, mock_setting_log):
4555
else:
4656
AquaCommand()
4757
mock_setting_log.assert_called_with(expected)
58+
59+
def test_aqua_command_without_compartment_env_var(self):
60+
os.environ.pop("ODSC_MODEL_COMPARTMENT_OCID", None)
61+
reload(ads.aqua)
62+
reload(ads.aqua.cli)
63+
with pytest.raises(SystemExit):
64+
AquaCommand()

0 commit comments

Comments
 (0)