mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-10-30 20:05:42 +08:00
fix(site): 修复手动新增站点失败 (#6531)
This commit is contained in:
@@ -149,6 +149,7 @@ class SiteMutationCommand:
|
||||
if await self._repository.async_get_by_domain(domain):
|
||||
return SiteMutationResult(False, f"{domain} 站点己存在")
|
||||
|
||||
values.pop("id", None)
|
||||
values.update(
|
||||
{
|
||||
"domain": domain,
|
||||
|
||||
@@ -4,6 +4,7 @@ import pytest
|
||||
|
||||
from app.application.site.contract import SiteMutation, SitePriorityMutation
|
||||
from app.application.site.mutation import SiteMutationCommand
|
||||
from app.schemas.site import Site
|
||||
|
||||
|
||||
def _command(**overrides):
|
||||
@@ -56,6 +57,20 @@ async def test_create_site_commits_before_updated_event():
|
||||
assert mutation.values["public"] == 1
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_create_site_ignores_schema_identity_field():
|
||||
"""手动新增站点应忽略请求 Schema 自动补出的空主键。"""
|
||||
command, dependencies = _command()
|
||||
|
||||
result = await command.create(
|
||||
Site(url="https://demo.example/path").model_dump()
|
||||
)
|
||||
|
||||
assert result.success is True
|
||||
mutation = dependencies["repository"].stage_create.await_args.args[0]
|
||||
assert "id" not in mutation.values
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_update_site_returns_legacy_not_found_without_writes():
|
||||
"""更新不存在站点时保持失败响应且不产生事务或事件。"""
|
||||
|
||||
Reference in New Issue
Block a user