• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mozilla / relman-auto-nag / #4164

pending completion
#4164

push

coveralls-python

suhaibmujahid
[multifix_regression] Handle cases where the merge have one tool only

549 of 3077 branches covered (17.84%)

5 of 5 new or added lines in 2 files covered. (100.0%)

1775 of 7954 relevant lines covered (22.32%)

0.22 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/auto_nag/scripts/multifix_regression.py
1
# This Source Code Form is subject to the terms of the Mozilla Public
2
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
3
# You can obtain one at http://mozilla.org/MPL/2.0/.
4

5
from collections import defaultdict
×
6

7
from auto_nag.multi_autofixers import (
×
8
    MultiAutoFixers,
9
    ToolsChanges,
10
    UnexpectedToolsError,
11
)
12
from auto_nag.scripts.needinfo_regression_author import NeedinfoRegressionAuthor
×
13
from auto_nag.scripts.regression_but_type_enhancement_task import (
×
14
    RegressionButEnhancementTask,
15
)
16
from auto_nag.scripts.regression_set_status_flags import RegressionSetStatusFlags
×
17

18

19
class MultiFixRegressed(MultiAutoFixers):
×
20
    """Merge changes from regression related tools and apply them to Bugzilla at once"""
21

22
    def __init__(self):
×
23
        super().__init__(
×
24
            RegressionButEnhancementTask(),
25
            RegressionSetStatusFlags(),
26
            NeedinfoRegressionAuthor(),
27
            comment=self.__merge_comment,
28
            keywords=self.__merge_keywords,
29
        )
30

31
    @staticmethod
×
32
    def __merge_comment(tools: ToolsChanges) -> dict:
×
33
        tools_to_merge = tools.keys() - {
×
34
            RegressionButEnhancementTask,  # we can ignore the comment from this tool
35
        }
36

37
        if len(tools_to_merge) == 1:
×
38
            return tools[next(iter(tools_to_merge))]["comment"]
×
39

40
        if tools_to_merge == {
×
41
            RegressionSetStatusFlags,
42
            NeedinfoRegressionAuthor,
43
        }:
44
            return {
×
45
                "body": "\n\n".join(
46
                    [
47
                        tools[RegressionSetStatusFlags]["comment"]["body"],
48
                        tools[NeedinfoRegressionAuthor]["comment"]["body"],
49
                    ]
50
                ),
51
            }
52

53
        raise UnexpectedToolsError(tools_to_merge)
×
54

55
    @staticmethod
×
56
    def __merge_keywords(tools: ToolsChanges) -> dict:
×
57
        merged_changes = defaultdict(set)
×
58
        for changes in tools.values():
×
59
            if "keywords" not in changes:
×
60
                continue
×
61

62
            for action, value in changes["keywords"].items():
×
63
                if isinstance(value, str):
×
64
                    value = [value]
×
65

66
                merged_changes[action].update(value)
×
67

68
        return {action: list(values) for action, values in merged_changes.items()}
×
69

70

71
if __name__ == "__main__":
×
72
    MultiFixRegressed().run()
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc