Skip to content

Commit

Permalink
Merge branch 'main' of github.com:Kataglyphis/WebDavClient
Browse files Browse the repository at this point in the history
  • Loading branch information
Kataglyphis committed Jul 18, 2024
2 parents 043331d + 75b67ad commit bfb0455
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 12 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name: Deploy web page with sphinx

on:
push:
branches: [ "main" ]
branches: ["main"]

jobs:
build:
Expand All @@ -25,7 +25,12 @@ jobs:
run: |
pip install -v -e .
pip install -r requirements/docs.txt
- name : Build web page
pip install -r requirements/test.txt
- name: Run tests
run: |
cd tests
pytest
- name: Build web page
run: |
cd docs
make html
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local_data
assets
.vscode/launch.json

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"python.testing.pytestArgs": [],
"python.testing.cwd": "${workspaceFolder}/tests",
}
8 changes: 4 additions & 4 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[pytest]
testpaths = tests
norecursedirs = .git ignore build __pycache__ data docker docs .eggs
; norecursedirs = .git ignore build __pycache__ data docker docs .eggs

filterwarnings= default
ignore:.*No cfgstr given in Cacher constructor or call.*:Warning
ignore:.*Define the __nice__ method for.*:Warning
; filterwarnings= default
; ignore:.*No cfgstr given in Cacher constructor or call.*:Warning
; ignore:.*Define the __nice__ method for.*:Warning
19 changes: 13 additions & 6 deletions tests/test_webdav_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@


def cleanup_test_files() -> None:
os.removedirs("local_data")
try:
shutil.rmtree("local_data")
shutil.rmtree("local_data2")
print(
f"The directory local_data and local_data2 and all its contents have been removed successfully."
)
except OSError as e:
print(f"Error : {e.strerror}")


def wait_for_server_to_start(url, timeout=10) -> bool:
Expand All @@ -29,19 +36,19 @@ def wait_for_server_to_start(url, timeout=10) -> bool:
def start_webdav_server():

# Start the mock WebDav server
# server_process = subprocess.Popen([sys.executable, "mock_webdav_server.py"])
server_process = subprocess.Popen(["python", "mock_webdav_server.py"])
# Wait for the server to start
# server_started = wait_for_server_to_start("http://localhost:8081")
# if not server_started:
# server_process.terminate()
# pytest.fail("Could not start the mock WebDAV server.")

# time.sleep(10)
time.sleep(4)
yield

# Terminate the server process after all tests are done
# server_process.terminate()
# server_process.wait()
server_process.terminate()
server_process.wait()

# Cleanup after tests
cleanup_test_files()
Expand Down Expand Up @@ -109,7 +116,7 @@ def test_download_files(webdav_client) -> None:
def test_download_all_files_iterative(webdav_client):

remote_base_path = "data"
local_base_path = "local_data"
local_base_path = "local_data2"

webdav_client.download_all_files_iterative(remote_base_path, local_base_path)
assert os.path.exists(os.path.join(local_base_path, "Readme.md"))
Expand Down
3 changes: 3 additions & 0 deletions webdavclient/webdavclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,9 @@ def download_files(
self.logger.info("The remote file url is: %s", remote_file_url)
sub_path = self.get_sub_path(file_path, global_remote_base_path)

if sub_path.endswith(decoded_filename):
sub_path = sub_path[: len(sub_path) - len(decoded_filename)]

if sub_path == decoded_filename:
sub_path = ""

Expand Down

0 comments on commit bfb0455

Please sign in to comment.