def test_DataPackageFileAttributesAreValid_different_checksum(): df = dpack_pb2.DataPackageFile() df.relative_path = 'a' df.checksum_hash = dpack_pb2.SHA256 with tempfile.TemporaryDirectory() as d: (pathlib.Path(d) / 'a').touch() assert not dpack.DataPackageFileAttributesAreValid(pathlib.Path(d), df)
def test_DataPackageFileAttributesAreValid_match(): df = dpack_pb2.DataPackageFile() df.relative_path = 'a' df.checksum_hash = dpack_pb2.SHA256 df.checksum = SHA256_EMPTY_FILE with tempfile.TemporaryDirectory() as d: (pathlib.Path(d) / 'a').touch() assert dpack.DataPackageFileAttributesAreValid(pathlib.Path(d), df)
def test_DataPackageFileAttributesAreValid_different_size(): df = dpack_pb2.DataPackageFile() df.relative_path = 'a' df.checksum_hash = dpack_pb2.SHA256 df.checksum = SHA256_EMPTY_FILE df.size_in_bytes = 10 # An empty file has size 0 with tempfile.TemporaryDirectory() as d: (pathlib.Path(d) / 'a').touch() assert not dpack.DataPackageFileAttributesAreValid(pathlib.Path(d), df)
def test_DataPackageFileAttributesAreValid_missing_file(): df = dpack_pb2.DataPackageFile() df.relative_path = 'a' with tempfile.TemporaryDirectory() as d: assert not dpack.DataPackageFileAttributesAreValid(pathlib.Path(d), df)