Skip to content

test: respx suite at the HTTP boundary; type-check tests (ratchet resolved)#57

Merged
Datata1 merged 1 commit into
mainfrom
refactor/06-test-suite-http-boundary
Jul 12, 2026
Merged

test: respx suite at the HTTP boundary; type-check tests (ratchet resolved)#57
Datata1 merged 1 commit into
mainfrom
refactor/06-test-suite-http-boundary

Conversation

@Datata1

@Datata1 Datata1 commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Implements plans/refactor/06-test-suite-http-boundary.md:

  • Add respx (dev). New shared fixtures: mock_api (respx router on the test base URL) and sdk (opened CodesphereSDK against it)
  • tests/test_exceptions.py: full raise_for_status matrix over real httpx.Response objects (status->class for every exported exception, message-key extraction incl. joined error lists, non-JSON bodies, Retry-After parsing incl. non-numeric, APIError request context and str), default constructors for all 10 exception classes, plus end-to-end error surfacing through the real transport (404/429/ timeout/connect)
  • tests/core/test_execute_operation.py: executor behavior on the real wire — URL building from path params, auth header, input_model validation stopping bad payloads before any request, empty-dict body regression, NoneType responses, response validation, and bound ResourceList items making follow-up calls
  • tests/test_http_client.py: transport lifecycle (idempotent open, close-without-open), the full httpx->SDK error mapping matrix, timeout/stream_timeout properties, stream() passthrough
  • Coverage: exceptions/config/http_client at 100%, core/handler at 96%
  • ty ratchet fully resolved: tests/ removed from [tool.ty.src] exclude; the whole repo (src + tests) now type-checks. Fallout fixed properly where real (env_vars set/delete annotations didn't admit list[EnvVar]; isinstance narrowing in delete; typed workspace configs in the integration conftest) and suppressed surgically where ty is wrong (pytest.skip/fail signature resolution, funneled through skip_test/ fail_test helpers)
  • CONTRIBUTING.md documents the mocking policy: new tests mock the transport (respx), never SDK internals

…olved)

Implements plans/refactor/06-test-suite-http-boundary.md:

- Add respx (dev). New shared fixtures: mock_api (respx router on the
  test base URL) and sdk (opened CodesphereSDK against it)
- tests/test_exceptions.py: full raise_for_status matrix over real
  httpx.Response objects (status->class for every exported exception,
  message-key extraction incl. joined error lists, non-JSON bodies,
  Retry-After parsing incl. non-numeric, APIError request context and
  __str__), default constructors for all 10 exception classes, plus
  end-to-end error surfacing through the real transport (404/429/
  timeout/connect)
- tests/core/test_execute_operation.py: executor behavior on the real
  wire — URL building from path params, auth header, input_model
  validation stopping bad payloads before any request, empty-dict body
  regression, NoneType responses, response validation, and bound
  ResourceList items making follow-up calls
- tests/test_http_client.py: transport lifecycle (idempotent open,
  close-without-open), the full httpx->SDK error mapping matrix,
  timeout/stream_timeout properties, stream() passthrough
- Coverage: exceptions/config/http_client at 100%, core/handler at 96%
- ty ratchet fully resolved: tests/ removed from [tool.ty.src] exclude;
  the whole repo (src + tests) now type-checks. Fallout fixed properly
  where real (env_vars set/delete annotations didn't admit list[EnvVar];
  isinstance narrowing in delete; typed workspace configs in the
  integration conftest) and suppressed surgically where ty is wrong
  (pytest.skip/fail signature resolution, funneled through skip_test/
  fail_test helpers)
- CONTRIBUTING.md documents the mocking policy: new tests mock the
  transport (respx), never SDK internals
@Datata1 Datata1 self-assigned this Jul 12, 2026
@Datata1 Datata1 merged commit a2c5edf into main Jul 12, 2026
3 of 4 checks passed
@github-actions

Copy link
Copy Markdown

🛡️ Bandit Security Scan Results

✅ No security issues found by Bandit.

@github-actions

Copy link
Copy Markdown

Coverage

Pytest Coverage Report
FileStmtsMissBranchBrPartCoverMissing
__init__.py9000100% 
client.py40060100% 
config.py9000100% 
exceptions.py940380100% 
http_client.py59060100% 
utils.py1024179%9->10, 10–11
core
   __init__.py4000100% 
   base.py55020100% 
   handler.py59318096%80–82
   operations.py15000100% 
resources
   __init__.py0000100% 
resources/metadata
   __init__.py3000100% 
   operations.py6000100% 
   resources.py13000100% 
   schemas.py28000100% 
resources/team
   __init__.py5000100% 
   operations.py8000100% 
   resources.py11000100% 
   schemas.py27000100% 
resources/team/domain
   __init__.py3000100% 
   operations.py11000100% 
   resources.py16000100% 
   schemas.py5550091%67, 69, 72, 75–76
resources/team/usage
   __init__.py3000100% 
   operations.py4000100% 
   resources.py4328292%99->102, 102, 162->165, 165
   schemas.py7076584%66->67, 67, 72–73, 76, 84–86
resources/workspace
   __init__.py5000100% 
   envVars.py4000100% 
   operations.py12000100% 
   resources.py1624280%13->14, 14, 19->20, 20
   schemas.py99146681%100–101, 103–109, 115–116, 118, 142, 161
resources/workspace/env_vars
   __init__.py3000100% 
   operations.py7000100% 
   resources.py26212484%33->35, 35–36, 38->exit
   schemas.py4000100% 
resources/workspace/git
   __init__.py3000100% 
   operations.py8000100% 
   resources.py15040100% 
   schemas.py4000100% 
resources/workspace/landscape
   __init__.py3000100% 
   operations.py12000100% 
   resources.py96736889%28->29, 29, 129->132, 135->138, 161->162, 162–163, 165->160, 168->169, 169, 173–175
   schemas.py2902910489%113–114, 117, 122–123, 126–127, 130, 135–137, 140–141, 144, 251, 258–259, 334–336, 338–340, 342–343, 458–459, 466–467
resources/workspace/logs
   __init__.py3000100% 
   operations.py5000100% 
   resources.py17550603763%66->68, 68, 97–98, 104, 106–108, 110, 113–114, 117, 120–121, 123–126, 128–129, 132–133, 135–136, 138–139, 141–143, 145–146, 148–152, 154–155, 157–159, 161–166, 179–180, 252–253
   schemas.py22000100% 
TOTAL14721232206989% 

Test Execution Summary

Tests Skipped Failures Errors Time
366 0 💤 0 ❌ 0 🔥 4.127s ⏱️

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