-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: juftin <juftin@juftin.com> Co-authored-by: ap-- <andreas@poehlmann.io>
- Loading branch information
1 parent
5c240c1
commit 8314a65
Showing
4 changed files
with
96 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
""" | ||
GitHub file system implementation | ||
""" | ||
|
||
import upath.core | ||
|
||
|
||
class GitHubPath(upath.core.UPath): | ||
""" | ||
GitHubPath supporting the fsspec.GitHubFileSystem | ||
""" | ||
|
||
@property | ||
def path(self) -> str: | ||
pth = super().path | ||
if pth == ".": | ||
return "" | ||
return pth | ||
|
||
def iterdir(self): | ||
if self.is_file(): | ||
raise NotADirectoryError(str(self)) | ||
yield from super().iterdir() |
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,71 @@ | ||
import os | ||
import platform | ||
import sys | ||
|
||
import pytest | ||
|
||
from upath import UPath | ||
from upath.implementations.github import GitHubPath | ||
from upath.tests.cases import BaseTests | ||
|
||
pytestmark = pytest.mark.skipif( | ||
os.environ.get("CI") | ||
and (sys.version_info not in {(3, 8), (3, 12)} and platform.system() != "Linux"), | ||
reason="Skipping GitHubPath tests to prevent rate limiting on GitHub API.", | ||
) | ||
|
||
|
||
class TestUPathGitHubPath(BaseTests): | ||
""" | ||
Unit-tests for the GitHubPath implementation of UPath. | ||
""" | ||
|
||
@pytest.fixture(autouse=True) | ||
def path(self): | ||
""" | ||
Fixture for the UPath instance to be tested. | ||
""" | ||
path = "github://ap--:universal_pathlib@test_data/data" | ||
self.path = UPath(path) | ||
|
||
def test_is_GitHubPath(self): | ||
""" | ||
Test that the path is a GitHubPath instance. | ||
""" | ||
assert isinstance(self.path, GitHubPath) | ||
|
||
@pytest.mark.skip(reason="GitHub filesystem is read-only") | ||
def test_mkdir(self): | ||
pass | ||
|
||
@pytest.mark.skip(reason="GitHub filesystem is read-only") | ||
def test_mkdir_exists_ok_false(self): | ||
pass | ||
|
||
@pytest.mark.skip(reason="GitHub filesystem is read-only") | ||
def test_mkdir_parents_true_exists_ok_false(self): | ||
pass | ||
|
||
@pytest.mark.skip(reason="GitHub filesystem is read-only") | ||
def test_rename(self): | ||
pass | ||
|
||
@pytest.mark.skip(reason="GitHub filesystem is read-only") | ||
def test_rename2(self): | ||
pass | ||
|
||
@pytest.mark.skip(reason="GitHub filesystem is read-only") | ||
def test_touch_unlink(self): | ||
pass | ||
|
||
@pytest.mark.skip(reason="GitHub filesystem is read-only") | ||
def test_write_bytes(self): | ||
pass | ||
|
||
@pytest.mark.skip(reason="GitHub filesystem is read-only") | ||
def test_write_text(self): | ||
pass | ||
|
||
@pytest.mark.skip(reason="GitHub filesystem is read-only") | ||
def test_fsspec_compat(self): | ||
pass |
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 |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
"webdav", | ||
"webdav+http", | ||
"webdav+https", | ||
"github", | ||
} | ||
|
||
|
||
|