diff --git a/.github/workflows/pcloud-test.yml b/.github/workflows/pcloud-test.yml index 802c557..cc20c52 100644 --- a/.github/workflows/pcloud-test.yml +++ b/.github/workflows/pcloud-test.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.8, 3.9, "3.10", "3.11", "3.12"] + python-version: [3.9, "3.10", "3.11", "3.12", "3.13"] max-parallel: 1 steps: - uses: actions/checkout@v4 diff --git a/CHANGES.rst b/CHANGES.rst index 6284a4b..55274fa 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,7 +4,9 @@ Changelog 1.4 (unreleased) ---------------- -- Nothing changed yet. +- Update (testing) dependencies [tomgross] +- Run tests on Python 3.9-3.13 [tomgross] +- Allow `eapi` with fs.opener #85 [tomgross] 1.3 (2024-03-01) diff --git a/setup.py b/setup.py index 6b27136..aa8ee1e 100644 --- a/setup.py +++ b/setup.py @@ -27,11 +27,11 @@ "Environment :: Other Environment", "Environment :: Web Environment", "Programming Language :: Python", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Operating System :: OS Independent", "License :: OSI Approved :: MIT License", "Topic :: Software Development :: Libraries :: Python Modules", @@ -48,10 +48,14 @@ install_requires=[ "requests", "requests-toolbelt", - "setuptools>=70.3.0" + "wheel>=0.45.1", + "setuptools>=75.6.0" ], extras_require={"pyfs": ["fs"]}, entry_points={ - "fs.opener": ["pcloud = pcloud.pcloudfs:PCloudOpener"], + "fs.opener": [ + "pcloud = pcloud.pcloudfs:PCloudOpener", + "pcloud+eapi = pcloud.pcloudfs:PCloudOpener", + ], }, ) diff --git a/src/pcloud/pcloudfs.py b/src/pcloud/pcloudfs.py index d9e5b6d..4e286fa 100644 --- a/src/pcloud/pcloudfs.py +++ b/src/pcloud/pcloudfs.py @@ -392,12 +392,19 @@ def removetree(self, dir_path): class PCloudOpener(Opener): - protocols = ["pcloud"] + protocols = ["pcloud", "pcloud+eapi"] @staticmethod def open_fs(fs_url, parse_result, writeable, create, cwd): _, _, directory = parse_result.resource.partition("/") - fs = PCloudFS(username=parse_result.username, password=parse_result.password) + endpoint = "api" + if "+" in parse_result.protocol: + _, endpoint = parse_result.protocol.split("+") + fs = PCloudFS( + username=parse_result.username, + password=parse_result.password, + endpoint=endpoint, + ) if directory: return fs.opendir(directory) else: diff --git a/src/pcloud/tests/notest_oauth2.py b/src/pcloud/tests/test_oauth2.py similarity index 95% rename from src/pcloud/tests/notest_oauth2.py rename to src/pcloud/tests/test_oauth2.py index 3a485e5..31c7a5b 100644 --- a/src/pcloud/tests/notest_oauth2.py +++ b/src/pcloud/tests/test_oauth2.py @@ -20,7 +20,8 @@ class PlaywrightTokenHandler(TokenHandler): def open_browser(self): with sync_playwright() as p: - self.browser = p.firefox.launch() + # set headless to `False` for debugging purposes + self.browser = p.firefox.launch(headless=True) self.browser.new_context( locale="de-DE", timezone_id="Europe/Berlin", diff --git a/src/pcloud/tests/test_pyfs.py b/src/pcloud/tests/test_pyfs.py index fdc7ed2..61cb10a 100644 --- a/src/pcloud/tests/test_pyfs.py +++ b/src/pcloud/tests/test_pyfs.py @@ -4,10 +4,13 @@ from fs import errors from fs.test import FSTestCases +from fs import opener from pcloud.pcloudfs import PCloudFS +from urllib.parse import quote class TestpCloudFS(FSTestCases, unittest.TestCase): + @classmethod def setUpClass(cls): username = os.environ.get("PCLOUD_USERNAME") @@ -68,3 +71,11 @@ def test_remove(self): error_msg = "resource 'foo/bar/egg/test.txt' not found" with self.assertRaisesRegex(errors.ResourceNotFound, error_msg): self.fs.remove("foo/bar/egg/test.txt") + + # Test custom functionality + + def test_fs_opener(self): + username = quote(os.environ.get("PCLOUD_USERNAME")) + password = os.environ.get("PCLOUD_PASSWORD") + with opener.open_fs(f"pcloud+eapi://{username}:{password}@/") as pcloud_fs: + assert pcloud_fs.pcloud.endpoint == "https://eapi.pcloud.com/" diff --git a/test_requirements.txt b/test_requirements.txt index 47eac12..73d0d44 100644 --- a/test_requirements.txt +++ b/test_requirements.txt @@ -1,11 +1,12 @@ -pytest==7.4.4 +pytest==8.3.4 pytest-sugar==1.0.0 -pytest-timeout==2.2.0 -pytest-cov==4.1.0 -pytest-rerunfailures==13.0 -wheel==0.42.0 -flake8==7.0.0 +pytest-timeout==2.3.1 +pytest-cov==6.0.0 +pytest-rerunfailures==15.0 +wheel==0.45.1 +flake8==7.1.1 fs==2.4.16 -playwright==1.41.2 -multipart==0.2.4 -setuptools>=65.5.1 # not directly required, pinned by Snyk to avoid a vulnerability \ No newline at end of file +playwright==1.49.1 +multipart==1.2.1 +setuptools>=75.6.0 # not directly required, pinned by Snyk to avoid a vulnerability +zipp>=3.19.1 # not directly required, pinned by Snyk to avoid a vulnerability \ No newline at end of file