Skip to content

Speed up and restore sync and upload_dir integration tests - #132

Merged
const-cloudinary merged 1 commit into
masterfrom
chore/sync-test-waits
Oct 4, 2026
Merged

const-cloudinary merged 1 commit into
masterfrom
chore/sync-test-waits

Conversation

@const-cloudinary

Copy link
Copy Markdown
Member

Makes the sync and upload_dir integration tests wait for assets instead of sleeping, and runs all of TestCLISync again.

Brief Summary of Changes

  • _wait_for_cld_files (test/test_modules/test_cli_sync.py): polls Search every 0.5s until the folder has the expected number of assets and exists (or is gone), and fails with the expected and found values after 15s. Used in setUp and after _upload_sync_files, replacing the fixed time.sleep calls and GRACE_PERIOD.
  • TestCLIUploadDir: removes the 1s sleeps in setUp and tearDown.
  • retry_assertion (test/helper_test.py): works as @retry_assertion and @retry_assertion(...), and runs tearDown and setUp between tries. The 9 decorated tests in TestCLISync now run their bodies.
  • delete_cld_folder_if_exists in dynamic folder mode: deletes the assets found with Search, and lists them with the Admin API, folder by folder, when delete_folder reports that the folder is not empty.
  • SyncDir.push and SyncDir.pull return True after transferring files, so sync prints "Done!" in that case too.
  • test_cli_sync_duplicate_file_names_dynamic_folder_mode: expects the current "Local folder ... does not exist." log line.

What does this PR address?

  • GitHub issue (Add reference - #XX)
  • Refactoring
  • New feature
  • Bug fix
  • Adds more tests

Are tests included?

  • Yes
  • No

Reviewer, please note:

  • test_cli_sync.py takes longer than on master, because the 9 restored tests now upload and sync files. Tests that already ran are 3–6s faster each.
  • Fixed folder mode cleanup is unchanged (prefix delete per resource type).

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I ran the full test suite before pushing the changes and all the tests pass.

Ran test_cli_sync.py and test_cli_upload_dir.py against a test cloud in dynamic folder mode: 31 of 32 passed. The remaining test passed on its own after updating its expected log line. Fixed folder mode is covered by CI only.

🤖 Generated with Claude Code

- Wait for assets to be indexed instead of sleeping for fixed periods.
  `_wait_for_cld_files` polls Search until the folder has the expected
  number of assets, and fails with a clear message on timeout.
- Run all `TestCLISync` tests again: `@retry_assertion` now works with
  and without parentheses and runs `tearDown` and `setUp` between tries.
- Clean up dynamic folders with Search, and fall back to the Admin API
  when some assets are not indexed yet.
- `sync` prints "Done!" after uploading or downloading files.
- Update the expected log line for a missing local folder.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@const-cloudinary
const-cloudinary merged commit 7b0fbca into master Oct 4, 2026
8 checks passed
@const-cloudinary
const-cloudinary deleted the chore/sync-test-waits branch October 4, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant