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

Unified 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 side-by-side diff with in-line comments
Download patch
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
new file mode 100644
index 0000000000000000000000000000000000000000..71fef0a5194e227f216d869ad614f683eebe9e44
--- /dev/null
+++ b/infra/tools/antibody/test/compute_stats_test.py
@@ -0,0 +1,39 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import unittest
+
+from infra.tools.antibody import compute_stats
+
+
+class TestComputeStats(unittest.TestCase):
+ 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]]
+ reg_ratio = compute_stats.ratio_calculator(reg_num, reg_den)
+ self.assertEqual(reg_ratio,
+ [['2014-01', 0.111], ['2014-02', 0.5], ['2014-07', 0.5]])
+
+ zero_num = [['2014-01', 1], ['2014-02', 0], ['2014-07', 5]]
+ zero_den = [['2014-07', 10], ['2014-02', 0], ['2014-01', 0]]
+ zero_ratio = compute_stats.ratio_calculator(zero_num, zero_den)
+ self.assertEqual(zero_ratio,
+ [['2014-01', 0], ['2014-02', 0], ['2014-07', 0.5]])
+
+ missing_num = [['2014-01', 1], ['2014-02', 3], ['2014-07', 5]]
+ missing_den = [['2014-02', 3], ['2014-07', 10]]
+ missing_ratio = compute_stats.ratio_calculator(missing_num, missing_den)
+ self.assertEqual(missing_ratio,
+ [['2014-02', 1.0], ['2014-07', 0.5]])
+
+ extra_num = [['2014-01', 1], ['2014-02', 3], ['2014-07', 5]]
+ extra_den = [['2014-02', 3], ['2015-07', 5], ['2015-07', 5]]
+ extra_ratio = compute_stats.ratio_calculator(extra_num, extra_den)
+ self.assertEqual(extra_ratio, [['2014-02', 1.0]])
+
+ 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)
« 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