Ejemplo n.º 1
0
    def test_aggregate_empty(self):
        c = Context({})

        files = {'moz.build': Files(c, '**')}

        self.assertEqual(Files.aggregate(files), {
            'bug_component_counts': [],
            'recommended_bug_component': None,
        })
Ejemplo n.º 2
0
    def test_single_bug_component(self):
        c = Context({})
        f = Files(c, '**')
        f['BUG_COMPONENT'] = (u'Product1', u'Component1')

        files = {'moz.build': f}
        self.assertEqual(Files.aggregate(files), {
            'bug_component_counts': [((u'Product1', u'Component1'), 1)],
            'recommended_bug_component': (u'Product1', u'Component1'),
        })
Ejemplo n.º 3
0
    def test_aggregate_empty(self):
        c = Context({})

        files = {"moz.build": Files(c, "**")}

        self.assertEqual(
            Files.aggregate(files),
            {
                "bug_component_counts": [],
                "recommended_bug_component": None,
            },
        )
Ejemplo n.º 4
0
    def test_single_bug_component(self):
        c = Context({})
        f = Files(c, "**")
        f["BUG_COMPONENT"] = ("Product1", "Component1")

        files = {"moz.build": f}
        self.assertEqual(
            Files.aggregate(files),
            {
                "bug_component_counts": [(("Product1", "Component1"), 1)],
                "recommended_bug_component": ("Product1", "Component1"),
            },
        )
Ejemplo n.º 5
0
    def test_multiple_patterns(self):
        c = Context({})
        f1 = Files(c, 'a/**')
        f1['BUG_COMPONENT'] = (u'Product1', u'Component1')
        f2 = Files(c, 'b/**', 'a/bar')
        f2['BUG_COMPONENT'] = (u'Product2', u'Component2')

        files = {'a/foo': f1, 'a/bar': f2, 'b/foo': f2}
        self.assertEqual(Files.aggregate(files), {
            'bug_component_counts': [
                ((u'Product2', u'Component2'), 2),
                ((u'Product1', u'Component1'), 1),
            ],
            'recommended_bug_component': (u'Product2', u'Component2'),
        })
Ejemplo n.º 6
0
    def test_no_recommended_bug_component(self):
        """If there is no clear count winner, we don't recommend a bug component."""
        c = Context({})
        f1 = Files(c, '**')
        f1['BUG_COMPONENT'] = (u'Product1', u'Component1')

        f2 = Files(c, '**')
        f2['BUG_COMPONENT'] = (u'Product2', u'Component2')

        files = {'a': f1, 'b': f2}
        self.assertEqual(Files.aggregate(files), {
            'bug_component_counts': [
                ((u'Product1', u'Component1'), 1),
                ((u'Product2', u'Component2'), 1),
            ],
            'recommended_bug_component': None,
        })
Ejemplo n.º 7
0
    def test_aggregate_empty(self):
        c = Context({})

        files = {'moz.build': Files(c, pattern='**')}

        self.assertEqual(Files.aggregate(files), {
            'bug_component_counts': [],
            'recommended_bug_component': None,
        })
Ejemplo n.º 8
0
    def test_multiple_patterns(self):
        c = Context({})
        f1 = Files(c, "a/**")
        f1["BUG_COMPONENT"] = ("Product1", "Component1")
        f2 = Files(c, "b/**", "a/bar")
        f2["BUG_COMPONENT"] = ("Product2", "Component2")

        files = {"a/foo": f1, "a/bar": f2, "b/foo": f2}
        self.assertEqual(
            Files.aggregate(files),
            {
                "bug_component_counts": [
                    (("Product2", "Component2"), 2),
                    (("Product1", "Component1"), 1),
                ],
                "recommended_bug_component": ("Product2", "Component2"),
            },
        )
Ejemplo n.º 9
0
    def test_single_bug_component(self):
        c = Context({})
        f = Files(c, pattern='**')
        f['BUG_COMPONENT'] = (u'Product1', u'Component1')

        files = {'moz.build': f}
        self.assertEqual(Files.aggregate(files), {
            'bug_component_counts': [((u'Product1', u'Component1'), 1)],
            'recommended_bug_component': (u'Product1', u'Component1'),
        })
