Chromium Code Reviews| Index: infra/tools/antibody/test/compute_stats_test.py |
| diff --git a/infra/tools/antibody/test/compute_stats_test.py b/infra/tools/antibody/test/compute_stats_test.py |
| index 71fef0a5194e227f216d869ad614f683eebe9e44..4a4398aeaf241353f6f8ddd4ed03cce72378dc80 100644 |
| --- a/infra/tools/antibody/test/compute_stats_test.py |
| +++ b/infra/tools/antibody/test/compute_stats_test.py |
| @@ -2,12 +2,45 @@ |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| +import datetime |
| import unittest |
| from infra.tools.antibody import compute_stats |
| +class Cursor(object): |
| + def execute(self, arg): |
| + pass |
| + |
| + def fetchall(self): |
| + results = (('https://codereview.chromium.org/1148323006', |
| + datetime.datetime(2015, 5, 28, 16, 8, 33), |
| + 'suppress-uninit-error-from-sessions-SessionBackend-' |
| + 'AppendCommandsToFile', |
| + 'bf1cf11bb721eb52bf46868cb831afd1f53567af'), |
| + ('https://codereview.chromium.org/1159593004', |
| + datetime.datetime(2015, 6, 1, 3, 37, 20), |
| + 'Revert-of-Converted-some-extension-browser-tests-into-using-' |
| + 'event-pages-patchset-1-id-60001-of-https-codereview.chromium.' |
| + 'org-1108133002', |
| + 'cda8c938f06f9955ac895099d05a9db3b61f3ab5'), |
| + ('https://codereview.chromium.org/1156073004', |
| + datetime.datetime(2015, 5, 26, 20, 52, 41), |
| + 'MemSheriff-Expand-suppressions-for-sqlite3-uninitialized-' |
| + 'reads', |
| + 'f48757cfe41e83e770095253b90775eb70f024b3'), |
| + ('https://codereview.chromium.org/1124083006', |
| + datetime.datetime(2015, 5, 20, 0, 26, 31), |
| + 'Revert-of-Temporarily-disable-a-webgl-conformance-test-on-' |
| + 'D3D9-only.-patchset-1-id-1-of-https-codereview.chromium.org-' |
| + '1135333004', |
| + '0b0b636093a7dbb56cc8712e2263b1c9a1ad8079')) |
| + return results |
| + |
| class TestComputeStats(unittest.TestCase): |
| + def setUp(self): |
| + self.cc = Cursor() |
| + |
| def test_ratio_calculator(self): |
| reg_num = [['2014-01', 1], ['2014-02', 3], ['2014-07', 5]] |
| reg_den = [['2014-07', 10], ['2014-02', 6], ['2014-01', 9]] |
| @@ -35,5 +68,92 @@ class TestComputeStats(unittest.TestCase): |
| def test_totaled_ratio_calculator(self): |
| ratio = compute_stats.totaled_ratio_calculator(3, 7) |
| self.assertEqual(ratio, 0.429) |
| - self.assertRaises(ZeroDivisionError, |
| - compute_stats.totaled_ratio_calculator, 5, 0) |
| + zero_ratio = compute_stats.totaled_ratio_calculator(5, 0) |
| + self.assertEqual(zero_ratio, 0) |
| + |
| + def test_totaled_tbr_no_lgtm(self): |
|
pgervais
2015/07/27 23:14:07
This method and the following two are basically th
|
| + sql_time_specification = 'DATEDIFF(git_commit.timestamp, NOW()) < 0' |
| + total_num, output = compute_stats.totaled_tbr_no_lgtm(self.cc, |
| + sql_time_specification) |
| + self.assertEqual(total_num, 4) |
| + self.assertEqual(output, |
| + [['https://codereview.chromium.org/1148323006', |
| + '2015-05-28 16:08:33', |
| + 'suppress-uninit-error-from-sessions-SessionBackend-' |
| + 'AppendCommandsToFile', |
| + 'bf1cf11bb721eb52bf46868cb831afd1f53567af'], |
| + ['https://codereview.chromium.org/1159593004', |
| + '2015-06-01 03:37:20', |
| + 'Revert-of-Converted-some-extension-browser-tests-into-using-' |
| + 'event-pages-patchset-1-id-60001-of-https-codereview.chromium.' |
| + 'org-1108133002', |
| + 'cda8c938f06f9955ac895099d05a9db3b61f3ab5'], |
| + ['https://codereview.chromium.org/1156073004', |
| + '2015-05-26 20:52:41', |
| + 'MemSheriff-Expand-suppressions-for-sqlite3-uninitialized-' |
| + 'reads', |
| + 'f48757cfe41e83e770095253b90775eb70f024b3'], |
| + ['https://codereview.chromium.org/1124083006', |
| + '2015-05-20 00:26:31', |
| + 'Revert-of-Temporarily-disable-a-webgl-conformance-test-on-' |
| + 'D3D9-only.-patchset-1-id-1-of-https-codereview.chromium.org-' |
| + '1135333004', |
| + '0b0b636093a7dbb56cc8712e2263b1c9a1ad8079']]) |
| + |
| + def test_totaled_blank_tbr(self): |
| + sql_time_specification = 'DATEDIFF(git_commit.timestamp, NOW()) < 0' |
| + total_num, output = compute_stats.totaled_blank_tbr(self.cc, |
| + sql_time_specification) |
| + self.assertEqual(total_num, 4) |
| + self.assertEqual(output, |
| + [['https://codereview.chromium.org/1148323006', |
| + '2015-05-28 16:08:33', |
| + 'suppress-uninit-error-from-sessions-SessionBackend-' |
| + 'AppendCommandsToFile', |
| + 'bf1cf11bb721eb52bf46868cb831afd1f53567af'], |
| + ['https://codereview.chromium.org/1159593004', |
| + '2015-06-01 03:37:20', |
| + 'Revert-of-Converted-some-extension-browser-tests-into-using-' |
| + 'event-pages-patchset-1-id-60001-of-https-codereview.chromium.' |
| + 'org-1108133002', |
| + 'cda8c938f06f9955ac895099d05a9db3b61f3ab5'], |
| + ['https://codereview.chromium.org/1156073004', |
| + '2015-05-26 20:52:41', |
| + 'MemSheriff-Expand-suppressions-for-sqlite3-uninitialized-' |
| + 'reads', |
| + 'f48757cfe41e83e770095253b90775eb70f024b3'], |
| + ['https://codereview.chromium.org/1124083006', |
| + '2015-05-20 00:26:31', |
| + 'Revert-of-Temporarily-disable-a-webgl-conformance-test-on-' |
| + 'D3D9-only.-patchset-1-id-1-of-https-codereview.chromium.org-' |
| + '1135333004', |
| + '0b0b636093a7dbb56cc8712e2263b1c9a1ad8079']]) |
| + |
| + def test_totaled_no_review_url(self): |
| + sql_time_specification = 'DATEDIFF(git_commit.timestamp, NOW()) < 0' |
| + total_num, output = compute_stats.totaled_no_review_url(self.cc, |
| + sql_time_specification) |
| + self.assertEqual(total_num, 4) |
| + self.assertEqual(output, |
| + [['https://codereview.chromium.org/1148323006', |
| + '2015-05-28 16:08:33', |
| + 'suppress-uninit-error-from-sessions-SessionBackend-' |
| + 'AppendCommandsToFile', |
| + 'bf1cf11bb721eb52bf46868cb831afd1f53567af'], |
| + ['https://codereview.chromium.org/1159593004', |
| + '2015-06-01 03:37:20', |
| + 'Revert-of-Converted-some-extension-browser-tests-into-using-' |
| + 'event-pages-patchset-1-id-60001-of-https-codereview.chromium.' |
| + 'org-1108133002', |
| + 'cda8c938f06f9955ac895099d05a9db3b61f3ab5'], |
| + ['https://codereview.chromium.org/1156073004', |
| + '2015-05-26 20:52:41', |
| + 'MemSheriff-Expand-suppressions-for-sqlite3-uninitialized-' |
| + 'reads', |
| + 'f48757cfe41e83e770095253b90775eb70f024b3'], |
| + ['https://codereview.chromium.org/1124083006', |
| + '2015-05-20 00:26:31', |
| + 'Revert-of-Temporarily-disable-a-webgl-conformance-test-on-' |
| + 'D3D9-only.-patchset-1-id-1-of-https-codereview.chromium.org-' |
| + '1135333004', |
| + '0b0b636093a7dbb56cc8712e2263b1c9a1ad8079']]) |