Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Side by Side Diff: infra/tools/antibody/test/compute_stats_test.py

Issue 1235373004: Added script to generate stats on a git checkout (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@new_antibody_db_schema
Patch Set: Rebase Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import unittest
6
7 from infra.tools.antibody import compute_stats
8
9
10 class TestComputeStats(unittest.TestCase):
11 def test_ratio_calculator(self):
12 reg_num = [['2014-01', 1], ['2014-02', 3], ['2014-07', 5]]
13 reg_den = [['2014-07', 10], ['2014-02', 6], ['2014-01', 9]]
14 reg_ratio = compute_stats.ratio_calculator(reg_num, reg_den)
15 self.assertEqual(reg_ratio,
16 [['2014-01', 0.111], ['2014-02', 0.5], ['2014-07', 0.5]])
17
18 zero_num = [['2014-01', 1], ['2014-02', 0], ['2014-07', 5]]
19 zero_den = [['2014-07', 10], ['2014-02', 0], ['2014-01', 0]]
20 zero_ratio = compute_stats.ratio_calculator(zero_num, zero_den)
21 self.assertEqual(zero_ratio,
22 [['2014-01', 0], ['2014-02', 0], ['2014-07', 0.5]])
23
24 missing_num = [['2014-01', 1], ['2014-02', 3], ['2014-07', 5]]
25 missing_den = [['2014-02', 3], ['2014-07', 10]]
26 missing_ratio = compute_stats.ratio_calculator(missing_num, missing_den)
27 self.assertEqual(missing_ratio,
28 [['2014-02', 1.0], ['2014-07', 0.5]])
29
30 extra_num = [['2014-01', 1], ['2014-02', 3], ['2014-07', 5]]
31 extra_den = [['2014-02', 3], ['2015-07', 5], ['2015-07', 5]]
32 extra_ratio = compute_stats.ratio_calculator(extra_num, extra_den)
33 self.assertEqual(extra_ratio, [['2014-02', 1.0]])
34
35 def test_totaled_ratio_calculator(self):
36 ratio = compute_stats.totaled_ratio_calculator(3, 7)
37 self.assertEqual(ratio, 0.429)
38 self.assertRaises(ZeroDivisionError,
39 compute_stats.totaled_ratio_calculator, 5, 0)
OLDNEW
« no previous file with comments | « infra/tools/antibody/test/antibody_test.py ('k') | infra/tools/antibody/test/data/sample_suspicious_commits.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698