Skip to content

Commit ad6ba5d

Browse files
authored
makedirs and listdir correctly work with paths started with /
refactored tests ---------------- Signed-off-by: Alexander Piskun <[email protected]>
1 parent 8be2f81 commit ad6ba5d

33 files changed

+1110
-1177
lines changed

.github/workflows/analysis-coverage.yml

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ concurrency:
1515
env:
1616
NEXTCLOUD_URL: "http://localhost:8080"
1717
APP_ID: "nc_py_api"
18-
APP_PORT: 9009
1918
APP_VERSION: "1.0.0"
2019
APP_SECRET: "tC6vkwPhcppjMykD1r0n9NlI95uJMBYjs5blpIcA1PAdoPDmc5qoAjaBAkyocZ6E"
20+
APP_PORT: 9009
2121
NC_AUTH_USER: "admin"
2222
NC_AUTH_PASS: "adminpassword"
2323

@@ -133,10 +133,7 @@ jobs:
133133
python3 tests/_install_wait.py http://127.0.0.1:$APP_PORT/heartbeat "\"status\":\"ok\"" 15 0.5
134134
python3 tests/_app_security_checks.py http://127.0.0.1:$APP_PORT
135135
cd ..
136-
php occ app_ecosystem_v2:daemon:register manual_install "Manual Install" manual-install 0 0 0
137-
php occ app_ecosystem_v2:app:register $APP_ID manual_install --json-info \
138-
"{\"appid\":\"$APP_ID\",\"name\":\"$APP_ID\",\"daemon_config_name\":\"manual_install\",\"version\":\"$APP_VERSION\",\"secret\":\"$APP_SECRET\",\"host\":\"localhost\",\"scopes\":{\"required\":[\"SYSTEM\", \"FILES\", \"FILES_SHARING\"],\"optional\":[\"USER_INFO\", \"USER_STATUS\", \"NOTIFICATIONS\", \"WEATHER_STATUS\", \"TALK\", \"TALK_BOT\"]},\"port\":$APP_PORT,\"protocol\":\"http\",\"system_app\":1}" \
139-
-e --force-scopes
136+
sh nc_py_api/scripts/ci_register.sh "$APP_ID" "$APP_VERSION" "$APP_SECRET" "localhost" "$APP_PORT"
140137
kill -15 $(cat /tmp/_install.pid)
141138
timeout 3m tail --pid=$(cat /tmp/_install.pid) -f /dev/null
142139
@@ -293,10 +290,7 @@ jobs:
293290
python3 tests/_install_wait.py http://127.0.0.1:$APP_PORT/heartbeat "\"status\":\"ok\"" 15 0.5
294291
python3 tests/_app_security_checks.py http://127.0.0.1:$APP_PORT
295292
cd ..
296-
php occ app_ecosystem_v2:daemon:register manual_install "Manual Install" manual-install 0 0 0
297-
php occ app_ecosystem_v2:app:register $APP_ID manual_install --json-info \
298-
"{\"appid\":\"$APP_ID\",\"name\":\"$APP_ID\",\"daemon_config_name\":\"manual_install\",\"version\":\"$APP_VERSION\",\"secret\":\"$APP_SECRET\",\"host\":\"localhost\",\"scopes\":{\"required\":[\"SYSTEM\", \"FILES\", \"FILES_SHARING\"],\"optional\":[\"USER_INFO\", \"USER_STATUS\", \"NOTIFICATIONS\", \"WEATHER_STATUS\", \"TALK\", \"TALK_BOT\"]},\"port\":$APP_PORT,\"protocol\":\"http\",\"system_app\":1}" \
299-
-e --force-scopes
293+
sh nc_py_api/scripts/ci_register.sh "$APP_ID" "$APP_VERSION" "$APP_SECRET" "localhost" "$APP_PORT"
300294
kill -15 $(cat /tmp/_install.pid)
301295
timeout 3m tail --pid=$(cat /tmp/_install.pid) -f /dev/null
302296
@@ -438,10 +432,7 @@ jobs:
438432
python3 tests/_install_wait.py http://127.0.0.1:$APP_PORT/heartbeat "\"status\":\"ok\"" 15 0.5
439433
python3 tests/_app_security_checks.py http://127.0.0.1:$APP_PORT
440434
cd ..
441-
php occ app_ecosystem_v2:daemon:register manual_install "Manual Install" manual-install 0 0 0
442-
php occ app_ecosystem_v2:app:register $APP_ID manual_install --json-info \
443-
"{\"appid\":\"$APP_ID\",\"name\":\"$APP_ID\",\"daemon_config_name\":\"manual_install\",\"version\":\"$APP_VERSION\",\"secret\":\"$APP_SECRET\",\"host\":\"localhost\",\"scopes\":{\"required\":[\"SYSTEM\", \"FILES\", \"FILES_SHARING\"],\"optional\":[\"USER_INFO\", \"USER_STATUS\", \"NOTIFICATIONS\", \"WEATHER_STATUS\", \"TALK\", \"TALK_BOT\"]},\"port\":$APP_PORT,\"protocol\":\"http\",\"system_app\":1}" \
444-
-e --force-scopes
435+
sh nc_py_api/scripts/ci_register.sh "$APP_ID" "$APP_VERSION" "$APP_SECRET" "localhost" "$APP_PORT"
445436
kill -15 $(cat /tmp/_install.pid)
446437
timeout 3m tail --pid=$(cat /tmp/_install.pid) -f /dev/null
447438
@@ -560,10 +551,7 @@ jobs:
560551
python3 tests/_install_wait.py http://127.0.0.1:$APP_PORT/heartbeat "\"status\":\"ok\"" 15 0.5
561552
python3 tests/_app_security_checks.py http://127.0.0.1:$APP_PORT
562553
cd ..
563-
php occ app_ecosystem_v2:daemon:register manual_install "Manual Install" manual-install 0 0 0
564-
php occ app_ecosystem_v2:app:register $APP_ID manual_install --json-info \
565-
"{\"appid\":\"$APP_ID\",\"name\":\"$APP_ID\",\"daemon_config_name\":\"manual_install\",\"version\":\"$APP_VERSION\",\"secret\":\"$APP_SECRET\",\"host\":\"localhost\",\"scopes\":{\"required\":[\"SYSTEM\", \"FILES\", \"FILES_SHARING\"],\"optional\":[\"USER_INFO\", \"USER_STATUS\", \"NOTIFICATIONS\", \"WEATHER_STATUS\", \"TALK\", \"TALK_BOT\"]},\"port\":$APP_PORT,\"protocol\":\"http\",\"system_app\":1}" \
566-
-e --force-scopes
554+
sh nc_py_api/scripts/ci_register.sh "$APP_ID" "$APP_VERSION" "$APP_SECRET" "localhost" "$APP_PORT"
567555
kill -15 $(cat /tmp/_install.pid)
568556
timeout 3m tail --pid=$(cat /tmp/_install.pid) -f /dev/null
569557
@@ -814,10 +802,7 @@ jobs:
814802
python3 tests/_install_wait.py http://127.0.0.1:$APP_PORT/heartbeat "\"status\":\"ok\"" 15 0.5
815803
python3 tests/_app_security_checks.py http://127.0.0.1:$APP_PORT
816804
cd ..
817-
php occ app_ecosystem_v2:daemon:register manual_install "Manual Install" manual-install 0 0 0
818-
php occ app_ecosystem_v2:app:register $APP_ID manual_install --json-info \
819-
"{\"appid\":\"$APP_ID\",\"name\":\"$APP_ID\",\"daemon_config_name\":\"manual_install\",\"version\":\"$APP_VERSION\",\"secret\":\"$APP_SECRET\",\"host\":\"localhost\",\"scopes\":{\"required\":[\"SYSTEM\", \"FILES\", \"FILES_SHARING\"],\"optional\":[\"USER_INFO\", \"USER_STATUS\", \"NOTIFICATIONS\", \"WEATHER_STATUS\", \"TALK\", \"TALK_BOT\"]},\"protocol\":\"http\",\"port\":$APP_PORT,\"system_app\":1}" \
820-
-e --force-scopes
805+
sh nc_py_api/scripts/ci_register.sh "$APP_ID" "$APP_VERSION" "$APP_SECRET" "localhost" "$APP_PORT"
821806
kill -15 $(cat /tmp/_install.pid)
822807
timeout 3m tail --pid=$(cat /tmp/_install.pid) -f /dev/null
823808

