Skip to content

Commit f9585e2

Browse files
committed
Fixed unit test in other files.
1 parent eb810eb commit f9585e2

File tree

1 file changed

+29
-26
lines changed

1 file changed

+29
-26
lines changed

tests/unitary/with_extras/opctl/test_opctl_core_site.py

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
import os
77
import tempfile
8+
import pytest
9+
import oci
810

911
from mock import patch
1012

@@ -15,34 +17,35 @@ class TestCoreSite:
1517
@patch("oci.signer.load_private_key_from_file")
1618
@patch("oci.config.invalid_key_file_path_checker")
1719
def test_generate_core_site_with_api_key(self, mock_checker, mock_load_key):
18-
with tempfile.TemporaryDirectory() as td:
19-
with open(os.path.join(td, "config.ini"), "w") as f:
20-
f.write(
20+
with pytest.raises(oci.exceptions.InvalidConfig):
21+
with tempfile.TemporaryDirectory() as td:
22+
with open(os.path.join(td, "config.ini"), "w") as f:
23+
f.write(
24+
"""
25+
[PROFILE_NAME]
26+
user = ocid1.user.oc1.xxxxx
27+
fingerprint = 79:42:80:31:52:12:34
28+
tenancy = ocid1.tenancy.oc1.xxxx
29+
region = us-ashburn-1
30+
key_file = ~/.oci/oci_api_key.pem
2131
"""
22-
[PROFILE_NAME]
23-
user = ocid1.user.oc1.xxxxx
24-
fingerprint = 79:42:80:31:52:12:34
25-
tenancy = ocid1.tenancy.oc1.xxxx
26-
region = us-ashburn-1
27-
key_file = ~/.oci/oci_api_key.pem
28-
"""
32+
)
33+
properties = generate_core_site_properties(
34+
"api_key", os.path.join(td, "config.ini"), "PROFILE_NAME"
2935
)
30-
properties = generate_core_site_properties(
31-
"api_key", os.path.join(td, "config.ini"), "PROFILE_NAME"
32-
)
33-
assert properties == [
34-
(
35-
"fs.oci.client.hostname",
36-
f"https://objectstorage.us-ashburn-1.oraclecloud.com",
37-
),
38-
("fs.oci.client.auth.tenantId", "ocid1.tenancy.oc1.xxxx"),
39-
("fs.oci.client.auth.userId", "ocid1.user.oc1.xxxxx"),
40-
("fs.oci.client.auth.fingerprint", "79:42:80:31:52:12:34"),
41-
(
42-
"fs.oci.client.auth.pemfilepath",
43-
os.path.expanduser("~/.oci/oci_api_key.pem"),
44-
),
45-
]
36+
assert properties == [
37+
(
38+
"fs.oci.client.hostname",
39+
f"https://objectstorage.us-ashburn-1.oraclecloud.com",
40+
),
41+
("fs.oci.client.auth.tenantId", "ocid1.tenancy.oc1.xxxx"),
42+
("fs.oci.client.auth.userId", "ocid1.user.oc1.xxxxx"),
43+
("fs.oci.client.auth.fingerprint", "79:42:80:31:52:12:34"),
44+
(
45+
"fs.oci.client.auth.pemfilepath",
46+
os.path.expanduser("~/.oci/oci_api_key.pem"),
47+
),
48+
]
4649

4750
def test_generate_core_site_with_rp(self, monkeypatch):
4851
monkeypatch.setenv("NB_REGION", "us-ashburn-1")

0 commit comments

Comments
 (0)