def test_calculate(self, filedir): """Compute the checksum of the file-object.""" path = filedir.write('file.c4gh', c4gh_data.ENC_FILE.encode('utf-8')) with open(path, 'rb') as file_data: data = file_data.read() file_hash = (hashlib.md5)(data).hexdigest() assert calculate(path, 'md5') == file_hash filedir.cleanup()
def test_calculate(self, filedir): """Compute the checksum of the file-object.""" path = filedir.write('priv.pgp', pgp_data.PGP_PRIVKEY.encode('utf-8')) with open(path, 'rb') as file_data: data = file_data.read() file_hash = (hashlib.md5)(data).hexdigest() assert calculate(path, 'md5') == file_hash filedir.cleanup()
def test_calculate_error(self): """Test nonexisting file.""" assert calculate('tests/resources/notexisting.file', 'md5') is None