tests.test_manager_overrides moduleΒΆ

Tests for the per-manager overrides of the [mpm.overrides.<id>] section.

tests.test_manager_overrides.reset_overrides()ΒΆ

Restore the override target’s instance state before and after each test.

The pool is a module-level singleton: any attribute we shadow on a manager instance via apply_manager_overrides() would leak to the next test. This fixture pops every overridable field and every cache-invalidated property from the instance __dict__, and clears the pool’s overridden-fields tracking dict so the next test starts from class defaults.

Cleanup runs both before (in case a prior test in the same xdist worker left the pool dirty) and after (to not pollute subsequent tests).

tests.test_manager_overrides.test_apply_raises_on_unknown_manager_so_no_hint_emitted()ΒΆ

Apply aborts on unknown manager IDs via the validator, so no hints leak.

The validator runs before any side effects, so the pool is unchanged.

tests.test_manager_overrides.test_apply_returns_hint_for_detection_field(reset_overrides)ΒΆ
tests.test_manager_overrides.test_apply_returns_hints_for_each_detection_field(reset_overrides)ΒΆ

Several detection-related overrides on one manager make one hint per field.

tests.test_manager_overrides.test_apply_returns_no_hint_for_preference_field(reset_overrides)ΒΆ

Overriding a preference field (timeout) generates no hint.

It is not a detection bug signal.

tests.test_manager_overrides.test_apply_returns_no_hint_when_overrides_empty()ΒΆ
tests.test_manager_overrides.test_build_issue_url_asserts_on_oversize_url()ΒΆ

A pathological override value trips the URL-length assertion.

It never produces a URL that GitHub would truncate.

tests.test_manager_overrides.test_build_issue_url_fills_fields_of_the_form()ΒΆ

Each field the URL fills is a field of the bug report form.

GitHub ignores a query key that names no field id, so a renamed field would leave the report empty with no error.

tests.test_manager_overrides.test_build_issue_url_includes_detected_cli_path_when_available()ΒΆ
tests.test_manager_overrides.test_build_issue_url_targets_bug_template()ΒΆ
tests.test_manager_overrides.test_build_issue_url_url_decodes_back_to_useful_body()ΒΆ

The URL-encoded body decodes back to text naming the override.

Round-trip: it mentions the manager id, the field, and the user’s value.

tests.test_manager_overrides.test_cached_property_evicted_on_override(reset_overrides)ΒΆ

Force a cached_property to be computed, then verify the override evicts it.

tests.test_manager_overrides.test_cli_config_template_multiple_managers(invoke)ΒΆ

mpm config-template <id1> <id2> dumps each requested manager.

tests.test_manager_overrides.test_cli_config_template_no_args_dumps_all_maintained(invoke)ΒΆ

With no positional args, every maintained manager appears.

tests.test_manager_overrides.test_cli_config_template_one_manager(invoke)ΒΆ

mpm config-template <id> produces a single parseable manager section.

tests.test_manager_overrides.test_cli_config_template_output_is_applicable(invoke, reset_overrides)ΒΆ

A config-template output fed back through the overrides is a no-op.

End-to-end: pipe mpm config-template <id> output back through apply_manager_overrides and confirm the pool is unchanged.

tests.test_manager_overrides.test_cli_config_template_unknown_manager_errors(invoke)ΒΆ
tests.test_manager_overrides.test_cli_contribution_hint(invoke, create_config, reset_overrides, config, args, hinted)ΒΆ

The configuration decides whether the contribution hint is printed.

End to end: the hint and the issue link it carries reach <stderr> or not.

tests.test_manager_overrides.test_cli_cooldown_override_gives_keyword_an_effect(invoke, create_config, reset_overrides)ΒΆ

A posture keyword has an effect while one manager pins its own window.

With no window anywhere, test_cli_cooldown_keyword_without_window_is_a_noop gets the no effect note instead.

tests.test_manager_overrides.test_cli_fails_on_unknown_manager_in_config(invoke, create_config)ΒΆ

A typo’d manager ID in the config aborts the CLI with a precise dotted path.

Permissive warn-and-skip behavior was removed: the same validator that powers --validate-config runs at normal load time.

