Skip to content

Commit

Permalink
fix: 不显示日期中的时区
Browse files Browse the repository at this point in the history
  • Loading branch information
he0119 committed Sep 19, 2023
1 parent 650c9f3 commit a408b2d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion nonebot_plugin_user/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async def _(session: UserSession):
[
f"用户 ID:{session.uid}",
f"用户名:{session.name}",
f"用户创建日期:{session.created_at}",
f"用户创建日期:{session.created_at.strftime('%Y-%m-%d %H:%M:%S')}",
f"用户所在平台 ID:{session.pid}",
f"用户所在平台:{session.platform}",
]
Expand Down
20 changes: 10 additions & 10 deletions tests/test_bind_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async def test_bind_group(app: App, patch_current_time, mocker: MockerFixture):
mocked_random = mocker.patch("nonebot_plugin_user.random.randint")
mocked_random.return_value = 123456

with patch_current_time("2023-09-14 10:46:10.416389", tick=False):
with patch_current_time("2023-09-14 10:46:10", tick=False):
async with app.test_matcher(user_cmd) as ctx:
adapter = get_adapter(Adapter)
bot = ctx.create_bot(base=Bot, adapter=adapter)
Expand All @@ -31,7 +31,7 @@ async def test_bind_group(app: App, patch_current_time, mocker: MockerFixture):
)
ctx.should_call_send(
event,
"用户 ID:1\n用户名:nickname1\n用户创建日期:2023-09-14 10:46:10.416389+08:00\n用户所在平台 ID:1\n用户所在平台:qq",
"用户 ID:1\n用户名:nickname1\n用户创建日期:2023-09-14 10:46:10\n用户所在平台 ID:1\n用户所在平台:qq",
True,
)
ctx.should_finished(user_cmd)
Expand All @@ -53,7 +53,7 @@ async def test_bind_group(app: App, patch_current_time, mocker: MockerFixture):
)
ctx.should_call_send(
event,
"用户 ID:2\n用户名:nickname10\n用户创建日期:2023-09-14 10:46:10.416389+08:00\n用户所在平台 ID:10\n用户所在平台:qq",
"用户 ID:2\n用户名:nickname10\n用户创建日期:2023-09-14 10:46:10\n用户所在平台 ID:10\n用户所在平台:qq",
True,
)
ctx.should_finished(user_cmd)
Expand Down Expand Up @@ -105,7 +105,7 @@ async def test_bind_group(app: App, patch_current_time, mocker: MockerFixture):
ctx.receive_event(bot, event)
ctx.should_call_send(
event,
"用户 ID:1\n用户名:nickname1\n用户创建日期:2023-09-14 10:46:10.416389+08:00\n用户所在平台 ID:10\n用户所在平台:qq",
"用户 ID:1\n用户名:nickname1\n用户创建日期:2023-09-14 10:46:10\n用户所在平台 ID:10\n用户所在平台:qq",
True,
)
ctx.should_finished(user_cmd)
Expand All @@ -118,7 +118,7 @@ async def test_bind_group(app: App, patch_current_time, mocker: MockerFixture):
ctx.receive_event(bot, event)
ctx.should_call_send(
event,
"用户 ID:1\n用户名:nickname1\n用户创建日期:2023-09-14 10:46:10.416389+08:00\n用户所在平台 ID:1\n用户所在平台:qq",
"用户 ID:1\n用户名:nickname1\n用户创建日期:2023-09-14 10:46:10\n用户所在平台 ID:1\n用户所在平台:qq",
True,
)
ctx.should_finished(user_cmd)
Expand All @@ -133,7 +133,7 @@ async def test_bind_group_different_user(
mocked_random = mocker.patch("nonebot_plugin_user.random.randint")
mocked_random.return_value = 123456

with patch_current_time("2023-09-14 10:46:10.416389", tick=False):
with patch_current_time("2023-09-14 10:46:10", tick=False):
async with app.test_matcher(user_cmd) as ctx:
adapter = get_adapter(Adapter)
bot = ctx.create_bot(base=Bot, adapter=adapter)
Expand All @@ -151,7 +151,7 @@ async def test_bind_group_different_user(
)
ctx.should_call_send(
event,
"用户 ID:1\n用户名:nickname1\n用户创建日期:2023-09-14 10:46:10.416389+08:00\n用户所在平台 ID:1\n用户所在平台:qq",
"用户 ID:1\n用户名:nickname1\n用户创建日期:2023-09-14 10:46:10\n用户所在平台 ID:1\n用户所在平台:qq",
True,
)
ctx.should_finished(user_cmd)
Expand All @@ -173,7 +173,7 @@ async def test_bind_group_different_user(
)
ctx.should_call_send(
event,
"用户 ID:2\n用户名:nickname10\n用户创建日期:2023-09-14 10:46:10.416389+08:00\n用户所在平台 ID:10\n用户所在平台:qq",
"用户 ID:2\n用户名:nickname10\n用户创建日期:2023-09-14 10:46:10\n用户所在平台 ID:10\n用户所在平台:qq",
True,
)
ctx.should_finished(user_cmd)
Expand Down Expand Up @@ -225,7 +225,7 @@ async def test_bind_group_different_user(
ctx.receive_event(bot, event)
ctx.should_call_send(
event,
"用户 ID:1\n用户名:nickname1\n用户创建日期:2023-09-14 10:46:10.416389+08:00\n用户所在平台 ID:1\n用户所在平台:qq",
"用户 ID:1\n用户名:nickname1\n用户创建日期:2023-09-14 10:46:10\n用户所在平台 ID:1\n用户所在平台:qq",
True,
)
ctx.should_finished(user_cmd)
Expand All @@ -238,7 +238,7 @@ async def test_bind_group_different_user(
ctx.receive_event(bot, event)
ctx.should_call_send(
event,
"用户 ID:2\n用户名:nickname10\n用户创建日期:2023-09-14 10:46:10.416389+08:00\n用户所在平台 ID:10\n用户所在平台:qq",
"用户 ID:2\n用户名:nickname10\n用户创建日期:2023-09-14 10:46:10\n用户所在平台 ID:10\n用户所在平台:qq",
True,
)
ctx.should_finished(user_cmd)
20 changes: 10 additions & 10 deletions tests/test_bind_private.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async def test_bind_private(app: App, patch_current_time, mocker: MockerFixture)
mocked_random = mocker.patch("nonebot_plugin_user.random.randint")
mocked_random.return_value = 123456

with patch_current_time("2023-09-14 10:46:10.416389", tick=False):
with patch_current_time("2023-09-14 10:46:10", tick=False):
async with app.test_matcher(user_cmd) as ctx:
adapter = get_adapter(Adapter)
bot = ctx.create_bot(base=Bot, adapter=adapter)
Expand All @@ -30,7 +30,7 @@ async def test_bind_private(app: App, patch_current_time, mocker: MockerFixture)
)
ctx.should_call_send(
event,
"用户 ID:1\n用户名:nickname1\n用户创建日期:2023-09-14 10:46:10.416389+08:00\n用户所在平台 ID:1\n用户所在平台:qq",
"用户 ID:1\n用户名:nickname1\n用户创建日期:2023-09-14 10:46:10\n用户所在平台 ID:1\n用户所在平台:qq",
True,
)
ctx.should_finished(user_cmd)
Expand All @@ -51,7 +51,7 @@ async def test_bind_private(app: App, patch_current_time, mocker: MockerFixture)
)
ctx.should_call_send(
event,
"用户 ID:2\n用户名:nickname10\n用户创建日期:2023-09-14 10:46:10.416389+08:00\n用户所在平台 ID:10\n用户所在平台:qq",
"用户 ID:2\n用户名:nickname10\n用户创建日期:2023-09-14 10:46:10\n用户所在平台 ID:10\n用户所在平台:qq",
True,
)
ctx.should_finished(user_cmd)
Expand Down Expand Up @@ -88,7 +88,7 @@ async def test_bind_private(app: App, patch_current_time, mocker: MockerFixture)
ctx.receive_event(bot, event)
ctx.should_call_send(
event,
"用户 ID:1\n用户名:nickname1\n用户创建日期:2023-09-14 10:46:10.416389+08:00\n用户所在平台 ID:1\n用户所在平台:qq",
"用户 ID:1\n用户名:nickname1\n用户创建日期:2023-09-14 10:46:10\n用户所在平台 ID:1\n用户所在平台:qq",
True,
)
ctx.should_finished(user_cmd)
Expand All @@ -101,7 +101,7 @@ async def test_bind_private(app: App, patch_current_time, mocker: MockerFixture)
ctx.receive_event(bot, event)
ctx.should_call_send(
event,
"用户 ID:1\n用户名:nickname1\n用户创建日期:2023-09-14 10:46:10.416389+08:00\n用户所在平台 ID:10\n用户所在平台:qq",
"用户 ID:1\n用户名:nickname1\n用户创建日期:2023-09-14 10:46:10\n用户所在平台 ID:10\n用户所在平台:qq",
True,
)
ctx.should_finished(user_cmd)
Expand All @@ -116,7 +116,7 @@ async def test_bind_private_invalid_token(
mocked_random = mocker.patch("nonebot_plugin_user.random.randint")
mocked_random.return_value = 123456

with patch_current_time("2023-09-14 10:46:10.416389", tick=False):
with patch_current_time("2023-09-14 10:46:10", tick=False):
async with app.test_matcher(user_cmd) as ctx:
adapter = get_adapter(Adapter)
bot = ctx.create_bot(base=Bot, adapter=adapter)
Expand All @@ -133,7 +133,7 @@ async def test_bind_private_invalid_token(
)
ctx.should_call_send(
event,
"用户 ID:1\n用户名:nickname1\n用户创建日期:2023-09-14 10:46:10.416389+08:00\n用户所在平台 ID:1\n用户所在平台:qq",
"用户 ID:1\n用户名:nickname1\n用户创建日期:2023-09-14 10:46:10\n用户所在平台 ID:1\n用户所在平台:qq",
True,
)
ctx.should_finished(user_cmd)
Expand All @@ -154,7 +154,7 @@ async def test_bind_private_invalid_token(
)
ctx.should_call_send(
event,
"用户 ID:2\n用户名:nickname10\n用户创建日期:2023-09-14 10:46:10.416389+08:00\n用户所在平台 ID:10\n用户所在平台:qq",
"用户 ID:2\n用户名:nickname10\n用户创建日期:2023-09-14 10:46:10\n用户所在平台 ID:10\n用户所在平台:qq",
True,
)
ctx.should_finished(user_cmd)
Expand Down Expand Up @@ -191,7 +191,7 @@ async def test_bind_private_invalid_token(
ctx.receive_event(bot, event)
ctx.should_call_send(
event,
"用户 ID:1\n用户名:nickname1\n用户创建日期:2023-09-14 10:46:10.416389+08:00\n用户所在平台 ID:1\n用户所在平台:qq",
"用户 ID:1\n用户名:nickname1\n用户创建日期:2023-09-14 10:46:10\n用户所在平台 ID:1\n用户所在平台:qq",
True,
)
ctx.should_finished(user_cmd)
Expand All @@ -204,7 +204,7 @@ async def test_bind_private_invalid_token(
ctx.receive_event(bot, event)
ctx.should_call_send(
event,
"用户 ID:2\n用户名:nickname10\n用户创建日期:2023-09-14 10:46:10.416389+08:00\n用户所在平台 ID:10\n用户所在平台:qq",
"用户 ID:2\n用户名:nickname10\n用户创建日期:2023-09-14 10:46:10\n用户所在平台 ID:10\n用户所在平台:qq",
True,
)
ctx.should_finished(user_cmd)
4 changes: 2 additions & 2 deletions tests/test_remove_bind.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ async def test_remove_bind(app: App, patch_current_time, mocker: MockerFixture):
from nonebot_plugin_user import bind_cmd
from nonebot_plugin_user.models import Bind, User

with patch_current_time("2023-09-14 10:46:10.416389", tick=False):
with patch_current_time("2023-09-14 10:46:10", tick=False):
async with create_session() as session:
user = User(id=1, name="nickname")
user2 = User(id=2, name="nickname2")
Expand Down Expand Up @@ -56,7 +56,7 @@ async def test_remove_bind_self(app: App, patch_current_time, mocker: MockerFixt
"""解除最初的绑定"""
from nonebot_plugin_user import bind_cmd

with patch_current_time("2023-09-14 10:46:10.416389", tick=False):
with patch_current_time("2023-09-14 10:46:10", tick=False):
async with app.test_matcher(bind_cmd) as ctx:
adapter = get_adapter(Adapter)
bot = ctx.create_bot(base=Bot, adapter=adapter)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ async def test_user(app: App, patch_current_time):
"""获取用户信息"""
from nonebot_plugin_user import user_cmd

with patch_current_time("2023-09-14 10:46:10.416389", tick=False):
with patch_current_time("2023-09-14 10:46:10", tick=False):
async with app.test_matcher(user_cmd) as ctx:
adapter = get_adapter(Adapter)
bot = ctx.create_bot(base=Bot, adapter=adapter)
Expand All @@ -27,7 +27,7 @@ async def test_user(app: App, patch_current_time):
)
ctx.should_call_send(
event,
"用户 ID:1\n用户名:nickname\n用户创建日期:2023-09-14 10:46:10.416389+08:00\n用户所在平台 ID:10\n用户所在平台:qq",
"用户 ID:1\n用户名:nickname\n用户创建日期:2023-09-14 10:46:10\n用户所在平台 ID:10\n用户所在平台:qq",
True,
)
ctx.should_finished(user_cmd)
Expand All @@ -48,7 +48,7 @@ async def test_user(app: App, patch_current_time):
)
ctx.should_call_send(
event,
"用户 ID:1\n用户名:nickname\n用户创建日期:2023-09-14 10:46:10.416389+08:00\n用户所在平台 ID:10\n用户所在平台:qq",
"用户 ID:1\n用户名:nickname\n用户创建日期:2023-09-14 10:46:10\n用户所在平台 ID:10\n用户所在平台:qq",
True,
)
ctx.should_finished(user_cmd)

0 comments on commit a408b2d

Please sign in to comment.