| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import datetime | 5 import datetime |
| 6 import mock | 6 import mock |
| 7 import re | 7 import re |
| 8 | 8 |
| 9 import webapp2 | 9 import webapp2 |
| 10 import webtest | 10 import webtest |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 data_point.commit_position = 2 | 388 data_point.commit_position = 2 |
| 389 data_point.git_hash = 'git_hash_2' | 389 data_point.git_hash = 'git_hash_2' |
| 390 data_point.previous_build_commit_position = 1 | 390 data_point.previous_build_commit_position = 1 |
| 391 data_point.previous_build_git_hash = 'git_hash_1' | 391 data_point.previous_build_git_hash = 'git_hash_1' |
| 392 analysis.data_points.append(data_point) | 392 analysis.data_points.append(data_point) |
| 393 analysis.Save() | 393 analysis.Save() |
| 394 | 394 |
| 395 self.assertEqual([[2, success_rate, None, build_number, 'git_hash_2', 1, | 395 self.assertEqual([[2, success_rate, None, build_number, 'git_hash_2', 1, |
| 396 'git_hash_1']], | 396 'git_hash_1']], |
| 397 check_flake._GetCoordinatesData(analysis)) | 397 check_flake._GetCoordinatesData(analysis)) |
| 398 | |
| 399 def testFindSuspectedFlakeBuildDataPoint(self): | |
| 400 master_name = 'm' | |
| 401 builder_name = 'b' | |
| 402 build_number = 123 | |
| 403 step_name = 's' | |
| 404 test_name = 't' | |
| 405 analysis = MasterFlakeAnalysis.Create( | |
| 406 master_name, builder_name, build_number, step_name, test_name) | |
| 407 analysis.suspected_flake_build_number = build_number | |
| 408 data_point_1 = DataPoint() | |
| 409 data_point_1.build_number = build_number - 1 | |
| 410 data_point_1.pass_rate = 1 | |
| 411 data_point_1.commit_position = 2 | |
| 412 data_point_1.git_hash = 'git_hash_2' | |
| 413 data_point_1.previous_build_commit_position = 1 | |
| 414 data_point_1.previous_build_git_hash = 'git_hash_1' | |
| 415 analysis.data_points.append(data_point_1) | |
| 416 data_point_2 = DataPoint() | |
| 417 data_point_2.build_number = build_number | |
| 418 data_point_2.pass_rate = 0.9 | |
| 419 data_point_2.commit_position = 4 | |
| 420 data_point_2.git_hash = 'git_hash_4' | |
| 421 data_point_2.previous_build_commit_position = 3 | |
| 422 data_point_2.previous_build_git_hash = 'git_hash_3' | |
| 423 analysis.data_points.append(data_point_2) | |
| 424 analysis.Save() | |
| 425 | |
| 426 self.assertEqual(data_point_2, | |
| 427 check_flake._FindSuspectedFlakeBuildDataPoint(analysis)) | |
| 428 | |
| 429 def testFindSuspectedFlakeBuildDataPointNotFound(self): | |
| 430 master_name = 'm' | |
| 431 builder_name = 'b' | |
| 432 build_number = 123 | |
| 433 step_name = 's' | |
| 434 test_name = 't' | |
| 435 analysis = MasterFlakeAnalysis.Create( | |
| 436 master_name, builder_name, build_number, step_name, test_name) | |
| 437 analysis.suspected_flake_build_number = build_number | |
| 438 analysis.data_points = [] | |
| 439 analysis.Save() | |
| 440 | |
| 441 self.assertIsNone(check_flake._FindSuspectedFlakeBuildDataPoint(analysis)) | |
| OLD | NEW |