Skip to content

test: port session and video tests off sync io#851

Merged
bdraco merged 1 commit into
mainfrom
fix-blockbuster-tests
May 22, 2026
Merged

test: port session and video tests off sync io#851
bdraco merged 1 commit into
mainfrom
fix-blockbuster-tests

Conversation

@bdraco
Copy link
Copy Markdown
Member

@bdraco bdraco commented May 22, 2026

Description of change

Drains the _KNOWN_BLOCKING xfail list from the blockbuster PR by porting the 17 remaining tests off sync IO. The session and CSRF tests in tests/test_api.py now write and read their config files via small async_write_bytes/async_read_bytes/async_write_text/async_read_text helpers added to tests/conftest.py (thin aiofiles wrappers), and path.exists checks switch to aiofiles.os.path.exists; test_get_camera_video swaps the NamedTemporaryFile write for aiofiles into a tmp_path and runs the PyAV validate through asyncio.to_thread; test_write_json follows the same pattern.

After this _KNOWN_BLOCKING is empty, the autouse blockbuster fixture passes for the whole suite, and pre-commit run -a is clean.

Pull-Request Checklist

  • Code is up-to-date with the main branch
  • This pull request follows the contributing guidelines.
  • This pull request links relevant issues as Fixes #0000 N/A
  • There are new or updated unit tests validating the change
  • Documentation has been updated to reflect this change N/A
  • The pull request title follows the conventional commit spec, such as "fix(api): prevent racing of requests" (PRs are squash-merged, so the title becomes the commit on main).
  • If pre-commit.ci is failing, try pre-commit run -a for further information.
  • If CI / test is failing, try poetry run pytest for further information.

Summary by CodeRabbit

  • Tests
    • Test infrastructure updated to use asynchronous file operations.

Review Change Stack

Replace the sync path.write_bytes, read_bytes, exists, write_text
and read_text calls in the session and CSRF tests with aiofiles
based helpers (async_write_bytes etc., new in conftest), and route
the PyAV-based video validation in test_get_camera_video through
asyncio.to_thread, so the autouse blockbuster fixture no longer has
to xfail any of them; the _KNOWN_BLOCKING list is now empty.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 22, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e3293a7b-3fb8-4c4d-b53c-e7fa19fc1d7a

📥 Commits

Reviewing files that changed from the base of the PR and between 93119ff and fa1357f.

📒 Files selected for processing (3)
  • tests/conftest.py
  • tests/test_api.py
  • tests/test_utils.py

📝 Walkthrough

Walkthrough

This PR migrates the test suite from synchronous blocking file I/O to non-blocking async file operations. New async helper functions are introduced in conftest, a blocker xfail list is cleared, and all file I/O calls in test_api and test_utils are updated to use awaited async operations.

Changes

Async File I/O Migration for Test Suite

Layer / File(s) Summary
Async file I/O helpers and xfail cleanup
tests/conftest.py
Adds aiofiles import, introduces four async helper functions (async_write_bytes, async_read_bytes, async_write_text, async_read_text) for non-blocking file reads/writes, and clears _KNOWN_BLOCKING frozenset since tests no longer have blocking I/O.
Migrate test_api.py to async file I/O
tests/test_api.py
Imports async helpers; updates test_get_camera_video to use tmp_path with async_write_bytes and asyncio.to_thread for validation; switches session storage, authentication, and clear-session tests to use async file operations for all config file writes, reads, and existence checks.
Migrate test_utils.py to async file I/O
tests/test_utils.py
Imports aiofiles.os and async_read_text; replaces synchronous path.exists() and path.read_text() checks with async equivalents in test_write_json.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 With async wings, the tests now fly,
No blocking calls to make time sigh,
aiofiles opens the way so clear,
Conftest helpers bring cheer and cheer! 🎉

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-blockbuster-tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 22, 2026

Merging this PR will not alter performance

✅ 4 untouched benchmarks


Comparing fix-blockbuster-tests (fa1357f) with main (93119ff)

Open in CodSpeed

@bdraco bdraco marked this pull request as ready for review May 22, 2026 22:58
Copilot AI review requested due to automatic review settings May 22, 2026 22:58
@bdraco bdraco enabled auto-merge (squash) May 22, 2026 22:59
@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bdraco bdraco disabled auto-merge May 22, 2026 22:59
@bdraco bdraco merged commit a7deac1 into main May 22, 2026
10 of 13 checks passed
@bdraco bdraco deleted the fix-blockbuster-tests branch May 22, 2026 22:59
@bdraco bdraco review requested due to automatic review settings May 22, 2026 23:21
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