tests pass
Details
Details
Diff Detail
Diff Detail
- Lint
Lint Skipped - Unit
Unit Tests Skipped
jskladan |
tests pass
Lint Skipped |
Unit Tests Skipped |
Path | |||
---|---|---|---|
M | testing/test_check.py (8 lines) |
Commit | Tree | Parents | Author | Summary | Date |
---|---|---|---|---|---|
cdd6dcf5fc7c | 17112d2ab4c1 | affa32d15db1 | Kamil Páral | use yaml.safe_load() because it's safer (Show More…) | Apr 3 2014, 2:34 PM |
Show First 20 Lines • Show All 216 Lines • ▼ Show 20 Line(s) | 209 | def test_single_tap(self): | |||
---|---|---|---|---|---|
217 | assert lines[-1].strip() == '...' | 217 | assert lines[-1].strip() == '...' | ||
218 | 218 | | |||
219 | def test_single_yaml(self): | 219 | def test_single_yaml(self): | ||
220 | '''Test export with a single item section. Check specific YAML lines.''' | 220 | '''Test export with a single item section. Check specific YAML lines.''' | ||
221 | tap = check.export_TAP(self.cd) | 221 | tap = check.export_TAP(self.cd) | ||
222 | 222 | | |||
223 | # specific lines must exist | 223 | # specific lines must exist | ||
224 | yaml_block = self._tap_to_yaml(tap) | 224 | yaml_block = self._tap_to_yaml(tap) | ||
225 | yaml_obj = yaml.load(yaml_block) | 225 | yaml_obj = yaml.safe_load(yaml_block) | ||
226 | 226 | | |||
227 | assert yaml_obj['item'] == self.item | 227 | assert yaml_obj['item'] == self.item | ||
228 | assert yaml_obj['outcome'] == self.outcome | 228 | assert yaml_obj['outcome'] == self.outcome | ||
229 | assert yaml_obj['summary'] == self.summary | 229 | assert yaml_obj['summary'] == self.summary | ||
230 | assert yaml_obj['type'] == self.report_type | 230 | assert yaml_obj['type'] == self.report_type | ||
231 | assert yaml_obj['details'] | 231 | assert yaml_obj['details'] | ||
232 | assert yaml_obj['details']['output'] == self.output | 232 | assert yaml_obj['details']['output'] == self.output | ||
233 | 233 | | |||
Show All 10 Lines | 234 | def test_multi(self): | |||
244 | yaml_blocks = self._tap_to_yaml(tap) | 244 | yaml_blocks = self._tap_to_yaml(tap) | ||
245 | 245 | | |||
246 | # test that we have a correct number of TAP lines | 246 | # test that we have a correct number of TAP lines | ||
247 | tap_lines = [line for line in lines if line.startswith('ok') or | 247 | tap_lines = [line for line in lines if line.startswith('ok') or | ||
248 | line.startswith('not ok')] | 248 | line.startswith('not ok')] | ||
249 | assert len(tap_lines) == 3 | 249 | assert len(tap_lines) == 3 | ||
250 | 250 | | |||
251 | # test that we have a correct number (and rough contents) of YAML blocks | 251 | # test that we have a correct number (and rough contents) of YAML blocks | ||
252 | yaml_gen = yaml.load_all(yaml_blocks) | 252 | yaml_gen = yaml.safe_load_all(yaml_blocks) | ||
253 | for index, yaml_obj in enumerate(yaml_gen): | 253 | for index, yaml_obj in enumerate(yaml_gen): | ||
254 | assert 'item' in yaml_obj | 254 | assert 'item' in yaml_obj | ||
255 | assert index == 2 | 255 | assert index == 2 | ||
256 | 256 | | |||
257 | def test_invalid(self): | 257 | def test_invalid(self): | ||
258 | '''Test invalid input parameters''' | 258 | '''Test invalid input parameters''' | ||
259 | with pytest.raises(exc.TaskotronValueError): | 259 | with pytest.raises(exc.TaskotronValueError): | ||
260 | self.cd.item = None | 260 | self.cd.item = None | ||
261 | check.export_TAP(self.cd) | 261 | check.export_TAP(self.cd) | ||
262 | 262 | | |||
263 | def test_minimal(self): | 263 | def test_minimal(self): | ||
264 | '''Test that empty CheckDetail values don't produce empty TAP lines, | 264 | '''Test that empty CheckDetail values don't produce empty TAP lines, | ||
265 | for example 'summary:' should not be present if there's no | 265 | for example 'summary:' should not be present if there's no | ||
266 | CheckDetail.summary''' | 266 | CheckDetail.summary''' | ||
267 | cd = check.CheckDetail('foo') | 267 | cd = check.CheckDetail('foo') | ||
268 | tap = check.export_TAP(cd) | 268 | tap = check.export_TAP(cd) | ||
269 | yaml_block = self._tap_to_yaml(tap) | 269 | yaml_block = self._tap_to_yaml(tap) | ||
270 | yaml_obj = yaml.load(yaml_block) | 270 | yaml_obj = yaml.safe_load(yaml_block) | ||
271 | 271 | | |||
272 | # the output should look like this: | 272 | # the output should look like this: | ||
273 | # | 273 | # | ||
274 | # ok - $CHECKNAME for XXX | 274 | # ok - $CHECKNAME for XXX | ||
275 | # --- | 275 | # --- | ||
276 | # item: XXX | 276 | # item: XXX | ||
277 | # outcome: XXX | 277 | # outcome: XXX | ||
278 | # ... | 278 | # ... | ||
Show All 20 Lines | 291 | def test_tap_not_ok(self): | |||
299 | self.cd.outcome = 'CRASHED' | 299 | self.cd.outcome = 'CRASHED' | ||
300 | assert check.export_TAP(self.cd).startswith('not ok') | 300 | assert check.export_TAP(self.cd).startswith('not ok') | ||
301 | 301 | | |||
302 | def test_custom_report_type(self): | 302 | def test_custom_report_type(self): | ||
303 | '''Test that user can specify a custom CheckDetail.report_type''' | 303 | '''Test that user can specify a custom CheckDetail.report_type''' | ||
304 | self.cd.report_type = 'My Custom Type' | 304 | self.cd.report_type = 'My Custom Type' | ||
305 | tap = check.export_TAP(self.cd) | 305 | tap = check.export_TAP(self.cd) | ||
306 | yaml_block = self._tap_to_yaml(tap) | 306 | yaml_block = self._tap_to_yaml(tap) | ||
307 | yaml_obj = yaml.load(yaml_block) | 307 | yaml_obj = yaml.safe_load(yaml_block) | ||
308 | 308 | | |||
309 | assert yaml_obj['type'] == self.cd.report_type | 309 | assert yaml_obj['type'] == self.cd.report_type |