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

Unified Diff: infra/tools/antibody/test/antibody_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
« no previous file with comments | « infra/tools/antibody/templates/tbr_by_user.jinja ('k') | infra/tools/antibody/test/compute_stats_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: infra/tools/antibody/test/antibody_test.py
diff --git a/infra/tools/antibody/test/antibody_test.py b/infra/tools/antibody/test/antibody_test.py
index 53c0609301ee30ed5ed8b59ae3925902a08f5956..6dae6ed764c3a37634da929c71b2f77a7f527388 100644
--- a/infra/tools/antibody/test/antibody_test.py
+++ b/infra/tools/antibody/test/antibody_test.py
@@ -50,6 +50,31 @@ class MyTest(auto_stub.TestCase):
with open(os.path.join(THIS_DIR, commit_data), 'r') as f:
suspicious_commits_data = [line.rstrip('\n').split(',') for line in f]
temp_data_gitiles="https://chromium.googlesource.com/infra/infra/+/"
+ sample_monthly_stats = {
+ '7_days': {
+ 'suspicious_to_total_ratio': 1,
+ 'total_commits': 2,
+ 'tbr_no_lgtm': 3,
+ 'no_review_url': 4,
+ 'blank_tbr': 5,
+ },
+ '30_days': {
+ 'suspicious_to_total_ratio': 1,
+ 'total_commits': 2,
+ 'tbr_no_lgtm': 3,
+ 'no_review_url': 4,
+ 'blank_tbr': 5,
+ },
+ 'all_time': {
+ 'suspicious_to_total_ratio': 1,
+ 'total_commits': 2,
+ 'tbr_no_lgtm': 3,
+ 'no_review_url': 4,
+ 'blank_tbr': 5,
+ },
+ }
+ with open(os.path.join(dirname, 'all_monthly_stats.json'), 'w') as f:
+ json.dump(sample_monthly_stats, f)
antibody.generate_antibody_ui(suspicious_commits_data, temp_data_gitiles,
dirname)
with open(
@@ -64,25 +89,34 @@ class MyTest(auto_stub.TestCase):
self.assertTrue(file_string)
self.assertFalse('{{' in file_string)
self.assertFalse('}}' in file_string)
+
+ with open(os.path.join(dirname, antibody.STATS_NAME), 'r') as f:
+ file_string = f.read()
+ self.assertTrue(file_string)
+ self.assertFalse('{{' in file_string)
+ self.assertFalse('}}' in file_string)
+
+ with open(os.path.join(dirname, antibody.LEADERBOARD_NAME), 'r') as f:
+ file_string = f.read()
+ self.assertTrue(file_string)
+ self.assertFalse('{{' in file_string)
+ self.assertFalse('}}' in file_string)
self.assertTrue(os.path.exists(os.path.join(dirname, 'static')))
def test_get_tbr_by_user(self):
with infra_libs.temporary_directory(prefix='antibody-test') as dirname:
- # tbr_no_lgtm: review_url, request_timestamp, hash, people_email_address
+ # tbr_no_lgtm: review_url, request_timestamp, subject,
+ # people_email_address, hash
tbr_no_lgtm = (
- ('https://codereview.chromium.org/1175993003',
- datetime.datetime(2015, 7, 13, 11, 11, 11),
- 'git_hash_1', 'pgervais@chromium.org'),
- ('https://codereview.chromium.org/1175993003',
- datetime.datetime(2015, 7, 13, 11, 11, 11),
- 'git_hash_1', 'hinoka@chromium.org'),
- ('https://codereview.chromium.org/1171763002',
- datetime.datetime(2015, 7, 13, 22, 22, 22),
- 'git_hash_2', 'hinoka@google.com'),
- ('https://codereview.chromium.org/1171763002',
- datetime.datetime(2015, 7, 13, 22, 22, 22),
- 'git_hash_2', 'keelerh@google.com'),
+ ('hello', '2015-07-13 11:11:11', 'pgervais@chromium.org',
+ 'git_hash_1', 'https://codereview.chromium.org/1175993003'),
+ ('hello', '2015-07-13 11:11:11', 'hinoka@chromium.org',
+ 'git_hash_1', 'https://codereview.chromium.org/1175993003'),
+ ('world', '2015-07-13 22:22:22', 'hinoka@chromium.org',
+ 'git_hash_2', 'https://codereview.chromium.org/1171763002'),
+ ('world', '2015-07-13 22:22:22', 'keelerh@google.com',
+ 'git_hash_2', 'https://codereview.chromium.org/1171763002'),
)
antibody.get_tbr_by_user(tbr_no_lgtm,
'https://chromium.googlesource.com/infra/infra/+/', dirname)
« no previous file with comments | « infra/tools/antibody/templates/tbr_by_user.jinja ('k') | infra/tools/antibody/test/compute_stats_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698