tests.test_gh moduleΒΆ
Tests for repomatic.github.gh.
- tests.test_gh.test_401_fallback_also_fails()ΒΆ
When fallback also fails, original 401 error is raised.
- tests.test_gh.test_401_no_fallback(env, clear)ΒΆ
401 does not retry when fallback is unavailable.
- tests.test_gh.test_401_requires_authentication_retries_with_github_token()ΒΆ
401 Requires authentication also triggers the GITHUB_TOKEN fallback.
Surfaces during GitHub auth incidents and from fine-grained PAT scope mismatches that GitHub treats as anonymous for the targeted resource.
- tests.test_gh.test_401_retries_with_github_token()ΒΆ
401 Bad credentials triggers retry with GITHUB_TOKEN.
- tests.test_gh.test_401_transient_clears_on_same_token_retry()ΒΆ
A 401 that clears on the same token resolves without falling back.
- tests.test_gh.test_401_transient_retry_disabled_when_schedule_empty()ΒΆ
An empty backoff schedule disables the retry loop entirely.
- tests.test_gh.test_401_transient_retry_exhausts_then_falls_back()ΒΆ
When every same-token retry returns 401, the cross-token fallback fires.
- tests.test_gh.test_api_headers_follows_token_precedence(env, expected_token)ΒΆ
Direct API calls authenticate with the same winner the gh CLI gets.
- tests.test_gh.test_api_headers_unauthenticated_without_token()ΒΆ
No token means no Authorization header, not an empty one.
- tests.test_gh.test_bad_credentials_raises_without_waiting()ΒΆ
A revoked token fails on the first call instead of paying the back-off.
Bad credentialsis deterministic: the same token cannot stop being revoked, so the same-token retry can only add idle seconds and flood the log with warnings that bury the real cause.
- tests.test_gh.test_bad_credentials_still_reaches_cross_token_fallback()ΒΆ
Skipping the same-token wait does not skip the second credential.
GITHUB_TOKENis issued by Actions itself, so it can succeed where a revoked PAT cannot: only the pointless wait is dropped, not the recovery.
- tests.test_gh.test_empty_repomatic_pat_ignored()ΒΆ
Empty REPOMATIC_PAT (unconfigured secret) is treated as absent.
- tests.test_gh.test_failure_message_includes_github_status_annotation()ΒΆ
A live githubstatus.com incident is appended to the raised RuntimeError.
- tests.test_gh.test_failure_message_omits_status_when_no_incident()ΒΆ
The healthy status annotation (empty string) leaves the error untouched.
- tests.test_gh.test_gh_executable_falls_back_to_path(failure, caplog)ΒΆ
A download failure degrades to
$PATHloudly, never stranding the job.
- tests.test_gh.test_gh_executable_prefers_the_pinned_registry_binary()ΒΆ
The pinned, checksum-verified
ghwins over whatever$PATHholds.
- tests.test_gh.test_gh_token_used_when_no_repomatic_pat()ΒΆ
Falls back to native GH_TOKEN when REPOMATIC_PAT is absent.
- tests.test_gh.test_github_token_promoted_to_gh_token()ΒΆ
GITHUB_TOKEN is promoted to GH_TOKEN when GH_TOKEN is absent.
- tests.test_gh.test_iter_graphql_nodes_follows_cursor()ΒΆ
Pagination follows
endCursoruntilhasNextPagegoes false.
- tests.test_gh.test_iter_graphql_nodes_max_nodes_shrinks_last_page()ΒΆ
The budget caps the yield count and shrinks the final page request.
- tests.test_gh.test_iter_graphql_nodes_missing_connection_yields_nothing()ΒΆ
A response missing the connection path yields nothing and stops.
- tests.test_gh.test_iter_graphql_nodes_single_page()ΒΆ
A single page yields its nodes and stops without a cursor request.
- tests.test_gh.test_iter_graphql_nodes_skips_null_nodes()ΒΆ
Null nodes (as the
searchconnection can emit) are dropped.
- tests.test_gh.test_iter_graphql_nodes_variable_flags()ΒΆ
String variables pass with
-f, ints and bools with-F.
- tests.test_gh.test_non_401_error_no_fallback()ΒΆ
Non-401 errors raise immediately without retry.
- tests.test_gh.test_non_401_skips_transient_retry()ΒΆ
Non-401 failures bypass the transient-retry loop and raise immediately.
- tests.test_gh.test_parse_create_output(output, kind, expected)ΒΆ
- tests.test_gh.test_parse_create_output_rejects_unparsable_output(output, kind)ΒΆ
- tests.test_gh.test_repomatic_pat_401_falls_back_to_github_token()ΒΆ
Expired REPOMATIC_PAT falls back to GITHUB_TOKEN.
- tests.test_gh.test_repomatic_pat_injected_as_gh_token()ΒΆ
REPOMATIC_PAT is passed to gh as GH_TOKEN.
- tests.test_gh.test_secondary_limit_clears_on_same_token_retry()ΒΆ
A throttled call that clears on the same token resolves without fallback.
- tests.test_gh.test_secondary_limit_retry_exhausts_then_raises()ΒΆ
An exhausted throttle schedule raises, without the cross-token fallback.
A throttled token is not a wrong one: swapping credentials against an abuse-detection refusal would only spread the burst across two identities, so the fallback stays scoped to auth markers.
- tests.test_gh.test_success_no_fallback()ΒΆ
Successful commands never trigger fallback.