added simple yaml validation
ClosedPublic

Authored by garretraziel on Feb 28 2014, 9:10 AM.

Details

Summary

Added some simple yaml validation for "input", "args" and "task" sections.

Problem is that almost everything is valid yaml, so using python-Rx and
writing schema would be better solution.

Test Plan

Run:
python runtask.py -e xchat-2.8.8-21.fc20 -a x86_64 yaml_file
where yaml_file is correct taskotron task file, empty file, task file
where "input:", "args:" and/or "task:" sections are missing or task without
task list in "tasks:" section.

Diff Detail

Branch
develop
Lint
No Linters Available
Unit
No Unit Test Coverage
ralph added a comment.Feb 28 2014, 2:24 PM

Are there any unit tests that could be associated with this change?

libtaskotron/runner.py
100

Any opinion on making this a KeyError instead of just an Exception? It is an error that is raised when a "key" is missing from the taskdata dict.

112

Same here.

148

This could perhaps be a ValueError?

I think that the best solution is to catch those errors and report it to user nicely, but I wanted to write it like it is written on line 117 to be consistent with existing code.

I think that the best solution is to catch those errors and report it to user nicely, but I wanted to write it like it is written on line 117 to be consistent with existing code.

The existing code needs to be changed at some point, though. It was never my intention to leave everything as base Exceptions.

Kamil added some custom exceptions yesterday, maybe adding a TaskotronYamlError or TaskotronInputError would be appropriate here.

garretraziel updated this revision.Mar 4 2014, 9:35 AM
mkrizek requested changes to this revision.Mar 4 2014, 11:55 AM

I'd like to see some unit tests, but otherwise it looks good to me.

garretraziel updated this revision.Mar 4 2014, 12:57 PM
  • added unit tests for YAML validation
garretraziel updated this revision.Mar 4 2014, 2:13 PM
  • corrected condition where "input" can be string
tflink accepted this revision.Mar 4 2014, 4:40 PM

Looks good to me, thanks for adding those tests

mkrizek accepted this revision.Mar 5 2014, 9:56 AM

LGTM

garretraziel closed this revision.Mar 6 2014, 8:51 AM