| 44 | |
| 45 | |
| 46 | class DummyHandler(FileSystemHandler): |
| 47 | def __init__(self, value=42): |
| 48 | self._value = value |
| 49 | |
| 50 | def __eq__(self, other): |
| 51 | if isinstance(other, FileSystemHandler): |
| 52 | return self._value == other._value |
| 53 | return NotImplemented |
| 54 | |
| 55 | def __ne__(self, other): |
| 56 | if isinstance(other, FileSystemHandler): |
| 57 | return self._value != other._value |
| 58 | return NotImplemented |
| 59 | |
| 60 | def get_type_name(self): |
| 61 | return "dummy" |
| 62 | |
| 63 | def normalize_path(self, path): |
| 64 | return path |
| 65 | |
| 66 | def get_file_info(self, paths): |
| 67 | info = [] |
| 68 | for path in paths: |
| 69 | if "file" in path: |
| 70 | info.append(FileInfo(path, FileType.File)) |
| 71 | elif "dir" in path: |
| 72 | info.append(FileInfo(path, FileType.Directory)) |
| 73 | elif "notfound" in path: |
| 74 | info.append(FileInfo(path, FileType.NotFound)) |
| 75 | elif "badtype" in path: |
| 76 | # Will raise when converting |
| 77 | info.append(object()) |
| 78 | else: |
| 79 | raise IOError |
| 80 | return info |
| 81 | |
| 82 | def get_file_info_selector(self, selector): |
| 83 | if selector.base_dir != "somedir": |
| 84 | if selector.allow_not_found: |
| 85 | return [] |
| 86 | else: |
| 87 | raise FileNotFoundError(selector.base_dir) |
| 88 | infos = [ |
| 89 | FileInfo("somedir/file1", FileType.File, size=123), |
| 90 | FileInfo("somedir/subdir1", FileType.Directory), |
| 91 | ] |
| 92 | if selector.recursive: |
| 93 | infos += [ |
| 94 | FileInfo("somedir/subdir1/file2", FileType.File, size=456), |
| 95 | ] |
| 96 | return infos |
| 97 | |
| 98 | def create_dir(self, path, recursive): |
| 99 | if path == "recursive": |
| 100 | assert recursive is True |
| 101 | elif path == "non-recursive": |
| 102 | assert recursive is False |
| 103 | else: |
no outgoing calls