Skip to content

Commit

Permalink
fix: user language unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
nannan00 committed Aug 8, 2024
1 parent 68d794a commit c522d79
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/bk-user/bkuser/apis/open_v2/views/profilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")

Expand Down
3 changes: 2 additions & 1 deletion src/bk-user/tests/apis/web/organization/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit c522d79

Please sign in to comment.