From c522d791e325f6bf452fe5e100786811f48f0b81 Mon Sep 17 00:00:00 2001 From: nannan00 <17491932+nannan00@users.noreply.github.com> Date: Thu, 8 Aug 2024 17:52:03 +0800 Subject: [PATCH] fix: user language unittest --- src/bk-user/bkuser/apis/open_v2/views/profilers.py | 4 +++- src/bk-user/tests/apis/web/organization/test_user.py | 3 ++- .../tests/apis/web/personal_center/test_personal_center.py | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/bk-user/bkuser/apis/open_v2/views/profilers.py b/src/bk-user/bkuser/apis/open_v2/views/profilers.py index 0b567ce53..36ec6871f 100644 --- a/src/bk-user/bkuser/apis/open_v2/views/profilers.py +++ b/src/bk-user/bkuser/apis/open_v2/views/profilers.py @@ -426,7 +426,9 @@ def _convert_create_time_lookup_to_query(values: List[str], is_exact: bool) -> Q # 时间转换异常,说明非预期内 IAM 特殊查询数据(从大到小) try: - datetime_values = [datetime.datetime.strptime(v, "%Y-%m-%d %H:%M") for v in values] + datetime_values = [ + datetime.datetime.strptime(v, "%Y-%m-%d %H:%M").replace(tzinfo=datetime.timezone.utc) for v in values + ] except Exception as error: raise error_codes.VALIDATION_ERROR.f(f"unsupported fuzzy create_time values: {values}, error={error}") diff --git a/src/bk-user/tests/apis/web/organization/test_user.py b/src/bk-user/tests/apis/web/organization/test_user.py index c463bf7af..e36f69bf8 100644 --- a/src/bk-user/tests/apis/web/organization/test_user.py +++ b/src/bk-user/tests/apis/web/organization/test_user.py @@ -8,6 +8,7 @@ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ + import datetime from typing import Any, Dict, List @@ -479,7 +480,7 @@ def test_standard(self, api_client, random_tenant): assert {ld["username"] for ld in resp.data["leaders"]} == {"wangwu", "maiba"} # 语言和时区字段应为默认值 - assert resp.data["language"] == "zh-CN" + assert resp.data["language"] == "zh-cn" assert resp.data["time_zone"] == "Asia/Shanghai" @pytest.mark.usefixtures("_init_collaboration_users_depts") diff --git a/src/bk-user/tests/apis/web/personal_center/test_personal_center.py b/src/bk-user/tests/apis/web/personal_center/test_personal_center.py index 3b2f02752..3990f69ab 100644 --- a/src/bk-user/tests/apis/web/personal_center/test_personal_center.py +++ b/src/bk-user/tests/apis/web/personal_center/test_personal_center.py @@ -8,6 +8,7 @@ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ + import pytest from bkuser.apps.tenant.models import TenantUser from django.urls import reverse @@ -91,7 +92,7 @@ def test_list(self, api_client, tenant_user): class TestTenantUserLanguageUpdateApi: @pytest.mark.parametrize( ("language"), - [("zh-CN"), ("en-US")], + [("zh-cn"), ("en")], ) def test_update_legal_language(self, api_client, tenant_user, language): resp = api_client.put(