tests.test_strategy module¶
The
Strategyenum defines no member under a second name or value.
- tests.test_strategy.test_strategy_definition(strategy)[source]¶
Each strategy has a lowercase ID matching its name.
It runs a documented function named after one of the strategies.
- tests.test_strategy.test_maildir_dry_run(invoke, make_box, strategy_id, params)[source]¶
Check no mail is removed in dry-run mode.
- tests.test_strategy.test_maildir_strategy(invoke, make_box, strategy, mailbox_input, mailbox_results)[source]¶
Generic test to check the result of a selection strategy.
- tests.test_strategy.test_strategy_is_deterministic(make_box, config, strategy)[source]¶
Each strategy selects the same mails from the same set, at every pass.
A dry run must name the mails that the real run acts on, and a
--jobsworker must decide what the main process decides. Each pass loads the mails anew, as a worker does.
- tests.test_strategy.test_quantity_strategies_rule_on_the_first_path(invoke, make_box, strategy, kept_by_first, jobs)[source]¶
select-onekeeps the first copy by path, andselect-all-but-onedrops it.The order of the sources on the command line plays no part, and a
--jobsworker rules on the same copy.
- tests.test_strategy.undated_mail = <tests.conftest.MailFactory object>¶
A mail with an unparsable
Dateheader, from which no timestamp can be derived.
- tests.test_strategy.test_strategy_fallback_resolves_identical_copies(invoke, make_box)[source]¶
Time-based strategies cannot discriminate byte-identical copies.
The next strategy of the cascade takes over the sets they fail on.
See: https://github.com/kdeldycke/mail-deduplicate/issues/647
- tests.test_strategy.test_strategy_fallback_on_missing_timestamp(invoke, make_box)[source]¶
A set whose mails have no parseable timestamp goes to the next strategy.
The set is not skipped.
- tests.test_strategy.test_strategy_cascade_exhausted(invoke, make_box)[source]¶
A set failing every strategy of the cascade is skipped as a whole.
- tests.test_strategy.test_time_strategy_alone_cannot_split_same_timestamp_set(invoke, make_box)[source]¶
A time-based strategy that selects the whole set skips it, and deletes no mail.
This happens when every mail shares a timestamp, which discriminates nothing. A fallback strategy is the documented way to resolve such sets.
See: https://github.com/kdeldycke/mail-deduplicate/issues/270 and https://github.com/kdeldycke/mail-deduplicate/issues/647
- tests.test_strategy.test_strategy_cascade_dedup_aliases(invoke, make_box)[source]¶
Repeated strategies are collapsed into one, even under their aliases.
- tests.test_strategy.PATH_STRATEGIES = 'discard-matching-path, discard-non-matching-path, select-matching-path, select-non-matching-path'¶
The strategies taking a
--regexp, as the constraint errors list them.
- tests.test_strategy.test_strategy_cascade_regexp(invoke, make_box, args, messages)[source]¶
–regexp is required as soon as a path-based strategy is part of the cascade.
It is rejected when no strategy of the cascade makes use of it.
- tests.test_strategy.test_empty_regexp_counts_as_unset(invoke, make_box, strategy, exit_code)[source]¶
An empty
--regexpmatches every path, so it decides no set and is ignored.A path-based strategy then misses its expression. Any other strategy accepts it.
- tests.test_strategy.NO_PATH = '(?!)'¶
A regular expression that matches no path.
- tests.test_strategy.test_regexp_cascade(invoke, make_box, strategies, regexps, env, kept, handovers)[source]¶
Each
--regexpexpression is a step of the strategy cascade, in their order.The log line of each hand-over names the expression, and what the set goes to. The two boxes have random names, so an expression naming one of them matches no other part of a path.
- tests.test_strategy.outlier_mail = <tests.conftest.MailFactory object>¶
A mail whose body size and content exceed the default thresholds against the other fixtures.
- tests.test_strategy.test_outlier_eviction_keeps_core_dedup(invoke, make_box)[source]¶
An outlier mail no longer prevents the deduplication of the true copies.
The outlier exceeds the thresholds against its set.
See: https://github.com/kdeldycke/mail-deduplicate/issues/851
- tests.test_strategy.test_size_strategy_ignores_set_aside_mails(invoke, make_box, strategy, kept)[source]¶
A size-based strategy compares the mails left once the outlier is set aside.
The biggest size of the set is then the one of
smaller_mail, not the outlier’s.
- tests.test_strategy.test_set_aside_resets_cached_properties(make_box, config)[source]¶
Setting mails aside drops every property that a set cached on its pool.
Each property then describes the mails left, as on a set built from them alone.
- tests.test_strategy.test_dissimilar_pair_still_skipped(invoke, make_box)[source]¶
A set with no coherent core of at least 2 similar mails is skipped as a whole.
This is the behavior from before outlier eviction.
- tests.test_strategy.test_eviction_is_not_transitive(invoke, make_box)[source]¶
A chain of mails, each within threshold of the next, is not one group.
The mails are not all within threshold of each other. An endpoint is set aside, and the coherent remainder is deduplicated.
- tests.test_strategy.test_threshold_checks_disabled(invoke, make_box, extra_args, size_skip_logged, content_skip_logged)[source]¶
A threshold set to -1 turns off its similarity check, and logs that it did.
The identical pair deduplicates whatever the thresholds; the flags only govern whether the size and content guards run at all.
See: https://github.com/kdeldycke/mail-deduplicate/issues/97
- tests.test_strategy.test_no_strategy_skips_duplicate_sets(invoke, make_box)[source]¶
With no –strategy, duplicate sets are grouped and counted, then skipped whole.
Every mail stays in place.
- tests.test_strategy.DISSIMILAR_PAIR = (<tests.conftest.MailFactory object>, <tests.conftest.MailFactory object>)¶
Two mails sharing every hashed header, with bodies of the same length.
The equal lengths keep the size check quiet, so the content check is what trips.
- tests.test_strategy.test_show_diff_starts_from_the_lowest_path(invoke, make_box)[source]¶
The diff of two mails always runs from the one with the lowest path.
The pairs were walked in the order of a set, which changes from one run to the next, so two runs on the same box printed the same diff in either direction.
- tests.test_strategy.test_show_diff_is_colored_by_the_theme(invoke, make_box)[source]¶
Each line of the diff takes the theme slot its kind reads as.
This is how
git diffcolors its own.
- tests.test_strategy.test_content_difference_counts_bytes(config)[source]¶
The content difference of two mails is measured in bytes, not characters.
Two bodies of the same length in characters weigh more bytes when one holds non-ASCII characters, and the difference grows by that many bytes.
- tests.test_strategy.test_thresholds_read_no_body_the_hash_already_covers(config, monkeypatch, hash_body, reads)[source]¶
A set hashed on its decoded body is settled without a read.
Every mail of such a set shares the decoded body, from which the size and the diff both follow, so the checks have nothing to compare. A set hashed on headers alone, on its bytes, or on a body stripped of its whitespace still gets its bodies read and compared.
- tests.test_strategy.test_size_check_alone_reads_no_body(config, monkeypatch)[source]¶
With the content check off, the sizes the hashing step kept settle the set.
No body is read again to compare contents that nothing compares.
- tests.test_strategy.test_raw_hash_keeps_the_size_safeguard(invoke, tmp_path, hash_body)[source]¶
The size check still compares mails that share their body bytes.
The same bytes decode to different texts under different transfer encodings, and no hash header covers the encoding by default. Hashed on their headers alone, the control, or on their bytes, both copies land in one set, which their decoded sizes keep from being deduplicated.