Ejemplo n.º 10
0
    def test_no_recommended_bug_component(self):
        """If there is no clear count winner, we don't recommend a bug component."""
        c = Context({})
        f1 = Files(c, "**")
        f1["BUG_COMPONENT"] = ("Product1", "Component1")

        f2 = Files(c, "**")
        f2["BUG_COMPONENT"] = ("Product2", "Component2")

        files = {"a": f1, "b": f2}
        self.assertEqual(
            Files.aggregate(files),
            {
                "bug_component_counts": [
                    (("Product1", "Component1"), 1),
                    (("Product2", "Component2"), 1),
                ],
                "recommended_bug_component":
                None,
            },
        )
Ejemplo n.º 11
0
    def test_single_bug_component(self):
        c = Context({})
        f = Files(c, pattern="**")
        f["BUG_COMPONENT"] = (u"Product1", u"Component1")

        files = {"moz.build": f}
        self.assertEqual(
            Files.aggregate(files),
            {
                "bug_component_counts": [((u"Product1", u"Component1"), 1)],
                "recommended_bug_component": (u"Product1", u"Component1"),
            },
        )
Ejemplo n.º 12
0
    def test_multiple_bug_components(self):
        c = Context({})
        f1 = Files(c, pattern="**")
        f1["BUG_COMPONENT"] = (u"Product1", u"Component1")

        f2 = Files(c, pattern="**")
        f2["BUG_COMPONENT"] = (u"Product2", u"Component2")

        files = {"a": f1, "b": f2, "c": f1}
        self.assertEqual(
            Files.aggregate(files),
            {
                "bug_component_counts": [((u"Product1", u"Component1"), 2), ((u"Product2", u"Component2"), 1)],
                "recommended_bug_component": (u"Product1", u"Component1"),
            },
        )
Ejemplo n.º 13
0
    def test_multiple_bug_components(self):
        c = Context({})
        f1 = Files(c, pattern='**')
        f1['BUG_COMPONENT'] = (u'Product1', u'Component1')

        f2 = Files(c, pattern='**')
        f2['BUG_COMPONENT'] = (u'Product2', u'Component2')

        files = {'a': f1, 'b': f2, 'c': f1}
        self.assertEqual(Files.aggregate(files), {
            'bug_component_counts': [
                ((u'Product1', u'Component1'), 2),
                ((u'Product2', u'Component2'), 1),
            ],
            'recommended_bug_component': (u'Product1', u'Component1'),
        })
Ejemplo n.º 14
0
    def test_no_recommended_bug_component(self):
        """If there is no clear count winner, we don't recommend a bug component."""
        c = Context({})
        f1 = Files(c, pattern="**")
        f1["BUG_COMPONENT"] = (u"Product1", u"Component1")

        f2 = Files(c, pattern="**")
        f2["BUG_COMPONENT"] = (u"Product2", u"Component2")

        files = {"a": f1, "b": f2}
        self.assertEqual(
            Files.aggregate(files),
            {
                "bug_component_counts": [((u"Product1", u"Component1"), 1), ((u"Product2", u"Component2"), 1)],
                "recommended_bug_component": None,
            },
        )
Ejemplo n.º 15
0
    def test_no_recommended_bug_component(self):
        """If there is no clear count winner, we don't recommend a bug component."""
        c = Context({})
        f1 = Files(c, pattern='**')
        f1['BUG_COMPONENT'] = (u'Product1', u'Component1')

        f2 = Files(c, pattern='**')
        f2['BUG_COMPONENT'] = (u'Product2', u'Component2')

        files = {'a': f1, 'b': f2}
        self.assertEqual(Files.aggregate(files), {
            'bug_component_counts': [
                ((u'Product1', u'Component1'), 1),
                ((u'Product2', u'Component2'), 1),
            ],
            'recommended_bug_component': None,
        })
Ejemplo n.º 16
0
    def test_aggregate_empty(self):
        c = Context({})

        files = {"moz.build": Files(c, pattern="**")}

        self.assertEqual(Files.aggregate(files), {"bug_component_counts": [], "recommended_bug_component": None})