OLD | NEW |
1 # Copyright (C) 2010 Google Inc. All rights reserved. | 1 # Copyright (C) 2010 Google Inc. All rights reserved. |
2 # | 2 # |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
(...skipping 15 matching lines...) Expand all Loading... |
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 | 28 |
29 try: | 29 try: |
30 import jsonresults | 30 import jsonresults |
31 from jsonresults import * | 31 from jsonresults import * |
32 except ImportError: | 32 except ImportError: |
33 print "ERROR: Add the TestResultServer, google_appengine and yaml/lib direct
ories to your PYTHONPATH" | 33 print "ERROR: Add the TestResultServer, google_appengine and yaml/lib direct
ories to your PYTHONPATH" |
34 raise | 34 raise |
35 | 35 |
36 import master_config | 36 from handlers import master_config |
37 | 37 |
38 import json | 38 import json |
39 import logging | 39 import logging |
40 import unittest | 40 import unittest |
41 | 41 |
42 from google.appengine.ext import blobstore | 42 from google.appengine.ext import blobstore |
43 from google.appengine.ext import db | 43 from google.appengine.ext import db |
44 from google.appengine.ext import testbed | 44 from google.appengine.ext import testbed |
45 | 45 |
46 FULL_RESULT_EXAMPLE = """ADD_RESULTS({ | 46 FULL_RESULT_EXAMPLE = """ADD_RESULTS({ |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 incremental_json, _ = JsonResults._get_incremental_json(self._builder, J
sonResults._load_json(aggregated_results), is_full_results_format=False) | 257 incremental_json, _ = JsonResults._get_incremental_json(self._builder, J
sonResults._load_json(aggregated_results), is_full_results_format=False) |
258 merged_results, status_code = JsonResults.merge(self._builder, aggregate
d_results, JsonResults._load_json(incremental_results), num_runs=max_builds, sor
t_keys=True) | 258 merged_results, status_code = JsonResults.merge(self._builder, aggregate
d_results, JsonResults._load_json(incremental_results), num_runs=max_builds, sor
t_keys=True) |
259 | 259 |
260 if expected_data: | 260 if expected_data: |
261 expected_results = self._make_test_json(expected_data, builder_name=
self._builder) | 261 expected_results = self._make_test_json(expected_data, builder_name=
self._builder) |
262 self.assert_json_equal(merged_results, expected_results) | 262 self.assert_json_equal(merged_results, expected_results) |
263 self.assertEqual(status_code, 200) | 263 self.assertEqual(status_code, 200) |
264 else: | 264 else: |
265 self.assertTrue(status_code != 200) | 265 self.assertTrue(status_code != 200) |
266 | 266 |
267 def _test_get_test_list(self, input_data, expected_data): | |
268 input_results = self._make_test_json(input_data) | |
269 expected_results = JSON_RESULTS_TEST_LIST_TEMPLATE.replace("{[TESTDATA_T
ESTS]}", json.dumps(expected_data, separators=(',', ':'))) | |
270 actual_results = JsonResults.get_test_list(self._builder, input_results) | |
271 self.assert_json_equal(actual_results, expected_results) | |
272 | |
273 def test_update_files_empty_aggregate_data(self): | 267 def test_update_files_empty_aggregate_data(self): |
274 small_file = MockFile(name='results-small.json') | 268 small_file = MockFile(name='results-small.json') |
275 large_file = MockFile(name='results.json') | 269 large_file = MockFile(name='results.json') |
276 | 270 |
277 incremental_data = { | 271 incremental_data = { |
278 "builds": ["2", "1"], | 272 "builds": ["2", "1"], |
279 "tests": { | 273 "tests": { |
280 "001.html": { | 274 "001.html": { |
281 "results": [[200, TEXT]], | 275 "results": [[200, TEXT]], |
282 "times": [[200, 0]], | 276 "times": [[200, 0]], |
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1019 "times": [[1, 0]]}}, | 1013 "times": [[1, 0]]}}, |
1020 "foo": { | 1014 "foo": { |
1021 "001.html": { | 1015 "001.html": { |
1022 "results": [[51, TEXT]], | 1016 "results": [[51, TEXT]], |
1023 "times": [[51, 0]]}, | 1017 "times": [[51, 0]]}, |
1024 "002.html": { | 1018 "002.html": { |
1025 "results": [[101, IMAGE]], | 1019 "results": [[101, IMAGE]], |
1026 "times": [[101, 0]]}}}, | 1020 "times": [[101, 0]]}}}, |
1027 "version": 4}) | 1021 "version": 4}) |
1028 | 1022 |
1029 # FIXME(aboxhall): Add some tests for xhtml/svg test results. | |
1030 | |
1031 def test_get_test_name_list(self): | |
1032 # Get test name list only. Don't include non-test-list data and | |
1033 # of test result details. | |
1034 # FIXME: This also tests a temporary bug in the data where directory-lev
el | |
1035 # results have a results and times values. Once that bug is fixed, | |
1036 # remove this test-case and assert we don't ever hit it. | |
1037 self._test_get_test_list( | |
1038 # Input results | |
1039 {"builds": ["3", "2", "1"], | |
1040 "tests": {"foo": { | |
1041 "001.html": { | |
1042 "results": [[200, PASS]], | |
1043 "times": [[200, 0]]}, | |
1044 "results": [[1, NO_DATA]], | |
1045 "times": [[1, 0]]}, | |
1046 "002.html": { | |
1047 "results": [[10, TEXT]], | |
1048 "times": [[10, 0]]}}}, | |
1049 # Expected results | |
1050 {"foo": {"001.html": {}}, "002.html": {}}) | |
1051 | |
1052 def test_gtest(self): | 1023 def test_gtest(self): |
1053 self._test_merge( | 1024 self._test_merge( |
1054 # Aggregated results | 1025 # Aggregated results |
1055 {"builds": ["2", "1"], | 1026 {"builds": ["2", "1"], |
1056 "tests": {"foo.bar": { | 1027 "tests": {"foo.bar": { |
1057 "results": [[50, TEXT]], | 1028 "results": [[50, TEXT]], |
1058 "times": [[50, 0]]}, | 1029 "times": [[50, 0]]}, |
1059 "foo.bar2": { | 1030 "foo.bar2": { |
1060 "results": [[100, IMAGE]], | 1031 "results": [[100, IMAGE]], |
1061 "times": [[100, 0]]}, | 1032 "times": [[100, 0]]}, |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1157 files = TestFile.get_files(master['url_name'], builder, test_type, None,
None, limit=3) | 1128 files = TestFile.get_files(master['url_name'], builder, test_type, None,
None, limit=3) |
1158 self.assertEqual(len(files), 2) | 1129 self.assertEqual(len(files), 2) |
1159 for f in files: | 1130 for f in files: |
1160 j = json.loads(f.data) | 1131 j = json.loads(f.data) |
1161 self.assertItemsEqual(j[builder]['blinkRevision'], ['12345', '54321'
]) | 1132 self.assertItemsEqual(j[builder]['blinkRevision'], ['12345', '54321'
]) |
1162 | 1133 |
1163 tb.deactivate() | 1134 tb.deactivate() |
1164 | 1135 |
1165 if __name__ == '__main__': | 1136 if __name__ == '__main__': |
1166 unittest.main() | 1137 unittest.main() |
OLD | NEW |