更新
This commit is contained in:
@@ -112,6 +112,40 @@ class AccountPaginationTests(unittest.IsolatedAsyncioTestCase):
|
||||
finally:
|
||||
main.manager.workers = original_workers
|
||||
|
||||
async def test_account_channel_change_stops_running_worker(self):
|
||||
account = SimpleNamespace(
|
||||
id=2202,
|
||||
egress_public_ip="116.62.23.103",
|
||||
status="online",
|
||||
)
|
||||
db = SimpleNamespace(
|
||||
commit=AsyncMock(),
|
||||
refresh=AsyncMock(),
|
||||
execute=AsyncMock(),
|
||||
)
|
||||
|
||||
with (
|
||||
patch.object(main, "get_owned_account", AsyncMock(return_value=account)),
|
||||
patch.object(main.manager, "is_running", return_value=True),
|
||||
patch.object(main.manager, "stop_worker", AsyncMock(return_value=True)) as stop,
|
||||
patch.object(main, "_build_account_response", return_value={"id": 2202}),
|
||||
):
|
||||
response = await main.update_account(
|
||||
account_id=2202,
|
||||
body=main.AccountUpdate(egress_public_ip="47.96.154.74"),
|
||||
db=db,
|
||||
user=SimpleNamespace(id=7, role="operator"),
|
||||
)
|
||||
|
||||
self.assertEqual(response, {"id": 2202})
|
||||
self.assertEqual(account.egress_public_ip, "47.96.154.74")
|
||||
stop.assert_awaited_once_with(2202)
|
||||
self.assertEqual(db.commit.await_count, 2)
|
||||
values = db.execute.await_args.args[0].compile().params
|
||||
self.assertIn("已保留登录凭证", values["error_message"])
|
||||
self.assertNotIn("cookie_data", values)
|
||||
self.assertNotIn("im_session_data", values)
|
||||
|
||||
async def test_log_stats_uses_one_aggregate_and_respects_ownership(self):
|
||||
engine = create_async_engine("sqlite+aiosqlite:///:memory:")
|
||||
async with engine.begin() as connection:
|
||||
|
||||
Reference in New Issue
Block a user