def test_no_root_name(self, root, original): ''' When root directory renamed, hash unchanged ''' root.rename('notroot') current = path_.hash(Path('notroot')).hexdigest() assert original == current
def test_directory_move(self, root, original): ''' When directory moves, hash changes ''' (root / 'emptydir').rename(root / 'subdir1/emptydir') current = path_.hash(root).hexdigest() assert original != current
def test_file_content(self, root, original, contents): ''' When file content changes, hash changes ''' path_.write(root / 'file', contents * 3) current = path_.hash(root).hexdigest() assert original != current
def test_file_move(self, root, original): ''' When file moves, hash changes ''' (root / 'file').rename(root / 'subdir1/file') current = path_.hash(root).hexdigest() assert original != current
def test_file_remove(self, root, original): ''' When file removed, hash changes ''' (root / 'file').unlink() current = path_.hash(root).hexdigest() assert original != current
def test_empty_directory_remove(self, root, original): ''' When empty directory removed, hash changes ''' (root / 'emptydir').rmdir() current = path_.hash(root).hexdigest() assert original != current
def test_file_dir_stat(self, root, original): ''' When file/dir stat() changes, hash unchanged ''' (root / 'emptydir').chmod(0o404) (root / 'file').chmod(0o404) current = path_.hash(root).hexdigest() assert original == current
def test_no_root_location(self, root, original): ''' When root directory moved, hash unchanged ''' Path('subdir').mkdir() root.rename('subdir/root') current = path_.hash(Path('subdir/root')).hexdigest() assert original == current
def test_digest_file(path, contents): ''' When file, digest only its contents ''' path_.write(path, contents) hash_ = hashlib.sha512() hash_.update(contents.encode()) assert path_.hash(path).hexdigest() == hash_.hexdigest()
def test_no_cwd(self, root, original): ''' When current working directory changes, hash unchanged ''' root = root.absolute() Path('cwd').mkdir() with pb.local.cwd('cwd'): current = path_.hash(root).hexdigest() assert original == current
def original(self, root): return path_.hash(root).hexdigest()