.run/register_nc_py_api.run.xml renamed to .run/register_nc_py_api (28).run.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<component name="ProjectRunConfigurationManager">
2-
<configuration default="false" name="register_nc_py_api" type="PythonConfigurationType" factoryName="Python">
2+
<configuration default="false" name="register_nc_py_api (28)" type="PythonConfigurationType" factoryName="Python">
33
<module name="nc_py_api" />
44
<option name="INTERPRETER_OPTIONS" value="" />
55
<option name="PARENT_ENVS" value="true" />

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [0.0.43 - 2023-09-0x]
6+
7+
### Fixed
8+
9+
- `makedirs` correctly work with paths started with `/`
10+
- `listdir` correctly handles `exclude_self=True` when input `path` starts with `/`
11+
512
## [0.0.42 - 2023-08-30]
613

714
### Added

nc_py_api/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Version of nc_py_api."""
22

3-
__version__ = "0.0.42"
3+
__version__ = "0.0.43.dev0"

nc_py_api/files/files.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ def makedirs(self, path: Union[str, FsNode], exist_ok=False) -> Optional[FsNode]
235235
"""
236236
_path = ""
237237
path = path.user_path if isinstance(path, FsNode) else path
238+
path = path.lstrip("/")
238239
result = None
239240
for i in Path(path).parts:
240241
_path = os.path.join(_path, i)
@@ -443,7 +444,7 @@ def _listdir(
443444
)
444445
if exclude_self:
445446
for index, v in enumerate(result):
446-
if v.user_path.rstrip("/") == path.rstrip("/"):
447+
if v.user_path.rstrip("/") == path.strip("/"):
447448
del result[index]
448449
break
449450
return result

scripts/ci_register.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
# Parameters:
4+
# APP_ID, VERSION, SECRET, HOST, PORT
5+
6+
php occ app_ecosystem_v2:daemon:register manual_install "Manual Install" manual-install 0 0 0
7+
php occ app_ecosystem_v2:app:register "$1" manual_install --json-info \
8+
"{\"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}" \
9+
-e --force-scopes

tests/__init__.py

Whitespace-only changes.

tests/_tests_at_the_end.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import sys
33
from subprocess import Popen
44

5-
from _install_wait import check_heartbeat
5+
from ._install_wait import check_heartbeat
66

77
# These tests will be run separate, and at the end of all other tests.
88

tests/actual_tests/__init__.py

Whitespace-only changes.

tests/appcfg_prefs_ex_test.py renamed to tests/actual_tests/appcfg_prefs_ex_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import pytest
2-
from conftest import NC_APP
32

43
from nc_py_api import NextcloudExceptionNotFound
54

5+
from ..conftest import NC_APP
6+
67
if NC_APP is None:
78
pytest.skip("Need App mode", allow_module_level=True)
89

0 commit comments

Comments
 (0)