fgerlits commented on a change in pull request #1017:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1017#discussion_r613094766
##########
File path:
docker/test/integration/minifi/validators/SingleFileContentHashValidator.py
##########
@@ -0,0 +1,43 @@
+import logging
+import os
+
+from os import listdir
+from os.path import join
+
+from .FileOutputValidator import FileOutputValidator
+from ..core.HashUtils import md5
+
+class SingleFileContentHashValidator(FileOutputValidator):
+ """
+ Validates the content of a single file in the given directory.
+ """
+
+ def __init__(self, expected_md5_hash, subdir=''):
+ self.valid = False
+ self.expected_md5_hash = expected_md5_hash
+ self.subdir = subdir
+
+ def validate(self):
+ self.valid = False
+ full_dir = os.path.join(self.output_dir, self.subdir)
+ logging.info("Output folder: %s", full_dir)
+
+ if not os.path.isdir(full_dir):
+ return self.valid
+
+ listing = listdir(full_dir)
+ if listing:
+ for l in listing:
+ logging.info("name:: %s", l)
+ out_file_name = listing[0]
+ logging.info("dir %s -- name %s", full_dir, out_file_name)
+ full_path = join(full_dir, out_file_name)
+ if not os.path.isfile(full_path):
+ return self.valid
Review comment:
Why not `continue` instead of `return`? If `l` is a subdirectory in
`output_dir`, we want to keep looking for matching files.
EDIT: I have misunderstood what this does; it seems to assume that there is
a single file in the directory. This is slightly weird; my preference would
be, in descending order:
- specify the name (or full path) of the file in the constructor, so no
listing is necessary;
- or try to match all files in the given directory;
- or log an error message when there is more than one file in the given
directory.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]