tests.test_manager_overrides.test_cli_ignore_auto_updates_warns(invoke)ΒΆ

The removed flag that asked for the default only warns.

tests.test_manager_overrides.test_cli_include_auto_updates_names_replacement(invoke)ΒΆ

The removed flag for auto-updating casks stops the run.

It names the configuration that replaces it.

tests.test_manager_overrides.test_cli_loads_manager_overrides(invoke, create_config, reset_overrides)ΒΆ

End-to-end: mpm --config <path> applies [mpm.overrides.<id>] overrides.

tests.test_manager_overrides.test_cli_managers_suggests_an_override_for_an_unread_version(invoke, create_config, reset_overrides, tmp_path)ΒΆ

A named manager whose version no pattern reads gets the override to test.

The overrides point pip at a fake binary printing mytool 1.2.3, which the pattern misses: the hint under the table quotes that output beside the current patterns.

tests.test_manager_overrides.test_cli_removed_auto_updates_key_warns(invoke, create_config, value, hint)ΒΆ

click-extra drops the removed [mpm] key in silence, so mpm warns.

tests.test_manager_overrides.test_cli_warns_on_risky_override_from_untrusted_file(invoke, create_config, reset_overrides)ΒΆ

The CLI warns about a risky override read from a file others can write to.

tests.test_manager_overrides.test_cli_warns_on_stale_overrides_section(invoke, create_config, reset_overrides)ΒΆ

A table under [mpm.managers] is named in a warning and not applied.

That was the old home of the overrides. The table is not dropped in silence.

tests.test_manager_overrides.test_config_template_round_trips(manager_id)ΒΆ

For every manager, dump β†’ tomli_w β†’ tomllib β†’ converter yields the same value.

Catches schema drift between OVERRIDABLE_FIELDS converters and the live attribute types.

tests.test_manager_overrides.test_contribution_hint_fields_subset_of_overridable()ΒΆ

The hint allowlist must only name real overridable fields.

tests.test_manager_overrides.test_cooldown_override_beats_run_window(reset_overrides, run_window, run_policy, injects)ΒΆ

A per-manager cooldown survives the window of the run.

_select_managers sets the window that --cooldown and [mpm.cooldown] resolve on each manager it selects, except on a manager whose override pins its own.

tests.test_manager_overrides.test_dict_override(reset_overrides)ΒΆ
tests.test_manager_overrides.test_dict_override_adds_to_shipped_variables()ΒΆ

An extra_env override adds its variables to those the manager ships.

Its value wins for a name both set. Each application starts again from the shipped variables, so a name a later configuration drops is gone.

tests.test_manager_overrides.test_dump_manager_overrides_converts_tuples_to_lists()ΒΆ

Tuples are converted to lists so tomli_w can serialize them.

tests.test_manager_overrides.test_dump_manager_overrides_keys_are_alphabetical()ΒΆ

The output is canonical: dict insertion order matches sorted field names.

tests.test_manager_overrides.test_dump_manager_overrides_lists_buildable_operations(reset_overrides)ΒΆ

The template names each operation an override can reach.

Each operation shows its current extra_args.

tests.test_manager_overrides.test_dump_manager_overrides_skips_none_values()ΒΆ

Attributes whose current value is None are omitted from the dump.

tests.test_manager_overrides.test_dump_manager_overrides_spells_cooldown_window(reset_overrides)ΒΆ

The template spells a pinned window as a duration string, which TOML holds.

tests.test_manager_overrides.test_empty_section_is_noop(reset_overrides, section)ΒΆ

An absent or empty [mpm.overrides] section applies and validates as a no-op.

tests.test_manager_overrides.test_format_contribution_hints_cautions_an_agent(monkeypatch, agent)ΒΆ

An AI agent is told to ask its user before it files the report.

tests.test_manager_overrides.test_format_contribution_hints_empty_returns_empty_string()ΒΆ
tests.test_manager_overrides.test_format_contribution_hints_lists_each_with_url()ΒΆ
tests.test_manager_overrides.test_global_default_still_applies_without_override()ΒΆ

Sanity: with no per-manager override, the global default reaches the manager.

