import pytest
from mcp_server_notion.server import call_tool

class DummyNotion:
    def __init__(self):
        self.pages = self
    def create(self, parent, properties, children):
        assert parent["database_id"] == "dummy_db"
        assert properties["title"][0]["text"]["content"] == "테스트"
        assert children[0]["paragraph"]["rich_text"][0]["text"]["content"] == "본문"
        return {"url": "https://notion.so/dummy"}

def test_notion_create_page(monkeypatch):
    import mcp_server_notion.server as server
    server.Client = lambda auth: DummyNotion()
    result = pytest.run(asyncio_run(call_tool("notion_create_page", {
        "notion_token": "dummy_token",
        "parent_id": "dummy_db",
        "title": "테스트",
        "content": "본문"
    })))
    assert result[0].text == "페이지 생성됨: https://notion.so/dummy"

def asyncio_run(coro):
    import asyncio
    return asyncio.get_event_loop().run_until_complete(coro)