| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 json | 6 import json |
| 7 import re | 7 import re |
| 8 import webapp2 | 8 import webapp2 |
| 9 import webtest | 9 import webtest |
| 10 | 10 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 _MOCK_ACTION_SETTINGS = { | 81 _MOCK_ACTION_SETTINGS = { |
| 82 'cr_notification_build_threshold': 2, | 82 'cr_notification_build_threshold': 2, |
| 83 'cr_notification_latency_limit_minutes': 1000, | 83 'cr_notification_latency_limit_minutes': 1000, |
| 84 } | 84 } |
| 85 | 85 |
| 86 _MOCK_CHECK_FLAKE_SETTINGS = { | 86 _MOCK_CHECK_FLAKE_SETTINGS = { |
| 87 'lower_flake_threshold': 0.02, | 87 'lower_flake_threshold': 0.02, |
| 88 'upper_flake_threshold': 0.98, | 88 'upper_flake_threshold': 0.98, |
| 89 'max_flake_in_a_row': 4, | 89 'max_flake_in_a_row': 4, |
| 90 'max_stable_in_a_row': 4, | 90 'max_stable_in_a_row': 4, |
| 91 'iterations_to_rerun': 100 | 91 'iterations_to_rerun': 100, |
| 92 'max_build_numbers_to_look_back': 1000 |
| 92 } | 93 } |
| 93 | 94 |
| 94 _MOCK_VERSION_NUMBER = 12 | 95 _MOCK_VERSION_NUMBER = 12 |
| 95 | 96 |
| 96 | 97 |
| 97 class ConfigTest(testing.AppengineTestCase): | 98 class ConfigTest(testing.AppengineTestCase): |
| 98 app_module = webapp2.WSGIApplication([ | 99 app_module = webapp2.WSGIApplication([ |
| 99 ('/config', config.Configuration), | 100 ('/config', config.Configuration), |
| 100 ], debug=True) | 101 ], debug=True) |
| 101 | 102 |
| (...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 })) | 763 })) |
| 763 | 764 |
| 764 def testValidateCheckFlakeSettings(self): | 765 def testValidateCheckFlakeSettings(self): |
| 765 self.assertFalse(config._ValidateCheckFlakeSettings({})) | 766 self.assertFalse(config._ValidateCheckFlakeSettings({})) |
| 766 self.assertFalse(config._ValidateCheckFlakeSettings( | 767 self.assertFalse(config._ValidateCheckFlakeSettings( |
| 767 { | 768 { |
| 768 'lower_flake_threshold': 1, # Should be a float. | 769 'lower_flake_threshold': 1, # Should be a float. |
| 769 'upper_flake_threshold': 0.98, | 770 'upper_flake_threshold': 0.98, |
| 770 'max_flake_in_a_row': 4, | 771 'max_flake_in_a_row': 4, |
| 771 'max_stable_in_a_row': 4, | 772 'max_stable_in_a_row': 4, |
| 772 'iterations_to_rerun': 100 | 773 'iterations_to_rerun': 100, |
| 774 'max_build_numbers_to_look_back': 1000 |
| 773 })) | 775 })) |
| 774 self.assertFalse(config._ValidateCheckFlakeSettings( | 776 self.assertFalse(config._ValidateCheckFlakeSettings( |
| 775 { | 777 { |
| 776 'lower_flake_threshold': 0.02, | 778 'lower_flake_threshold': 0.02, |
| 777 'upper_flake_threshold': 'a', # Should be a float. | 779 'upper_flake_threshold': 'a', # Should be a float. |
| 778 'max_flake_in_a_row': 4, | 780 'max_flake_in_a_row': 4, |
| 779 'max_stable_in_a_row': 4, | 781 'max_stable_in_a_row': 4, |
| 780 'iterations_to_rerun': 100 | 782 'iterations_to_rerun': 100, |
| 783 'max_build_numbers_to_look_back': 1000 |
| 781 })) | 784 })) |
| 782 self.assertFalse(config._ValidateCheckFlakeSettings( | 785 self.assertFalse(config._ValidateCheckFlakeSettings( |
| 783 { | 786 { |
| 784 'lower_flake_threshold': 0.02, | 787 'lower_flake_threshold': 0.02, |
| 785 'upper_flake_threshold': 0.98, | 788 'upper_flake_threshold': 0.98, |
| 786 'max_flake_in_a_row': [], # Should be an int. | 789 'max_flake_in_a_row': [], # Should be an int. |
| 787 'max_stable_in_a_row': 4, | 790 'max_stable_in_a_row': 4, |
| 788 'iterations_to_rerun': 100 | 791 'iterations_to_rerun': 100, |
| 792 'max_build_numbers_to_look_back': 1000 |
| 789 })) | 793 })) |
| 790 self.assertFalse(config._ValidateCheckFlakeSettings( | 794 self.assertFalse(config._ValidateCheckFlakeSettings( |
| 791 { | 795 { |
| 792 'lower_flake_threshold': 0.02, | 796 'lower_flake_threshold': 0.02, |
| 793 'upper_flake_threshold': 0.98, | 797 'upper_flake_threshold': 0.98, |
| 794 'max_flake_in_a_row': 4, | 798 'max_flake_in_a_row': 4, |
| 795 'max_stable_in_a_row': {}, # Should be an int. | 799 'max_stable_in_a_row': {}, # Should be an int. |
| 796 'iterations_to_rerun': 100 | 800 'iterations_to_rerun': 100, |
| 801 'max_build_numbers_to_look_back': 1000 |
| 797 })) | 802 })) |
| 798 self.assertFalse(config._ValidateCheckFlakeSettings( | 803 self.assertFalse(config._ValidateCheckFlakeSettings( |
| 799 { | 804 { |
| 800 'lower_flake_threshold': 0.02, | 805 'lower_flake_threshold': 0.02, |
| 801 'upper_flake_threshold': 0.98, | 806 'upper_flake_threshold': 0.98, |
| 802 'max_flake_in_a_row': 4, | 807 'max_flake_in_a_row': 4, |
| 803 'max_stable_in_a_row': 4, | 808 'max_stable_in_a_row': 4, |
| 804 'iterations_to_rerun': 3.2 # Should be an int. | 809 'iterations_to_rerun': 3.2, # Should be an int. |
| 810 'max_build_numbers_to_look_back': 1000 |
| 811 })) |
| 812 self.assertFalse(config._ValidateCheckFlakeSettings( |
| 813 { |
| 814 'lower_flake_threshold': 0.02, |
| 815 'upper_flake_threshold': 0.98, |
| 816 'max_flake_in_a_row': 4, |
| 817 'max_stable_in_a_row': 4, |
| 818 'iterations_to_rerun': 4, |
| 819 'max_build_numbers_to_look_back': 'a' # Should be an int. |
| 805 })) | 820 })) |
| 806 self.assertTrue(config._ValidateCheckFlakeSettings( | 821 self.assertTrue(config._ValidateCheckFlakeSettings( |
| 807 { | 822 { |
| 808 'lower_flake_threshold': 0.02, | 823 'lower_flake_threshold': 0.02, |
| 809 'upper_flake_threshold': 0.98, | 824 'upper_flake_threshold': 0.98, |
| 810 'max_flake_in_a_row': 4, | 825 'max_flake_in_a_row': 4, |
| 811 'max_stable_in_a_row': 4, | 826 'max_stable_in_a_row': 4, |
| 812 'iterations_to_rerun': 100 | 827 'iterations_to_rerun': 100, |
| 828 'max_build_numbers_to_look_back': 1000 |
| 813 })) | 829 })) |
| OLD | NEW |