2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-17 17:47:13 +00:00

chunked helper to return DrawinGFile objects

This commit is contained in:
2025-12-15 19:42:23 +00:00
parent dd2bfe8fe3
commit f3b46856ee
2 changed files with 46 additions and 5 deletions

View File

@@ -145,3 +145,22 @@ class DrawingsPathlibTests(TestCase):
self.assertEqual(set(drawings.IMAGE_LIKE_EXTS), set(drawings.IMAGE_EXTS))
self.assertIn('.th', drawings.SUPPORTED_EXTENSIONS)
self.assertIn('.png', drawings.SUPPORTED_EXTENSIONS)
def test_fetch_drawingfiles_by_paths_chunks(self):
# Create more items than typical SQLite parameter limit to ensure chunking
count = 1200
rel_paths = []
objs = []
for i in range(count):
rel = f'bigdir/file{i}.txt'
rel_paths.append(rel)
objs.append(DrawingFile(dwgpath=rel, dwgname=f'name{i}'))
# Bulk create them efficiently
DrawingFile.objects.bulk_create(objs)
mapping = drawings.fetch_drawingfiles_by_paths(rel_paths, chunk_size=500)
self.assertEqual(len(mapping), count)
# Spot-check a few entries
self.assertIn('bigdir/file0.txt', mapping)
self.assertIn(f'bigdir/file{count-1}.txt', mapping)