• Sam Thursfield's avatar
    functional-tests: Show a better error when we can't extract a file · 2a88ad75
    Sam Thursfield authored
    The functional-tests assume that all necessary dependencies are
    installed. If you are missing one, you'll get an error.
    
    Previously the error looked like this:
    
        ======================================================================
        ERROR: nctional-tests/test-extraction-data/images/xmp-loaded-1.expe (__main__.GenericExtractionTestCase)
        ----------------------------------------------------------------------
        Traceback (most recent call last):
          File "/home/parallels/newrepos/tracker-miners/tests/functional-tests/common/utils/extractor.py", line 73, in get_tracker_extract_jsonld_output
            data = json.loads(output)
          File "/usr/lib/python3.6/json/__init__.py", line 354, in loads
            return _default_decoder.decode(s)
          File "/usr/lib/python3.6/json/decoder.py", line 339, in decode
            obj, end = self.raw_decode(s, idx=_w(s, 0).end())
          File "/usr/lib/python3.6/json/decoder.py", line 357, in raw_decode
            raise JSONDecodeError("Expecting value", s, err.value) from None
        json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
    
        During handling of the above exception, another exception occurred:
    
        Traceback (most recent call last):
          File "./400-extractor-metadata.py", line 85, in generic_test_extraction
            result = get_tracker_extract_jsonld_output(self.file_to_extract)
          File "/home/parallels/newrepos/tracker-miners/tests/functional-tests/common/utils/extractor.py", line 76, in get_tracker_extract_jsonld_output
            "Output was: %s" % (e, output))
        RuntimeError: tracker-extract did not return valid JSON data: Expecting value: line 1 column 1 (char 0)
        Output was:
    
    Now it is a bit clearer:
    
        ======================================================================
        ERROR: nctional-tests/test-extraction-data/images/test-image-1.expe (__main__.GenericExtractionTestCase)
        ----------------------------------------------------------------------
        Traceback (most recent call last):
          File "./400-extractor-metadata.py", line 85, in generic_test_extraction
            result = get_tracker_extract_jsonld_output(self.file_to_extract)
          File "/home/sam/src/tracker-miners/tests/functional-tests/common/utils/extractor.py", line 77, in get_tracker_extract_jsonld_output
            "Error output was: %s" % error_output)
        RuntimeError: tracker-extract didn't return any data.
        Error output was: file:///home/sam/src/tracker-miners/tests/functional-tests/test-extraction-data/images/test-image-1.jpg: No metadata or extractor modules found to handle this file
    2a88ad75
extractor.py 8.93 KB