-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
makedirs
and listdir
correctly work with paths started with /
refactored tests ---------------- Signed-off-by: Alexander Piskun <[email protected]>
- Loading branch information
Showing
33 changed files
with
1,110 additions
and
1,177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.run/register_nc_py_api.run.xml → .run/register_nc_py_api (28).run.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
"""Version of nc_py_api.""" | ||
|
||
__version__ = "0.0.42" | ||
__version__ = "0.0.43.dev0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
# Parameters: | ||
# APP_ID, VERSION, SECRET, HOST, PORT | ||
|
||
php occ app_ecosystem_v2:daemon:register manual_install "Manual Install" manual-install 0 0 0 | ||
php occ app_ecosystem_v2:app:register "$1" manual_install --json-info \ | ||
"{\"appid\":\"$1\",\"name\":\"$1\",\"daemon_config_name\":\"manual_install\",\"version\":\"$2\",\"secret\":\"$3\",\"host\":\"$4\",\"scopes\":{\"required\":[\"SYSTEM\", \"FILES\", \"FILES_SHARING\"],\"optional\":[\"USER_INFO\", \"USER_STATUS\", \"NOTIFICATIONS\", \"WEATHER_STATUS\", \"TALK\", \"TALK_BOT\"]},\"port\":$5,\"protocol\":\"http\",\"system_app\":1}" \ | ||
-e --force-scopes |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
3 changes: 2 additions & 1 deletion
3
tests/appcfg_prefs_ex_test.py → tests/actual_tests/appcfg_prefs_ex_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
import contextlib | ||
from io import BytesIO | ||
from os import environ, path | ||
from random import randbytes | ||
|
||
import pytest | ||
from PIL import Image | ||
|
||
from nc_py_api import Nextcloud, NextcloudApp, NextcloudException, _session # noqa | ||
|
||
from ..conftest import NC_CLIENT | ||
|
||
_TEST_FAILED_INCREMENTAL: dict[str, dict[tuple[int, ...], str]] = {} | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def rand_bytes() -> bytes: | ||
"""Returns 64 bytes from `test_64_bytes.bin` file.""" | ||
return randbytes(64) | ||
|
||
|
||
def init_filesystem_for_user(nc_any, rand_bytes): | ||
""" | ||
/test_empty_dir | ||
/test_empty_dir_in_dir/test_empty_child_dir | ||
/test_dir | ||
/test_dir/subdir/ | ||
/test_dir/subdir/test_empty_text.txt | ||
/test_dir/subdir/test_64_bytes.bin | ||
/test_dir/subdir/test_12345_text.txt | ||
/test_dir/subdir/test_generated_image.png | ||
/test_dir/test_empty_child_dir/ | ||
/test_dir/test_empty_text.txt | ||
/test_dir/test_64_bytes.bin | ||
/test_dir/test_12345_text.txt | ||
/test_dir/test_generated_image.png | ||
/test_empty_text.txt | ||
/test_64_bytes.bin | ||
/test_12345_text.txt | ||
/test_generated_image.png | ||
/test_dir_tmp | ||
""" | ||
clean_filesystem_for_user(nc_any) | ||
im = BytesIO() | ||
Image.linear_gradient("L").resize((768, 768)).save(im, format="PNG") | ||
nc_any.files.mkdir("/test_empty_dir") | ||
nc_any.files.makedirs("/test_empty_dir_in_dir/test_empty_child_dir") | ||
nc_any.files.makedirs("/test_dir/subdir") | ||
nc_any.files.mkdir("/test_dir/test_empty_child_dir/") | ||
nc_any.files.mkdir("/test_dir_tmp") | ||
|
||
def init_folder(folder: str = ""): | ||
nc_any.files.upload(path.join(folder, "test_empty_text.txt"), content=b"") | ||
nc_any.files.upload(path.join(folder, "test_64_bytes.bin"), content=rand_bytes) | ||
nc_any.files.upload(path.join(folder, "test_12345_text.txt"), content="12345") | ||
im.seek(0) | ||
nc_any.files.upload(path.join(folder, "test_generated_image.png"), content=im.read()) | ||
|
||
init_folder() | ||
init_folder("test_dir") | ||
init_folder("test_dir/subdir") | ||
|
||
|
||
def clean_filesystem_for_user(nc_any): | ||
clean_up_list = [ | ||
"test_empty_dir", | ||
"test_empty_dir_in_dir", | ||
"test_dir", | ||
"test_dir_tmp", | ||
"test_empty_text.txt", | ||
"test_64_bytes.bin", | ||
"test_12345_text.txt", | ||
"test_generated_image.png", | ||
] | ||
for i in clean_up_list: | ||
nc_any.files.delete(i, not_fail=True) | ||
|
||
|
||
@pytest.fixture(autouse=True, scope="session") | ||
def tear_up_down(nc_any, rand_bytes): | ||
if NC_CLIENT: | ||
# create two additional groups | ||
environ["TEST_GROUP_BOTH"] = "test_nc_py_api_group_both" | ||
environ["TEST_GROUP_USER"] = "test_nc_py_api_group_user" | ||
with contextlib.suppress(NextcloudException): | ||
NC_CLIENT.users_groups.delete(environ["TEST_GROUP_BOTH"]) | ||
with contextlib.suppress(NextcloudException): | ||
NC_CLIENT.users_groups.delete(environ["TEST_GROUP_USER"]) | ||
NC_CLIENT.users_groups.create(group_id=environ["TEST_GROUP_BOTH"]) | ||
NC_CLIENT.users_groups.create(group_id=environ["TEST_GROUP_USER"]) | ||
# create two additional users | ||
environ["TEST_ADMIN_ID"] = "test_nc_py_api_admin" | ||
environ["TEST_ADMIN_PASS"] = "az1dcaNG4c42" | ||
environ["TEST_USER_ID"] = "test_nc_py_api_user" | ||
environ["TEST_USER_PASS"] = "DC89GvaR42lk" | ||
with contextlib.suppress(NextcloudException): | ||
NC_CLIENT.users.delete(environ["TEST_ADMIN_ID"]) | ||
with contextlib.suppress(NextcloudException): | ||
NC_CLIENT.users.delete(environ["TEST_USER_ID"]) | ||
NC_CLIENT.users.create( | ||
environ["TEST_ADMIN_ID"], password=environ["TEST_ADMIN_PASS"], groups=["admin", environ["TEST_GROUP_BOTH"]] | ||
) | ||
NC_CLIENT.users.create( | ||
environ["TEST_USER_ID"], | ||
password=environ["TEST_USER_PASS"], | ||
groups=[environ["TEST_GROUP_BOTH"], environ["TEST_GROUP_USER"]], | ||
) | ||
init_filesystem_for_user(nc_any, rand_bytes) # currently we initialize filesystem only for admin | ||
|
||
yield | ||
|
||
clean_filesystem_for_user(nc_any) | ||
if NC_CLIENT: | ||
NC_CLIENT.users.delete(environ["TEST_ADMIN_ID"]) | ||
NC_CLIENT.users.delete(environ["TEST_USER_ID"]) | ||
NC_CLIENT.users_groups.delete(environ["TEST_GROUP_BOTH"]) | ||
NC_CLIENT.users_groups.delete(environ["TEST_GROUP_USER"]) |
Oops, something went wrong.