Allow resultsdb_directive to read from file
ClosedPublic

Authored by jskladan on Jul 21 2016, 2:08 PM.

Details

Summary

Adds a file parameter to the resultsdb_directive that allows for it to
read the input data from file, instead of the results variable

Test Plan

added unittests

Diff Detail

Repository
rLTRN libtaskotron
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
jskladan retitled this revision from to Allow resultsdb_directive to read from file.Jul 21 2016, 2:08 PM
jskladan updated this object.
jskladan edited the test plan for this revision. (Show Details)
jskladan added a reviewer: libtaskotron.
jskladan updated this revision to Diff 2401.Jul 21 2016, 2:14 PM
  • fix docs
kparal added a subscriber: kparal.Jul 22 2016, 9:38 AM
kparal added inline comments.
libtaskotron/directives/resultsdb_directive.py
25

Would this be clearer?

You must use either ``results`` or ``file`` parameter (exactly one).
77

on on

77–85

This seems to be part of the first example (the first two directives), but it's a separate example. Let's put a new paragraph between the first two and the second two directives. Let's say something like "Read ResultsYAML from a file, as saved by a bash check".

84

Typo. But actually, do we need to export the output? I think we used it for Bodhi reporting in the past, now we don't need it at all? Maybe we can strip it from the examples.

262–263

Would it make sense to wrap this as well and raise TaskotronDirectiveError for IO errors? Or do we want to raise them directly (maybe document them then)?

268–269

Maybe get rid of the apostrophes in the message, because this is going to be printed even for file: now.

testing/test_resultsdb_directive.py
183–184

This makes me very uneasy. Why we need to mock builtin open? That's a big freaking hammer. Would it be better to use pytest's tmpdir, as we use it in functest_yumrepoinfo_directive.py, to create a fake file with predefined contents (therefore ideally put it into functest_resultsdb_directive)?

apart of the open mock, I agree, will fix asap.

testing/test_resultsdb_directive.py
183–184

Taken from xunit directive, tbh. I don't really see the problem of mocking open(), though, feels even cleaner than creating fake files to me.

kparal added inline comments.Jul 22 2016, 11:57 AM
libtaskotron/directives/resultsdb_directive.py
261–269

IIUIC, this didn't fix the issue unless you also start catching IOError.

testing/test_resultsdb_directive.py
183–184

I don't like overriding builtins at all, but I won't fight it at this point.

However, according to this and this it might be a better idea to patch open just for the current module, and not globally in __builtin__ space.

kparal added inline comments.Jul 22 2016, 12:07 PM
libtaskotron/directives/resultsdb_directive.py
258–259

Also, please add this to raises: in documentation, thanks.

jskladan updated this revision to Diff 2412.Jul 25 2016, 8:39 AM
kparal accepted this revision.Jul 25 2016, 8:53 AM
kparal added a reviewer: kparal.

Looks good, and seems to work well in my testing. Please push!

This revision is now accepted and ready to land.Jul 25 2016, 8:53 AM
Closed by commit rLTRNd9b7a64c5b9a: Allow resultsdb_directive to read from file (authored by Josef Skladanka <jskladan@redhat.com>). · Explain WhyJul 25 2016, 9:22 AM
This revision was automatically updated to reflect the committed changes.