|
1 | 1 | """Integration tests for StorableContainer""" |
2 | 2 |
|
3 | 3 | import csv |
4 | | -import os |
5 | 4 | import uuid |
6 | 5 | from pathlib import Path |
7 | 6 | from typing import Callable |
@@ -386,108 +385,3 @@ async def test_error_column_rows_skipped( |
386 | 385 | for f in synced.files: |
387 | 386 | if f.name == unique_name: |
388 | 387 | self.schedule_for_cleanup(f.id) |
389 | | - |
390 | | - async def test_recreate_hierarchy_creates_folders( |
391 | | - self, project_model: Project, tmp_path: Path |
392 | | - ) -> None: |
393 | | - """ |
394 | | - When files live in nested local directories (e.g., subdir_a/file1.txt, |
395 | | - subdir_a/subdir_b/file2.txt) and recreate_hierarchy is enabled, |
396 | | - Synapse folders are created to match the local layout and files are |
397 | | - placed inside the corresponding folders. |
398 | | - """ |
399 | | - # GIVEN local files arranged in a nested directory hierarchy |
400 | | - subdir_a = tmp_path / "subdir_a" |
401 | | - subdir_b = subdir_a / "subdir_b" |
402 | | - subdir_b.mkdir(parents=True) |
403 | | - |
404 | | - file_at_root = _create_local_test_file("root level", tmp_path) |
405 | | - file_in_a = subdir_a / f"{uuid.uuid4()}_in_a.txt" |
406 | | - file_in_a.write_text("inside subdir_a", encoding="utf-8") |
407 | | - file_in_b = subdir_b / f"{uuid.uuid4()}_in_b.txt" |
408 | | - file_in_b.write_text("inside subdir_a/subdir_b", encoding="utf-8") |
409 | | - |
410 | | - name_root = f"root_{uuid.uuid4()}.txt" |
411 | | - name_a = f"a_{uuid.uuid4()}.txt" |
412 | | - name_b = f"b_{uuid.uuid4()}.txt" |
413 | | - |
414 | | - # AND a manifest where every file points at the project as parentId |
415 | | - manifest_path = _write_manifest( |
416 | | - [ |
417 | | - { |
418 | | - "path": str(file_at_root), |
419 | | - "parentId": project_model.id, |
420 | | - "name": name_root, |
421 | | - }, |
422 | | - { |
423 | | - "path": str(file_in_a), |
424 | | - "parentId": project_model.id, |
425 | | - "name": name_a, |
426 | | - }, |
427 | | - { |
428 | | - "path": str(file_in_b), |
429 | | - "parentId": project_model.id, |
430 | | - "name": name_b, |
431 | | - }, |
432 | | - ], |
433 | | - tmp_path, |
434 | | - ) |
435 | | - |
436 | | - # WHEN I sync to Synapse |
437 | | - await project_model.sync_to_synapse_async( |
438 | | - manifest_path=str(manifest_path), |
439 | | - send_messages=False, |
440 | | - synapse_client=self.syn, |
441 | | - ) |
442 | | - |
443 | | - # THEN the project contains the mirrored folder structure |
444 | | - synced_project = await Project(id=project_model.id).sync_from_synapse_async( |
445 | | - recursive=True, download_file=False, synapse_client=self.syn |
446 | | - ) |
447 | | - |
448 | | - # The root-level file is in the project root, but NOT the subdirectory files |
449 | | - root_file_names = {f.name for f in synced_project.files} |
450 | | - assert name_root in root_file_names |
451 | | - assert name_a not in root_file_names, "file_in_a should not be at project root" |
452 | | - assert name_b not in root_file_names, "file_in_b should not be at project root" |
453 | | - |
454 | | - # subdir_a was created as a Synapse folder |
455 | | - folder_names = {f.name for f in synced_project.folders} |
456 | | - assert "subdir_a" in folder_names |
457 | | - |
458 | | - synapse_subdir_a = next( |
459 | | - f for f in synced_project.folders if f.name == "subdir_a" |
460 | | - ) |
461 | | - self.schedule_for_cleanup(synapse_subdir_a.id) |
462 | | - synced_a = await Folder(id=synapse_subdir_a.id).sync_from_synapse_async( |
463 | | - recursive=True, download_file=False, synapse_client=self.syn |
464 | | - ) |
465 | | - |
466 | | - # file_in_a is inside subdir_a |
467 | | - a_file_names = {f.name for f in synced_a.files} |
468 | | - assert name_a in a_file_names |
469 | | - |
470 | | - # subdir_b was created as a nested Synapse folder inside subdir_a |
471 | | - a_folder_names = {f.name for f in synced_a.folders} |
472 | | - assert "subdir_b" in a_folder_names |
473 | | - |
474 | | - synapse_subdir_b = next(f for f in synced_a.folders if f.name == "subdir_b") |
475 | | - self.schedule_for_cleanup(synapse_subdir_b.id) |
476 | | - synced_b = await Folder(id=synapse_subdir_b.id).sync_from_synapse_async( |
477 | | - recursive=False, download_file=False, synapse_client=self.syn |
478 | | - ) |
479 | | - |
480 | | - # file_in_b is inside subdir_a/subdir_b |
481 | | - b_file_names = {f.name for f in synced_b.files} |
482 | | - assert name_b in b_file_names |
483 | | - |
484 | | - # Clean up files |
485 | | - for f in synced_project.files: |
486 | | - if f.name == name_root: |
487 | | - self.schedule_for_cleanup(f.id) |
488 | | - for f in synced_a.files: |
489 | | - if f.name == name_a: |
490 | | - self.schedule_for_cleanup(f.id) |
491 | | - for f in synced_b.files: |
492 | | - if f.name == name_b: |
493 | | - self.schedule_for_cleanup(f.id) |
0 commit comments