tests.test_manager_overrides.test_multiple_fields_in_one_call(reset_overrides)ΒΆ
tests.test_manager_overrides.test_non_dict_manager_section_raises()ΒΆ
tests.test_manager_overrides.test_non_dict_top_level_raises()ΒΆ
tests.test_manager_overrides.test_operations_override_reaches_its_command_alone(reset_overrides)ΒΆ

Operation arguments reach the commands of their operation alone.

The override, the stamp of the operation method and build_cli put them there, and nowhere else.

tests.test_manager_overrides.test_operations_override_rejects(reset_overrides, operations, message)ΒΆ
tests.test_manager_overrides.test_operations_override_sets_extra_args(reset_overrides)ΒΆ
tests.test_manager_overrides.test_overridable_fields_match_base_attributes()ΒΆ

Every overridable field must exist on the PackageManager base class.

Drift between OVERRIDABLE_FIELDS and the base class is silent at runtime (setattr happily creates new attributes) so this test acts as the safety net.

tests.test_manager_overrides.test_override_applies(reset_overrides, field, value, expected)ΒΆ

An override of the right type sets the field on the manager.

The value takes the type the field holds.

tests.test_manager_overrides.test_override_experiment_guides_an_agent(monkeypatch)ΒΆ

An AI agent is told to test in a scratch file and show the user the result.

tests.test_manager_overrides.test_override_experiment_names_the_field_to_test(manager_class, state, expected, monkeypatch)ΒΆ

Each cause gets the table of the field that controls it.

tests.test_manager_overrides.test_override_experiment_quotes_the_head_of_a_long_output(monkeypatch)ΒΆ

Only the first lines are quoted: dnf5 lists every plugin after its version.

tests.test_manager_overrides.test_override_experiment_stays_silent_when_no_override_helps(manager_class, state)ΒΆ
tests.test_manager_overrides.test_override_rejects(reset_overrides, field, value, message)ΒΆ

An unknown field or a value of the wrong type stops the override.

The error names what the field accepts.

tests.test_manager_overrides.test_overrides_section_names_a_schema_field()ΒΆ

OVERRIDES_SECTION and the schema field declaring it opaque agree.

click-extra derives a configuration path from the field name, so renaming one side alone leaves every reader of the constant looking at a sub-tree the schema no longer marks opaque, which the strict check then rejects key by key.

tests.test_manager_overrides.test_per_manager_override_beats_global_default(reset_overrides, field, override, global_value)ΒΆ

A per-manager override survives the global setattr loop.

That loop runs in _select_managers, and the most specific value wins.

tests.test_manager_overrides.test_removed_auto_updates_field_names_replacement(reset_overrides)ΒΆ
tests.test_manager_overrides.test_risky_override_from_untrusted_source_warns(monkeypatch, caplog, source, is_url, trusted, origin)ΒΆ

One warning per shipped manager whose override sets a risky field.

Only a configuration from a remote URL or an unsafe file triggers them.

The source and its trust are stubbed, so the test reads the same on every platform. An unknown ID and a section that is not a table carry no field to warn about.

tests.test_manager_overrides.test_str_tuple_override_coerces_list_to_tuple(reset_overrides)ΒΆ
tests.test_manager_overrides.test_str_tuple_override_replaces_default(reset_overrides)ΒΆ
tests.test_manager_overrides.test_sudo_is_a_risky_override_field()ΒΆ

An untrusted sudo = true override trips the untrusted-source warning.

[mpm.overrides.<id>] sudo = true from an untrusted source can run a binary as root, like pre_cmds.

tests.test_manager_overrides.test_timeout_binds_detection_phase(reset_overrides, monkeypatch, override, expected)ΒΆ

_select_managers binds the probes to the resolved timeout first.

The version-detection probes are bound before warm_availability runs them: the global --timeout reaches a plain candidate, while a per-manager override still keeps precedence.

tests.test_manager_overrides.test_unknown_manager_raises()ΒΆ
tests.test_manager_overrides.test_unknown_manager_with_override_operations_reads_as_typo()ΒΆ

A section whose operations only add arguments is a mistyped override.

It is not a definition missing its platforms.