|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +import os |
| 3 | + |
| 4 | +from tencentcloud.common import credential |
| 5 | +from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException |
| 6 | +from tencentcloud.cvm.v20170312 import cvm_client, models |
| 7 | + |
| 8 | +from tencentcloud.common.profile.client_profile import ClientProfile |
| 9 | +from tencentcloud.common.profile.http_profile import HttpProfile |
| 10 | + |
| 11 | +try: |
| 12 | + cred = credential.Credential( |
| 13 | + os.environ.get("TENCENTCLOUD_SECRET_ID"), |
| 14 | + os.environ.get("TENCENTCLOUD_SECRET_KEY")) |
| 15 | + |
| 16 | + httpProfile = HttpProfile() |
| 17 | + httpProfile.endpoint = "cvm.tencentcloudapi.com" |
| 18 | + |
| 19 | + clientProfile = ClientProfile() |
| 20 | + clientProfile.httpProfile = httpProfile |
| 21 | + client = cvm_client.CvmClient(cred, "ap-guangzhou", clientProfile) |
| 22 | + |
| 23 | + req = models.DescribeZonesRequest() |
| 24 | + resp = client.DescribeZones(req) |
| 25 | + print(resp.to_json_string()) |
| 26 | + # When using the default language en US, assert result |
| 27 | + if resp.TotalCount > 0: |
| 28 | + assert "Guangzhou" in resp.to_json_string(), "language=en-US not working" |
| 29 | + |
| 30 | + # When changing the language to use zh CN, assert result |
| 31 | + clientProfile.language = "zh-CN" |
| 32 | + client = cvm_client.CvmClient(cred, "ap-guangzhou", clientProfile) |
| 33 | + req = models.DescribeZonesRequest() |
| 34 | + resp = client.DescribeZones(req) |
| 35 | + print(resp.to_json_string()) |
| 36 | + if resp.TotalCount > 0: |
| 37 | + assert "广州" in resp.to_json_string(), "language=zh-CN not working" |
| 38 | +except TencentCloudSDKException as err: |
| 39 | + assert False, "unexpected request failure" |
0 commit comments