Chromium Code Reviews| Index: appengine/findit/handlers/test/triage_analysis_test.py |
| diff --git a/appengine/findit/handlers/test/triage_analysis_test.py b/appengine/findit/handlers/test/triage_analysis_test.py |
| index 7bf6bdaffa72019d7bfe0bfe1baa384a9c72ef05..5af05582b46810a0b70bd77f284d4f28a324f6f9 100644 |
| --- a/appengine/findit/handlers/test/triage_analysis_test.py |
| +++ b/appengine/findit/handlers/test/triage_analysis_test.py |
| @@ -5,6 +5,9 @@ |
| from google.appengine.ext import ndb |
| import webapp2 |
| +from datetime import datetime |
|
lijeffrey
2016/06/13 18:15:05
nit: i would move these imports to the very top
josiahk
2016/06/21 00:56:53
Done.
|
| +from datetime import timedelta |
|
chanli
2016/06/13 20:21:03
Move this one to top as well.
josiahk
2016/06/21 00:56:53
Done.
|
| + |
| from testing_utils import testing |
| from handlers import triage_analysis |
| @@ -130,3 +133,224 @@ class TriageAnalysisTest(testing.AppengineTestCase): |
| params={'url': build_url, 'correct': True, 'format': 'json'}) |
| self.assertEquals(200, response.status_int) |
| self.assertEquals({'success': True}, response.json_body) |
| + |
| + def testAnalysesMatch(self): |
| + analysis_with_empty_failures = WfAnalysis.Create( |
|
lijeffrey
2016/06/13 18:15:05
i would create these and modify them in the order
chanli
2016/06/13 20:21:03
+1
analysis_with_empty_failiures = WfAnalysis.Cre
josiahk
2016/06/21 00:56:53
Done.
|
| + self.master_name, self.builder_name, 200) |
| + analysis_with_no_suspected_cls = WfAnalysis.Create( |
| + self.master_name, self.builder_name, 201) |
| + analysis_with_suspected_cls_1 = WfAnalysis.Create( |
| + self.master_name, self.builder_name, 202) |
| + analysis_with_suspected_cls_2 = WfAnalysis.Create( |
| + self.master_name, self.builder_name, 203) |
| + analysis_with_suspected_cls_3 = WfAnalysis.Create( |
| + self.master_name, self.builder_name, 204) |
| + analysis_with_suspected_cls_4 = WfAnalysis.Create( |
| + self.master_name, self.builder_name, 205) |
| + analysis_with_tests_1 = WfAnalysis.Create( |
| + self.master_name, self.builder_name, 206) |
| + analysis_with_tests_2 = WfAnalysis.Create( |
| + self.master_name, self.builder_name, 207) |
| + |
| + # Set time to yesterday |
|
lijeffrey
2016/06/13 18:15:05
nit: comment ends with .
chanli
2016/06/13 20:21:03
nit: 'Sets'
josiahk
2016/06/21 00:56:53
Thanks!
|
| + build_start_time = datetime.utcnow() - timedelta( |
|
lijeffrey
2016/06/13 18:15:05
if it's yesterday you can do
datetime.utcnow() -
josiahk
2016/06/21 00:56:53
Thanks!
|
| + triage_analysis.MATCHING_ANALYSIS_DAYS_AGO_END) |
| + build_start_time = build_start_time.replace( |
| + hour=12, minute=0, second=0, microsecond=0) |
| + |
| + analysis_with_empty_failures.result = { |
| + 'failures': [] |
| + } |
| + analysis_with_empty_failures.put() |
| + |
| + analysis_with_no_suspected_cls.result = { |
| + 'failures': [ |
| + { |
| + 'suspected_cls': [] |
| + }, |
| + { |
| + 'suspected_cls': [] |
| + }, |
| + ] |
| + } |
| + analysis_with_no_suspected_cls.put() |
| + |
| + analysis_with_suspected_cls_1.result = { |
| + 'failures': [ |
| + { |
| + 'step_name': 'interactive_ui_tests', |
| + 'suspected_cls': [ |
| + { |
| + 'revision': '3cf9343f4602d4ec11717cb6ff56a793c1d5f84b', |
| + } |
| + ], |
| + } |
| + ] |
| + } |
| + analysis_with_suspected_cls_1.put() |
| + |
| + analysis_with_suspected_cls_2.result = { |
| + 'failures': [ |
| + { |
| + 'suspected_cls': [], |
| + 'step_name': 'browser_tests' |
| + }, |
| + { |
| + 'suspected_cls': [ |
| + { |
| + 'revision': '0e8dc209f5e4a6140e43551de0e036324c68a383', |
| + } |
| + ], |
| + 'step_name': 'content_browsertests' |
| + } |
| + ] |
| + } |
| + analysis_with_suspected_cls_2.put() |
| + |
| + analysis_with_suspected_cls_3.result = { |
| + 'failures': [ |
| + { |
| + 'suspected_cls': [], |
| + 'step_name': 'browser_tests', |
| + }, |
| + { |
| + 'suspected_cls': [ |
| + { |
| + 'revision': '0e8dc209f5e4a6140e43551de0e036324c68a383', |
| + }, |
| + { |
| + 'revision': '292b41bbd603ae2f11d239f457a8a5f04387fa85', |
| + }, |
| + { |
| + 'revision': 'f6c9ef029e28a6bef28e727cd70751d782963e21', |
| + } |
| + ], |
| + 'step_name': 'content_browsertests', |
| + } |
| + ] |
| + } |
| + analysis_with_suspected_cls_3.result_status = result_status.FOUND_UNTRIAGED |
| + analysis_with_suspected_cls_3.build_start_time = build_start_time |
| + analysis_with_suspected_cls_3.put() |
| + |
| + analysis_with_suspected_cls_4.result = { |
| + 'failures': [ |
| + { |
| + 'suspected_cls': [], |
| + 'step_name': 'browser_tests', |
| + }, |
| + { |
| + 'suspected_cls': [ |
| + { |
| + 'revision': '0e8dc209f5e4a6140e43551de0e036324c68a383', |
| + }, |
| + { |
| + 'revision': '292b41bbd603ae2f11d239f457a8a5f04387fa85', |
| + }, |
| + { |
| + 'revision': 'f6c9ef029e28a6bef28e727cd70751d782963e21', |
| + } |
| + ], |
| + 'step_name': 'content_browsertests', |
| + } |
| + ] |
| + } |
| + analysis_with_suspected_cls_4.result_status = result_status.FOUND_UNTRIAGED |
| + analysis_with_suspected_cls_4.build_start_time = build_start_time |
| + analysis_with_suspected_cls_4.put() |
| + |
| + analysis_with_tests_1.result = { |
| + 'failures': [ |
| + { |
| + 'tests': [ |
| + { |
| + 'test_name': 'super_test_1', |
| + 'suspected_cls': [ |
| + { |
| + 'revision': 'abc' |
| + } |
| + ] |
| + }, { |
| + 'test_name': 'super_test_2', |
| + 'suspected_cls': [ |
| + { |
| + 'revision': 'def' |
| + }, |
| + { |
| + 'revision': 'ghi' |
| + } |
| + ] |
| + } |
| + ], |
| + 'step_name': 'interactive_ui_tests', |
| + 'suspected_cls': [ |
| + { |
| + 'revision': '3cf9343f4602d4ec11717cb6ff56a793c1d5f84b', |
| + } |
| + ], |
| + } |
| + ] |
| + } |
| + analysis_with_tests_1.put() |
| + |
| + analysis_with_tests_2.result = { |
| + 'failures': [ |
| + { |
| + 'tests': [ |
| + { |
| + 'test_name': 'super_test_3', |
| + 'suspected_cls': [ |
| + { |
| + 'revision': 'ab' |
| + }, |
| + { |
| + 'revision': 'cd' |
| + }, |
| + { |
| + 'revision': 'ef' |
| + } |
| + ] |
| + } |
| + ], |
| + 'step_name': 'interactive_ui_tests', |
| + 'suspected_cls': [ |
| + { |
| + 'revision': '3cf9343f4602d4ec11717cb6ff56a793c1d5f84b', |
| + } |
| + ], |
| + } |
| + ] |
| + } |
| + analysis_with_tests_2.put() |
| + |
| + # Empty failures list |
|
lijeffrey
2016/06/13 18:15:06
nit: all comments should end with .
josiahk
2016/06/21 00:56:53
Done.
|
| + self.assertFalse(triage_analysis._DoAnalysesMatch( |
| + analysis_with_empty_failures, |
| + analysis_with_empty_failures)) |
| + # Zero culprit-tuples |
| + self.assertFalse(triage_analysis._DoAnalysesMatch( |
| + analysis_with_no_suspected_cls, |
| + analysis_with_no_suspected_cls)) |
| + # Zero culprit-tuples and some culprit-tuples |
| + self.assertFalse(triage_analysis._DoAnalysesMatch( |
| + analysis_with_no_suspected_cls, |
| + analysis_with_suspected_cls_1)) |
| + # Has step-level culprit-tuples, and should detect match |
| + self.assertTrue(triage_analysis._DoAnalysesMatch( |
| + analysis_with_suspected_cls_2, |
| + analysis_with_suspected_cls_2)) |
| + # Two different step-level culprit-tuples, and should fail to match |
| + self.assertFalse(triage_analysis._DoAnalysesMatch( |
| + analysis_with_suspected_cls_2, |
| + analysis_with_suspected_cls_3)) |
| + # Has test-level culprit-tuples, and should detect match |
| + self.assertTrue(triage_analysis._DoAnalysesMatch( |
| + analysis_with_tests_1, |
| + analysis_with_tests_1)) |
| + # Two different test-level culprit-tuples, and should fail to match |
| + self.assertFalse(triage_analysis._DoAnalysesMatch( |
| + analysis_with_tests_1, |
| + analysis_with_tests_2)) |
| + |
| + # TODO(josiahk): Put this into its own testTriageDuplicateResults test |
| + triage_analysis._TriageDuplicateResults(analysis_with_suspected_cls_3, True) |
|
lijeffrey
2016/06/13 18:15:05
why not just do this instead of leaving it in TODO
chanli
2016/06/13 20:21:03
+1
josiahk
2016/06/21 00:56:53
There is now a testTriageDuplicateResults test, th
|