tests.test_labels module¶
Tests for the label rules in repomatic.github.labels.
A rule is one label mapped to a list of patterns: keywords or regexes over a thread’s text, globs over a pull request’s changed paths. These tests pin the resolution semantics (project entries overlay the bundled defaults per label), the pattern compiler, and the two matchers.
- tests.test_labels.test_defaults_resolve_without_a_config(resolver)[source]¶
The bundled defaults stand alone: no project config needed to match.
- tests.test_labels.test_project_entries_overlay_the_defaults(resolver, field, defaults, default_label)[source]¶
A new label adds; a default label’s entry is replaced, not merged.
- tests.test_labels.test_empty_list_disables_a_default_label()[source]¶
"🐛 bug" = []is the off switch for a bundled rule.
- tests.test_labels.test_bare_string_is_a_single_pattern()[source]¶
"🥭 mango" = "mango"reads as the one-element list it means.
- tests.test_labels.test_rules_that_are_not_a_table_degrade_to_defaults(caplog)[source]¶
A list where a table belongs is reported, then ignored.
The config loader passes a mistyped value through rather than crashing, so every repomatic command keeps working and falls back to the bundled defaults.
- tests.test_labels.test_unusable_entries_are_skipped_loudly(caplog, overrides, warning)[source]¶
A malformed entry is dropped with a warning, never a crash.
- tests.test_labels.test_content_pattern_forms(pattern, text, expected)[source]¶
Both the keyword and
/body/flagsspellings behave as documented.
- tests.test_labels.test_malformed_pattern_is_skipped_not_fatal(caplog)[source]¶
One bad regex must not take the whole labelling run with it.
- tests.test_labels.test_content_patterns_are_or_joined()[source]¶
Any one pattern matching applies the label: a keyword list just works.
- tests.test_labels.test_file_globs(patterns, files, expected)[source]¶
The glob dialect stays
minimatch’s, evaluated as one set per label.
- tests.test_labels.test_default_rule_labels_exist_in_the_label_registry()[source]¶
Every label the package hard-codes names one
labels.tomldefines.Applying an unknown label fails the
ghcall outright, so a rule keyed on a label the registry dropped or renamed is not a dead rule but a broken one. The sponsor-label command’s default rides the same registry and gets the same check. So doDEPENDENCY_LABEL, applied to every dependency-update PR, the labels of the broken links issue, and the label of every issue repomatic maintains.
- tests.test_labels.test_default_content_rules_match_as_advertised(text, expected)[source]¶
The shipped keyword lists fire on their keyword and nothing else.
- tests.test_labels.BUNDLED_ISSUE_FORMS = ('awesome_template/.github/ISSUE_TEMPLATE/new-link.yaml',)¶
Every issue form repomatic bundles, so a keyword in one pre-labels them all.
- tests.test_labels.test_a_bundled_issue_form_pre_labels_nothing(form_path)[source]¶
A form’s own boilerplate must not label every submission filed through it.
.githubamong the🤖 cicontent rules matched the.github/...URLs this form embeds in its self-check boxes, so all four awesome lists labelled every new-link issue as CI. Read from the bundle rather than a copied string, so a keyword a later form edit introduces fails here.
- tests.test_labels.test_default_file_rules_match_as_advertised(files, expected)[source]¶
The shipped globs cover the paths they name, and no others.
- tests.test_labels.test_label_keys_survive_config_loading()[source]¶
Emoji, spaces, colons and hyphens in label keys reach the rules intact.
The loader normalizes configuration keys (
content-rules→content_rules), and a label like📦 manager: apt-cygmust not be dragged through the same rewrite: mapping-typed fields are opaque to the normalization, which this pins.
- tests.test_labels.test_apply_labels_dry_run_on_an_issue(tmp_path)[source]¶
An issue event matches content rules only, and dry-run writes nothing.
- tests.test_labels.test_apply_labels_live_on_a_pull_request(tmp_path)[source]¶
A PR event adds the file-rule matches and writes the labels once.
- tests.test_labels.test_apply_labels_reads_another_thread_from_the_api(tmp_path)[source]¶
A thread the event does not carry has its text read from the API.
- tests.test_labels.test_serialize_inline_labels_empty()[source]¶
An empty input yields an empty string so the caller can skip labelmaker.
- tests.test_labels.test_serialize_inline_labels_all_invalid_returns_empty(caplog)[source]¶
If every entry is nameless, the result is empty and warnings are logged.
- tests.test_labels.test_serialize_inline_labels_round_trip()[source]¶
Output parses back to the expected labelmaker structure.
- tests.test_labels.test_serialize_inline_labels_strips_leading_hash_on_color()[source]¶
Hex colors with a leading
#are normalized to bare hex.
- tests.test_labels.test_serialize_inline_labels_omits_missing_optional_fields()[source]¶
Missing
coloranddescriptionare omitted, not emitted as empty strings.
- tests.test_labels.test_serialize_inline_labels_passes_through_labelmaker_fields()[source]¶
Every per-label labelmaker field rides through, booleans included.
- tests.test_labels.test_serialize_inline_labels_strips_hash_on_multi_color()[source]¶
Multi-color lists are normalized to bare hex like single colors.
- tests.test_labels.test_serialize_inline_labels_omits_empty_values()[source]¶
Empty strings and empty lists are omitted, not emitted as blanks.
- tests.test_labels.test_serialize_inline_labels_warns_on_unknown_fields(caplog)[source]¶
Unknown fields are dropped with a warning instead of aborting the sync.
- tests.test_labels.test_serialize_inline_labels_skips_blank_name(caplog)[source]¶
A whitespace-only name is treated as missing.
- tests.test_labels.test_serialize_inline_labels_escapes_special_characters(name, description)[source]¶
Special characters survive serialization and re-parsing.
- tests.test_labels.captured_labelmaker(monkeypatch)[source]¶
Record every labelmaker invocation, with the staged file’s content.
- tests.test_labels.test_apply_labels_applies_the_bundled_default_profile(tmp_path, monkeypatch, captured_labelmaker)[source]¶
The bundled definitions go first, under the
defaultprofile alone.
- tests.test_labels.test_apply_labels_applies_the_awesome_profile(tmp_path, monkeypatch, captured_labelmaker)[source]¶
An awesome list gets the
awesomeprofile on top ofdefault.
- tests.test_labels.test_sync_labels_reads_an_awesome_list_from_its_name(tmp_path, monkeypatch, captured_labelmaker)[source]¶
sync-labelsadds theawesomeprofile for anawesome-*repository.
- tests.test_labels.test_sync_labels_fails_on_a_labelmaker_failure(tmp_path, monkeypatch)[source]¶
A labelmaker run that fails ends the command with labelmaker’s message.
- tests.test_labels.test_run_labelmaker_passes_the_promoted_token(caplog, stdout, logged)[source]¶
labelmaker runs with the
ghenvironment, its output kept for the debug log.
- tests.test_labels.test_run_labelmaker_raises_with_its_error_output()[source]¶
A failed run raises with what labelmaker printed on its error stream.
- tests.test_labels.test_apply_labels_stages_outside_the_working_tree(tmp_path, monkeypatch, captured_labelmaker)[source]¶
Every file labelmaker reads sits in a scratch directory, never the tree.
- tests.test_labels.test_apply_labels_applies_committed_extra_labels(tmp_path, monkeypatch, captured_labelmaker)[source]¶
A hand-written
extra-labels/file is applied without a profile.
- tests.test_labels.test_download_shadows_committed_file_of_same_name(tmp_path)[source]¶
A
labels.extra-filesdownload wins over a committed file of that name.