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