|
3 | 3 |
|
4 | 4 | from __future__ import annotations
|
5 | 5 |
|
| 6 | +import pytest |
| 7 | + |
6 | 8 | from jupyter_collaboration.stores import SQLiteYStore, TempFileYStore
|
7 | 9 |
|
8 | 10 |
|
@@ -61,9 +63,28 @@ def test_settings_should_change_ystore_class(jp_configurable_serverapp):
|
61 | 63 | assert settings["ystore_class"] == TempFileYStore
|
62 | 64 |
|
63 | 65 |
|
64 |
| -async def test_get_document_file(rtc_create_file, jp_serverapp): |
| 66 | +@pytest.mark.parametrize("copy", [True, False]) |
| 67 | +async def test_get_document_file(rtc_create_file, jp_serverapp, copy): |
65 | 68 | path, content = await rtc_create_file("test.txt", "test", store=True)
|
66 | 69 | collaboration = jp_serverapp.web_app.settings["jupyter_collaboration"]
|
67 |
| - document = await collaboration.get_document(path=path, content_type="file", file_format="text") |
| 70 | + document = await collaboration.get_document( |
| 71 | + path=path, content_type="file", file_format="text", copy=copy |
| 72 | + ) |
68 | 73 | assert document.get() == content == "test"
|
69 | 74 | await collaboration.stop_extension()
|
| 75 | + |
| 76 | + |
| 77 | +async def test_get_document_file_copy_is_independent( |
| 78 | + rtc_create_file, jp_serverapp, rtc_fetch_session |
| 79 | +): |
| 80 | + path, content = await rtc_create_file("test.txt", "test", store=True) |
| 81 | + collaboration = jp_serverapp.web_app.settings["jupyter_collaboration"] |
| 82 | + document = await collaboration.get_document( |
| 83 | + path=path, content_type="file", file_format="text", copy=True |
| 84 | + ) |
| 85 | + document.set("other") |
| 86 | + fresh_copy = await collaboration.get_document( |
| 87 | + path=path, content_type="file", file_format="text" |
| 88 | + ) |
| 89 | + assert fresh_copy.get() == "test" |
| 90 | + await collaboration.stop_extension() |
0 commit comments