def test_get_rates_by_task(self): th = utl.TestHistory("test1.js") th.add_reliable_period_stats([ { "test_file": "test1.js", "task_name": "task1", "variant": "v1", "distro": "d1", "num_pass": 1, "num_fail": 0 }, { "test_file": "test1.js", "task_name": "task1", "variant": "v1", "distro": "d2", "num_pass": 0, "num_fail": 1 }, { "test_file": "test1.js", "task_name": "task2", "variant": "v2", "distro": "d3", "num_pass": 2, "num_fail": 1 }, { "test_file": "test1.js", "task_name": "task2", "variant": "v2", "distro": "d4", "num_pass": 1, "num_fail": 0 }, ]) expected = [ (utl.TestCombination("test1.js", "task1", None, None), 0.5, 2), (utl.TestCombination("test1.js", "task2", None, None), 0.25, 4), ] rates = th.get_reliable_period_rates(group_by=utl.TestCombination.GROUP_BY_TASK) self.assertListEqual(expected, rates)
def test_get_rates_by_distro(self): th = utl.TestHistory("test1.js") th.add_reliable_period_stats([ { "test_file": "test1.js", "task_name": "task1", "variant": "v", "distro": "d1", "num_pass": 1, "num_fail": 0 }, { "test_file": "test1.js", "task_name": "task1", "variant": "v", "distro": "d1", "num_pass": 0, "num_fail": 1 }, { "test_file": "test1.js", "task_name": "task1", "variant": "v", "distro": "d2", "num_pass": 0, "num_fail": 1 }, { "test_file": "test1.js", "task_name": "task2", "variant": "v", "distro": "d2", "num_pass": 1, "num_fail": 0 }, ]) expected = [ (utl.TestCombination("test1.js", "task1", "v", "d1"), 0.5, 2), (utl.TestCombination("test1.js", "task1", "v", "d2"), 1.0, 1), (utl.TestCombination("test1.js", "task2", "v", "d2"), 0.0, 1), ] rates = th.get_reliable_period_rates(group_by=utl.TestCombination.GROUP_BY_DISTRO) self.assertListEqual(expected, rates)
def test_equal(self): args = ["test1", "task1", "variant1", "distro1"] while args: t1 = utl.TestCombination(*args) t2 = utl.TestCombination(*args) self.assertTrue(t1 == t2) self.assertTrue(t2 == t1) args.pop()
def test_from_tag(self): test = "testA" combination = utl.TestCombination.from_tag(test, "unreliable") self.assertEqual(combination, utl.TestCombination(test, None, None, None)) combination = utl.TestCombination.from_tag(test, "unreliable|taskA") self.assertEqual(combination, utl.TestCombination(test, "taskA", None, None)) combination = utl.TestCombination.from_tag(test, "unreliable|taskA|variantA") self.assertEqual(combination, utl.TestCombination(test, "taskA", "variantA", None)) combination = utl.TestCombination.from_tag(test, "unreliable|taskA|variantA|distroA") self.assertEqual(combination, utl.TestCombination(test, "taskA", "variantA", "distroA"))
def test_equal_group_by(self): args = ["test1", "task1", "variant1", "distro1"] # yapf: disable group_by = [ utl.TestCombination.GROUP_BY_TEST, utl.TestCombination.GROUP_BY_TASK, utl.TestCombination.GROUP_BY_VARIANT, utl.TestCombination.GROUP_BY_DISTRO ] # yapf: enable while args: t1 = utl.TestCombination(*args) t2 = utl.TestCombination(*args) self.assertTrue(t1 == t2) self.assertTrue(t2 == t1) self.assertEqual(group_by.pop(), t1.group_by) args.pop()
def test_tag(self): args = ["test1", "task1", "variant1", "distro1"] tags = [ "unreliable", "unreliable|task1", "unreliable|task1|variant1", "unreliable|task1|variant1|distro1", ] while args: t = utl.TestCombination(*args) self.assertEqual(tags.pop(), t.tag) args.pop()
def test_properties(self): t = utl.TestCombination("test1", "task1", "variant1", "distro1") self.assertEqual("test1", t.test) self.assertEqual("task1", t.task) self.assertEqual("variant1", t.variant) self.assertEqual("distro1", t.distro)