diff --git a/tests/conftest.py b/tests/conftest.py index f9df43c2..4c1e1821 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -169,13 +169,9 @@ async def _inner(format: str, type: str, path: str) -> None: return _inner -@pytest.fixture -def rtc_create_SQLite_store(jp_serverapp): - for k, v in jp_serverapp.config.get("SQLiteYStore").items(): - setattr(SQLiteYStore, k, v) - +def rtc_create_SQLite_store_factory(jp_serverapp): async def _inner(type: str, path: str, content: str) -> DocumentRoom: - db = SQLiteYStore(path=f"{type}:{path}") + db = SQLiteYStore(path=f"{type}:{path}", config=jp_serverapp.config) task = create_task(db.start()) await db.started.wait() @@ -192,6 +188,11 @@ async def _inner(type: str, path: str, content: str) -> DocumentRoom: return _inner +@pytest.fixture +def rtc_create_SQLite_store(jp_serverapp): + return rtc_create_SQLite_store_factory(jp_serverapp) + + @pytest.fixture def rtc_create_mock_document_room(): def _inner( diff --git a/tests/test_app.py b/tests/test_app.py index 3288311e..82067a1d 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -6,6 +6,8 @@ import pytest from jupyter_server_ydoc.stores import SQLiteYStore, TempFileYStore +from .conftest import rtc_create_SQLite_store_factory + def test_default_settings(jp_serverapp): settings = jp_serverapp.web_app.settings["jupyter_server_ydoc_config"] @@ -62,6 +64,19 @@ def test_settings_should_change_ystore_class(jp_configurable_serverapp): assert settings["ystore_class"] == TempFileYStore +async def test_document_ttl_from_settings(rtc_create_mock_document_room, jp_configurable_serverapp): + argv = ["--SQLiteYStore.document_ttl=3600"] + + app = jp_configurable_serverapp(argv=argv) + + id = "test-id" + content = "test_ttl" + rtc_create_SQLite_store = rtc_create_SQLite_store_factory(app) + store = await rtc_create_SQLite_store("file", id, content) + + assert store.document_ttl == 3600 + + @pytest.mark.parametrize("copy", [True, False]) async def test_get_document_file(rtc_create_file, jp_serverapp, copy): path, content = await rtc_create_file("test.txt", "test", store=True)