コード例 #1
0
 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
コード例 #2
0
 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
コード例 #3
0
 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
コード例 #4
0
 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
コード例 #5
0
 def test_file_remove(self, root, original):
     '''
     When file removed, hash changes
     '''
     (root / 'file').unlink()
     current = path_.hash(root).hexdigest()
     assert original != current
コード例 #6
0
 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
コード例 #7
0
 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
コード例 #8
0
 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
コード例 #9
0
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()
コード例 #10
0
 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
コード例 #11
0
 def original(self, root):
     return path_.hash(root).hexdigest()