From ac71adb000f552950bda923d1527ac2ca30e0e01 Mon Sep 17 00:00:00 2001 From: Sefank <12670778+Sefank@users.noreply.github.com> Date: Wed, 19 Jun 2024 11:49:18 +0800 Subject: [PATCH] Change the default return language to en-US Note: the logic of tests/integration/common/test_request_common_param.py depends on the default language feature, thus an incidental change here. --- tencentcloud/common/profile/client_profile.py | 2 +- .../common/test_default_en_profile.py | 27 +++++++++++++++++++ .../common/test_request_common_param.py | 4 +-- 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 tests/integration/common/test_default_en_profile.py diff --git a/tencentcloud/common/profile/client_profile.py b/tencentcloud/common/profile/client_profile.py index 74ab3869..203db764 100644 --- a/tencentcloud/common/profile/client_profile.py +++ b/tencentcloud/common/profile/client_profile.py @@ -20,7 +20,7 @@ class ClientProfile(object): unsignedPayload = False - def __init__(self, signMethod=None, httpProfile=None, language="zh-CN", + def __init__(self, signMethod=None, httpProfile=None, language="en-US", disable_region_breaker=True, region_breaker_profile=None, request_client=None): """SDK profile. diff --git a/tests/integration/common/test_default_en_profile.py b/tests/integration/common/test_default_en_profile.py new file mode 100644 index 00000000..42d5f124 --- /dev/null +++ b/tests/integration/common/test_default_en_profile.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +import os +from tencentcloud.common import credential +from tencentcloud.common.profile.client_profile import ClientProfile +from tencentcloud.common.profile.http_profile import HttpProfile +from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException +from tencentcloud.cvm.v20170312 import cvm_client, models + + +def test_default_en_profile(): + try: + cred = credential.Credential( + os.environ.get("TENCENTCLOUD_SECRET_ID"), + os.environ.get("TENCENTCLOUD_SECRET_KEY")) + httpProfile = HttpProfile() + httpProfile.endpoint = "cvm.tencentcloudapi.com" + + clientProfile = ClientProfile() + clientProfile.httpProfile = httpProfile + client = cvm_client.CvmClient(cred, "ap-guangzhou", clientProfile) + + req = models.DescribeZonesRequest() + resp = client.DescribeZones(req) + if resp.TotalCount > 0: + assert "Guangzhou" in resp.to_json_string(), "default \"language=en-US\" not working" + except TencentCloudSDKException as err: + assert False, "unexpected request failure" diff --git a/tests/integration/common/test_request_common_param.py b/tests/integration/common/test_request_common_param.py index 5d3fb3cb..d5a5a643 100644 --- a/tests/integration/common/test_request_common_param.py +++ b/tests/integration/common/test_request_common_param.py @@ -11,7 +11,7 @@ def test_request_common_param_language(): endpoint = "cvm.tencentcloudapi.com" region = "ap-guangzhou" - language = "en-US" + language = "zh-CN" try: cred = credential.Credential( @@ -27,6 +27,6 @@ def test_request_common_param_language(): req = models.DescribeZonesRequest() resp = client.DescribeZones(req) if resp.TotalCount > 0: - assert "Guangzhou" in resp.to_json_string(), "language=en-US not working" + assert "Guangzhou" not in resp.to_json_string(), "language=zh-CN not working" except TencentCloudSDKException as err: assert False, "unexpected request failure"