Beispiel #1
0
 def test_memory_returns_fs_client_with_memory_fs(self) -> None:
     actual = helpers.memory()
     assert type(actual.fs) is MemoryFileSystem
     assert actual.fs.path_to_string(Path("", "foo", "bar")) == "foo/bar"
     assert actual != helpers.memory()
Beispiel #2
0
 def test_memory_returns_fs_client_with_memory_fs_with_set_separator(
         self) -> None:
     actual = helpers.memory(separator="@")
     assert type(actual.fs) is MemoryFileSystem
     assert actual.fs.path_to_string(Path("", "foo", "bar")) == "foo@bar"
Beispiel #3
0
 def parse_path(self, path: str) -> Path:
     tail: List[str] = path.split(self._separator)
     return Path("", *tail)
Beispiel #4
0
def random_path(drive: Optional[str] = None, prefix: List[str] = []) -> Path:
    if drive is None:
        drive = randstr()
    tail: List[str] = prefix + [randstr() for _ in range(random.randint(1, 5))]
    return Path(drive, *tail)
Beispiel #5
0
 def make_path(self, *tail: str) -> Path:
     return Path("", *tail)
Beispiel #6
0
 def make_path(self, *tail: str) -> Path:
     return Path(self.bucket_name, *tail)
Beispiel #7
0
 def test_child(self) -> None:
     child_name: str = mock.Mock(spec=str)
     assert self.sut.child(child_name) == Path(self.drive, *self.tail,
                                               child_name)
Beispiel #8
0
 def test_parent(self) -> None:
     assert self.sut.parent == Path(self.drive, *self.tail[:-1])
Beispiel #9
0
 def setUp(self) -> None:
     self.drive = mock.Mock(spec=str)
     self.tail = [mock.Mock(spec=str) for _ in range(random.randint(1, 10))]
     self.sut = Path(self.drive, *self.tail)