Example #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()
Example #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"
Example #3
0
 def parse_path(self, path: str) -> Path:
     tail: List[str] = path.split(self._separator)
     return Path("", *tail)
Example #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)
Example #5
0
 def make_path(self, *tail: str) -> Path:
     return Path("", *tail)
Example #6
0
 def make_path(self, *tail: str) -> Path:
     return Path(self.bucket_name, *tail)
Example #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)
Example #8
0
 def test_parent(self) -> None:
     assert self.sut.parent == Path(self.drive, *self.tail[:-1])
Example #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)