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, })
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'), })
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'), })
def test_aggregate_empty(self): c = Context({}) files = {"moz.build": Files(c, "**")} self.assertEqual( Files.aggregate(files), { "bug_component_counts": [], "recommended_bug_component": None, }, )
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"), }, )
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"), }, )
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'), })
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"), }, )
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'), })
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, })
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, }, )
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, })
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"), }, )
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, }, )
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})