OLD | NEW |
(Empty) | |
| 1 # Copyright (C) 2014 Google Inc. All rights reserved. |
| 2 # |
| 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are |
| 5 # met: |
| 6 # |
| 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer |
| 11 # in the documentation and/or other materials provided with the |
| 12 # distribution. |
| 13 # * Neither the name of Google Inc. nor the names of its |
| 14 # contributors may be used to endorse or promote products derived from |
| 15 # this software without specific prior written permission. |
| 16 # |
| 17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 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. |
| 28 |
| 29 import json |
| 30 import webkitpy.thirdparty.unittest2 as unittest |
| 31 |
| 32 from webkitpy.layout_tests.process_json_data import ProcessJsonData |
| 33 |
| 34 |
| 35 class ProcessJsonDataTester(unittest.TestCase): |
| 36 |
| 37 def test_check_failing_results(self): |
| 38 valid_json_data = json.loads('''{ |
| 39 "tests": { |
| 40 "test_category": { |
| 41 "test_sub_category": { |
| 42 "test_name": { |
| 43 "test.html": { |
| 44 "actual": "TEXT"
, |
| 45 "expected": "PAS
S", |
| 46 "is_unexpected":
true |
| 47 } |
| 48 } |
| 49 } |
| 50 } |
| 51 } |
| 52 }''') |
| 53 valid_json_data_1 = json.loads('''{ |
| 54 "tests": { |
| 55 "test_category": { |
| 56 "test_sub_category": { |
| 57 "test_name": { |
| 58 "test.html": { |
| 59 "actual": "TEXT"
, |
| 60 "expected": "TEX
T", |
| 61 "is_unexpected":
true |
| 62 } |
| 63 } |
| 64 } |
| 65 } |
| 66 } |
| 67 }''') |
| 68 valid_json_data_2 = json.loads('''{ |
| 69 "tests": { |
| 70 "test_category": { |
| 71 "test_sub_category": { |
| 72 "test_name": { |
| 73 "test.html": { |
| 74 "actual": "TEXT"
, |
| 75 "expected": "TEX
T", |
| 76 "is_unexpected":
true |
| 77 } |
| 78 }, |
| 79 "test_name_2": { |
| 80 "test_2.html": { |
| 81 "actual": "TEXT"
, |
| 82 "expected": "PAS
S", |
| 83 "is_unexpected":
true |
| 84 } |
| 85 } |
| 86 } |
| 87 } |
| 88 } |
| 89 }''') |
| 90 expected_result = json.loads('''{ |
| 91 "tests": { |
| 92 "test_category": { |
| 93 "test_sub_category": { |
| 94 "test_name": { |
| 95 "test.html": { |
| 96 "archived_results": [ |
| 97 "TEXT", |
| 98 "PASS" |
| 99 ] |
| 100 } |
| 101 } |
| 102 } |
| 103 } |
| 104 } |
| 105 }''') |
| 106 process_json_data = ProcessJsonData(valid_json_data, [valid_json_data_1]
, [valid_json_data_2]) |
| 107 actual_result = process_json_data.generate_archived_result() |
| 108 self.assertEqual(expected_result, actual_result) |
| 109 |
| 110 def test_check_full_results(self): |
| 111 valid_json_data = json.loads('''{ |
| 112 "tests": { |
| 113 "test_category": { |
| 114 "test_sub_category": { |
| 115 "test_name_2": { |
| 116 "test_2.html": { |
| 117 "actual": "TEXT"
, |
| 118 "expected": "PAS
S", |
| 119 "is_unexpected":
true |
| 120 } |
| 121 } |
| 122 } |
| 123 } |
| 124 } |
| 125 }''') |
| 126 valid_json_data_1 = json.loads('''{ |
| 127 "tests": { |
| 128 "test_category": { |
| 129 "test_sub_category": { |
| 130 "test_name": { |
| 131 "test.html": { |
| 132 "actual": "TEXT"
, |
| 133 "expected": "TEX
T", |
| 134 "is_unexpected":
true |
| 135 } |
| 136 } |
| 137 } |
| 138 } |
| 139 } |
| 140 }''') |
| 141 valid_json_data_2 = json.loads('''{ |
| 142 "tests": { |
| 143 "test_category": { |
| 144 "test_sub_category": { |
| 145 "test_name": { |
| 146 "test.html": { |
| 147 "actual": "TEXT"
, |
| 148 "expected": "TEX
T", |
| 149 "is_unexpected":
true |
| 150 } |
| 151 }, |
| 152 "test_name_2": { |
| 153 "test_2.html": { |
| 154 "actual": "IMAGE
", |
| 155 "expected": "TEX
T", |
| 156 "is_unexpected":
true |
| 157 } |
| 158 } |
| 159 } |
| 160 } |
| 161 } |
| 162 }''') |
| 163 expected_result = json.loads('''{ |
| 164 "tests": { |
| 165 "test_category": { |
| 166 "test_sub_category": { |
| 167 "test_name_2": { |
| 168 "test_2.html": { |
| 169 "archived_results": [ |
| 170 "TEXT", |
| 171 "IMAGE" |
| 172 ] |
| 173 } |
| 174 } |
| 175 } |
| 176 } |
| 177 } |
| 178 }''') |
| 179 process_json_data = ProcessJsonData(valid_json_data, [valid_json_data_1]
, [valid_json_data_2]) |
| 180 actual_result = process_json_data.generate_archived_result() |
| 181 self.assertEqual(expected_result, actual_result) |
| 182 |
| 183 def test_null_check(self): |
| 184 valid_json_data = json.loads('''{ |
| 185 "tests": { |
| 186 "test_category": { |
| 187 "test_sub_category": { |
| 188 "test_name": { |
| 189 "test.html": { |
| 190 "actual": "TEXT"
, |
| 191 "expected": "PAS
S", |
| 192 "is_unexpected":
true |
| 193 } |
| 194 } |
| 195 } |
| 196 } |
| 197 } |
| 198 }''') |
| 199 expected_result = json.loads('''{ |
| 200 "tests": { |
| 201 "test_category": { |
| 202 "test_sub_category": { |
| 203 "test_name": { |
| 204 "test.html": { |
| 205 "archived_results": [ |
| 206 "TEXT" |
| 207 ] |
| 208 } |
| 209 } |
| 210 } |
| 211 } |
| 212 } |
| 213 }''') |
| 214 process_json_data = ProcessJsonData(valid_json_data, [], []) |
| 215 actual_result = process_json_data.generate_archived_result() |
| 216 self.assertEqual(expected_result, actual_result) |
OLD | NEW |