Hsyshasuzh/longmemory-geo / project /tests /test_dior_queue_development_screen.py
Hsyshasuzh's picture
download
raw
1.69 kB
import hashlib
import json
import tempfile
import unittest
from pathlib import Path
from PIL import Image
from evaluation.audit_dior_queue_dota_development import audit
class QueueScreenTests(unittest.TestCase):
def test_finds_duplicate_and_does_not_grant_eligibility(self):
with tempfile.TemporaryDirectory() as temp:
root = Path(temp)
image, reference = root / 'queue.png', root / 'dev.png'
Image.new('RGB', (16, 16), (20, 80, 130)).save(image)
reference.write_bytes(image.read_bytes())
queue = root / 'queue.json'
queue.write_text(json.dumps({'records': [{'id': 'one', 'image': str(image),
'image_sha256': hashlib.sha256(image.read_bytes()).hexdigest(), 'training_eligible': False}]}))
report = audit(queue, [reference])
self.assertEqual(len(report['matches']), 1)
self.assertTrue(report['matches'][0]['exact_rgb'])
self.assertFalse(report['training_eligible'])
self.assertFalse(report['independence_established'])
def test_rejects_changed_queue_image(self):
with tempfile.TemporaryDirectory() as temp:
root = Path(temp); image = root / 'queue.png'
Image.new('RGB', (16, 16)).save(image)
queue = root / 'queue.json'
queue.write_text(json.dumps({'records': [{'id': 'one', 'image': str(image),
'image_sha256': '0' * 64, 'training_eligible': False}]}))
with self.assertRaisesRegex(ValueError, 'hash mismatch'):
audit(queue, [image])
if __name__ == '__main__':
unittest.main()

Xet Storage Details

Size:
1.69 kB
·
Xet hash:
5881911b7c2995123f671027d95d3ed2fc4ad55a69ec3d54f621b9def3180e6d

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.