Skip to content

Commit ddce6bf

Browse files
authored
restore old file_version tests, skip them on PGSQL (#256)
Restored the old tests for the file versions, because that commit with optimization of working with file versions in the Nextcloud server repository was backported on the NC 27, 28 versions of the server - I simply disabled this test on the PGSQL database, where these tests fails. Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
1 parent a4f04cc commit ddce6bf

File tree

3 files changed

+52
-35
lines changed

3 files changed

+52
-35
lines changed

.github/workflows/analysis-coverage.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ jobs:
200200
php-version: "8.2"
201201
env:
202202
NC_dbname: nextcloud_abz
203+
DATABASE_PGSQL: 1
203204
timeout-minutes: 60
204205

205206
services:
@@ -637,6 +638,7 @@ jobs:
637638
nextcloud: [ 'stable27', 'stable28', 'master' ]
638639
env:
639640
NC_dbname: nextcloud_abz
641+
DATABASE_PGSQL: 1
640642
timeout-minutes: 60
641643

642644
services:

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ help:
2121
@echo " "
2222
@echo " register27 register nc_py_api for Nextcloud 27"
2323
@echo " register28 register nc_py_api for Nextcloud 28"
24+
@echo " register29 register nc_py_api for Nextcloud 29"
2425
@echo " register register nc_py_api for Nextcloud Last"
2526
@echo " "
2627
@echo " tests27 run nc_py_api tests for Nextcloud 27"
2728
@echo " tests28 run nc_py_api tests for Nextcloud 28"
29+
@echo " tests29 run nc_py_api tests for Nextcloud 29"
2830
@echo " tests run nc_py_api tests for Nextcloud Last"
2931

3032
.PHONY: register27
@@ -35,6 +37,10 @@ register27:
3537
register28:
3638
/bin/sh scripts/dev_register.sh master-stable28-1 stable28.local
3739

40+
.PHONY: register29
41+
register29:
42+
/bin/sh scripts/dev_register.sh master-stable29-1 stable28.local
43+
3844
.PHONY: register
3945
register:
4046
/bin/sh scripts/dev_register.sh master-nextcloud-1 nextcloud.local
@@ -47,6 +53,10 @@ tests27:
4753
tests28:
4854
NEXTCLOUD_URL=http://stable28.local python3 -m pytest
4955

56+
.PHONY: tests29
57+
tests29:
58+
NEXTCLOUD_URL=http://stable29.local python3 -m pytest
59+
5060
.PHONY: tests
5161
tests:
5262
NEXTCLOUD_URL=http://nextcloud.local python3 -m pytest

tests/actual_tests/files_test.py

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import contextlib
22
import math
33
import os
4-
import time
54
import zipfile
65
from datetime import datetime
76
from io import BytesIO
@@ -1055,45 +1054,51 @@ async def test_trashbin_async(anc_any, file_path):
10551054
assert not r
10561055

10571056

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):
10591063
if nc_any.check_capabilities("files.versioning"):
10601064
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")
10781081
@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):
10801087
if await anc_any.check_capabilities("files.versioning"):
10811088
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"
10971102

10981103

10991104
def test_create_update_delete_tag(nc_any):

0 commit comments

Comments
 (0)