Conversation
Added comprehensive unit tests for the `enapter.http.api.errors.check_error` function. Covered all logical branches, including successful responses, generic server errors (non-JSON payloads triggering raise_for_status), and API-specific errors (single and multiple errors from DTO). Also added coverage for empty payloads parsing. Co-authored-by: rnovatorov <[email protected]>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Ran `black tests/unit/test_http/test_api/test_errors.py` to fix formatting violations that were causing the CI `make check` step to fail. Now lines involving `httpx.Response` object creation are properly wrapped to respect the line length limit. Co-authored-by: rnovatorov <[email protected]>
|
Thx @jules, nice PR! Could you test that |
Added a new unit test, |
Addresses PR feedback by adding `test_check_error_reads_body` which verifies that `response.aread()` is called when `response.is_success` is False, ensuring the body is completely read for streamed responses. Also fixed PEP8 import order. Co-authored-by: rnovatorov <[email protected]>
🎯 What: The testing gap addressed
The
enapter.http.api.errors.check_errorfunction and the associatedErrorandMultiErrorclasses lacked comprehensive unit testing to verify their expected behaviors under different HTTP response conditions.📊 Coverage: What scenarios are now tested
response.is_successis True.response.raise_for_status()when a non-success response doesn't contain a JSON payload.Errorwith parsed message, code, and details when the API returns an error DTO with exactly one error.MultiErrorwhen the API returns an error DTO with a list of errors.<no message>) are used.✨ Result: The improvement in test coverage
src/enapter/http/api/errors.pyis now rigorously tested, improving confidence when parsing various shapes of HTTP errors from the Enapter API. Tested the functionality usingpytest-asyncioandhttpx.Responsemocks properly equipped withrequestproperties.PR created automatically by Jules for task 3453424892746361646 started by @rnovatorov