|
1 | 1 | import contextlib |
2 | 2 | import math |
3 | 3 | import os |
4 | | -import time |
5 | 4 | import zipfile |
6 | 5 | from datetime import datetime |
7 | 6 | from io import BytesIO |
@@ -1055,45 +1054,51 @@ async def test_trashbin_async(anc_any, file_path): |
1055 | 1054 | assert not r |
1056 | 1055 |
|
1057 | 1056 |
|
1058 | | -def test_file_versions(nc_any): |
| 1057 | +@pytest.mark.skipif(os.environ.get("DATABASE_PGSQL", "0") == "1", reason="Fails on the PGSQL") |
| 1058 | +@pytest.mark.parametrize( |
| 1059 | + "dest_path", |
| 1060 | + ("/test_dir_tmp/file_versions.txt", "/test_dir_tmp/file_versions-ä.txt", "test_dir_tmp/file_versions-1##3"), |
| 1061 | +) |
| 1062 | +def test_file_versions(nc_any, dest_path): |
1059 | 1063 | if nc_any.check_capabilities("files.versioning"): |
1060 | 1064 | pytest.skip("Need 'Versions' App to be enabled.") |
1061 | | - dest_path = "/test_dir_tmp/file_versions-ä.txt" |
1062 | | - nc_any.files.delete(dest_path, not_fail=True) |
1063 | | - nc_any.files.upload(dest_path, content=b"22") |
1064 | | - time.sleep(2.0) |
1065 | | - new_file = nc_any.files.upload(dest_path, content=b"333") |
1066 | | - time.sleep(2.0) |
1067 | | - versions = nc_any.files.get_versions(new_file) |
1068 | | - assert versions |
1069 | | - version_str = str(versions[0]) |
1070 | | - assert version_str.find("File version") != -1 |
1071 | | - assert version_str.find("bytes size") != -1 |
1072 | | - time.sleep(2.0) |
1073 | | - nc_any.files.restore_version(versions[0]) |
1074 | | - time.sleep(2.0) |
1075 | | - assert nc_any.files.download(new_file) == b"22" |
1076 | | - |
1077 | | - |
| 1065 | + for i in (0, 1): |
| 1066 | + nc_any.files.delete(dest_path, not_fail=True) |
| 1067 | + nc_any.files.upload(dest_path, content=b"22") |
| 1068 | + new_file = nc_any.files.upload(dest_path, content=b"333") |
| 1069 | + if i: |
| 1070 | + new_file = nc_any.files.by_id(new_file) |
| 1071 | + versions = nc_any.files.get_versions(new_file) |
| 1072 | + assert versions |
| 1073 | + version_str = str(versions[0]) |
| 1074 | + assert version_str.find("File version") != -1 |
| 1075 | + assert version_str.find("bytes size") != -1 |
| 1076 | + nc_any.files.restore_version(versions[0]) |
| 1077 | + assert nc_any.files.download(new_file) == b"22" |
| 1078 | + |
| 1079 | + |
| 1080 | +@pytest.mark.skipif(os.environ.get("DATABASE_PGSQL", "0") == "1", reason="Fails on the PGSQL") |
1078 | 1081 | @pytest.mark.asyncio(scope="session") |
1079 | | -async def test_file_versions_async(anc_any): |
| 1082 | +@pytest.mark.parametrize( |
| 1083 | + "dest_path", |
| 1084 | + ("/test_dir_tmp/file_versions.txt", "/test_dir_tmp/file_versions-ä.txt", "test_dir_tmp/file_versions-1##3"), |
| 1085 | +) |
| 1086 | +async def test_file_versions_async(anc_any, dest_path): |
1080 | 1087 | if await anc_any.check_capabilities("files.versioning"): |
1081 | 1088 | pytest.skip("Need 'Versions' App to be enabled.") |
1082 | | - dest_path = "/test_dir_tmp/file_versions-ä-async.txt" |
1083 | | - await anc_any.files.delete(dest_path, not_fail=True) |
1084 | | - await anc_any.files.upload(dest_path, content=b"22") |
1085 | | - time.sleep(2.0) |
1086 | | - new_file = await anc_any.files.upload(dest_path, content=b"333") |
1087 | | - time.sleep(2.0) |
1088 | | - versions = await anc_any.files.get_versions(new_file) |
1089 | | - assert versions |
1090 | | - version_str = str(versions[0]) |
1091 | | - assert version_str.find("File version") != -1 |
1092 | | - assert version_str.find("bytes size") != -1 |
1093 | | - time.sleep(2.0) |
1094 | | - await anc_any.files.restore_version(versions[0]) |
1095 | | - time.sleep(2.0) |
1096 | | - assert await anc_any.files.download(new_file) == b"22" |
| 1089 | + for i in (0, 1): |
| 1090 | + await anc_any.files.delete(dest_path, not_fail=True) |
| 1091 | + await anc_any.files.upload(dest_path, content=b"22") |
| 1092 | + new_file = await anc_any.files.upload(dest_path, content=b"333") |
| 1093 | + if i: |
| 1094 | + new_file = await anc_any.files.by_id(new_file) |
| 1095 | + versions = await anc_any.files.get_versions(new_file) |
| 1096 | + assert versions |
| 1097 | + version_str = str(versions[0]) |
| 1098 | + assert version_str.find("File version") != -1 |
| 1099 | + assert version_str.find("bytes size") != -1 |
| 1100 | + await anc_any.files.restore_version(versions[0]) |
| 1101 | + assert await anc_any.files.download(new_file) == b"22" |
1097 | 1102 |
|
1098 | 1103 |
|
1099 | 1104 | def test_create_update_delete_tag(nc_any): |
|
0 commit comments