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 credentials is 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_TOKEN is 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_command_error_defaults_its_stderr_to_the_message()ΒΆ

An error built from a message alone still reads its status off it.

tests.test_gh.test_failure_carries_the_http_status(stderr, status)ΒΆ

The raised error keeps what a caller branches on, parsed once.

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_api_pages_flattens_every_page(pages, key, expected)ΒΆ

Every page’s items come back as one list, in API order.

tests.test_gh.test_gh_api_pages_raises_when_gh_cannot_reach_the_endpoint()ΒΆ

A paginated read fails loudly: a missing page would corrupt the result.

tests.test_gh.test_gh_executable_falls_back_to_path(failure, caplog)ΒΆ

A download failure degrades to $PATH loudly, never stranding the job.

tests.test_gh.test_gh_executable_prefers_the_pinned_registry_binary()ΒΆ

The pinned, checksum-verified gh wins over whatever $PATH holds.

tests.test_gh.test_gh_graphql_partial_keeps_the_resolved_data()ΒΆ

With partial, the data printed beside the errors is the answer.

tests.test_gh.test_gh_graphql_passes_a_numeric_repository_name_as_a_string()ΒΆ

A repository named 2048 reaches a String! variable as a string.

tests.test_gh.test_gh_graphql_raises_without_usable_data(stdout, partial)ΒΆ

A failure with nothing to keep, or without partial, still raises.

tests.test_gh.test_gh_json_parses_the_output(soft)ΒΆ

A command printing JSON hands back the parsed value, soft or not.

tests.test_gh.test_gh_json_raises_unless_soft(patch_kwargs, error)ΒΆ

Both failure modes raise, and soft turns both into None.

tests.test_gh.test_gh_receives_the_winning_token(env, expected_token)ΒΆ

The resolve_gh_token() winner reaches gh as an explicit GH_TOKEN.

tests.test_gh.test_graphql_args_types_each_variable(value, flag)ΒΆ

--field would read 2048 as a number, so a string rides --raw-field.

tests.test_gh.test_iter_graphql_nodes_follows_cursor()ΒΆ

Pagination follows endCursor until hasNextPage goes false.

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_sends_the_page_size_on_every_request()ΒΆ

Each page asks for the same size, as a typed field.

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 search connection 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_run_gh_command_reports_a_gh_that_cannot_start()ΒΆ

A missing binary raises the error every caller of gh already handles.

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.