19 lines
728 B
Python
19 lines
728 B
Python
from pathlib import Path
|
|
|
|
from image_prediction.encoder.encoders.hash_encoder import HashEncoder
|
|
from image_prediction.image_extractor.extractors.parsable import ParsablePDFImageExtractor
|
|
|
|
|
|
def test_all_hashes_have_length_of_twentyfive():
|
|
"""See RED-3814: all hashes should have 25 characters."""
|
|
pdf_path = Path(__file__).parents[1] / "data" / "RED-3814" / "similarImages2.pdf"
|
|
pdf_bytes = pdf_path.read_bytes()
|
|
image_extractor = ParsablePDFImageExtractor()
|
|
image_metadata_pairs = list(image_extractor.extract(pdf_bytes))
|
|
images = [image for image, _ in image_metadata_pairs]
|
|
|
|
hash_encoder = HashEncoder()
|
|
hashes = list(hash_encoder.encode(images))
|
|
|
|
assert all(len(h) == 25 for h in hashes)
|