fix: ignore non-JSON project share responses#675
Conversation
|
Overcomplicated tests. Is this llm generated? |
Drop the brittle full-call assertion (exact args/headers dict) and the module-level FakeSession in favor of asserting only the invariant the fix guarantees: share() runs the PUT with error_handling disabled and restores it afterwards.
|
Good call — simplified it. The test now just asserts the invariant the fix guarantees ( |
|
To answer your question directly: yes, I use AI assistance when drafting, under my own direction and review. The #609 bug is real, and I verified both the fix and the now-simplified test pass locally. Happy to adjust the implementation however you'd prefer. |
|
Hmm, i have checked the code a bit more and it seems like the reason why the tests are "overcomplicated" is because essentially it is doing interception. I still think this could be optimised however I can appreciate that this test would be different because if we tested it directly with the scratch website, it would cause an action (which mutates the state of the scratch website). However this is just a drive-by PR caused by the good first issue tag (again). Maybe the idea can be taken (and improved on). |
Fixes #609.
Summary
Project.share()inrequests.no_error_handling()so a successful Scratch share response with a non-JSON body does not raise from the shared response checkershare()performs the PUT while response error handling is disabled, then restores the global handler flagVerification
uv run --project tests pytest tests/test_project.py::test_project_share_disables_response_json_error_handling -quv run --project tests pytest tests/test_project.py -quv run --with ruff ruff check scratchattach/site/project.py tests/test_project.pygit diff --checkNote:
tests/test_project.pyreports the existing credentials-dependent integration test as skipped via warning when local Scratch credentials are unavailable.LLM disclosure
Codex was used to inspect the issue, make the code/test change, run verification commands, and draft this PR description. The final patch was reviewed through local tests and git diff before submission.