Flag for no coverage the really odd cases and the updated error handling in get_metadata

This commit is contained in:
Trenton H 2024-02-03 15:58:44 -08:00
parent 88a9c5079b
commit dab86a0802
2 changed files with 4 additions and 4 deletions

View File

@ -71,7 +71,7 @@ def get_suggestion_cache(document_id: int) -> Optional[SuggestionCacheData]:
and cache_hits[CLASSIFIER_HASH_KEY] == doc_suggestions.classifier_hash
):
return doc_suggestions
else:
else: # pragma: no cover
# Remove the key because something didn't match
cache.delete(doc_key)
return None
@ -145,7 +145,7 @@ def get_metadata_cache(document_id: int) -> Optional[MetadataCacheData]:
# Refresh cache
cache.touch(doc_key, CACHE_50_MINUTES)
return doc_metadata
else:
else: # pragma: no cover
# Something didn't match, delete the key
cache.delete(doc_key)
except Document.DoesNotExist: # pragma: no cover

View File

@ -389,11 +389,11 @@ class DocumentViewSet(
try:
return parser.extract_metadata(file, mime_type)
except Exception:
except Exception: # pragma: no cover
logger.exception(f"Issue getting metadata for {file}")
# TODO: cover GPG errors, remove later.
return []
else:
else: # pragma: no cover
logger.warning(f"No parser for {mime_type}")
return []