diff --git a/aries_cloudagent/vc/ld_proofs/document_downloader.py b/aries_cloudagent/vc/ld_proofs/document_downloader.py index d4d0bb691f..df194161e6 100644 --- a/aries_cloudagent/vc/ld_proofs/document_downloader.py +++ b/aries_cloudagent/vc/ld_proofs/document_downloader.py @@ -62,7 +62,7 @@ def __init__( for url, filename in StaticCacheJsonLdDownloader.CONTEXT_FILE_MAPPING.items() } - def load(self, url: str, options: Optional[Dict] = None): + async def load(self, url: str, options: Optional[Dict] = None): """Load a jsonld document from URL. Prioritize local static cache before attempting to download from the URL. @@ -74,10 +74,10 @@ def load(self, url: str, options: Optional[Dict] = None): return cached logger.debug("Context %s not in static cache, resolving from URL.", url) - return self._live_load(url, options) + return await self._live_load(url, options) - def _live_load(self, url: str, options: Optional[Dict] = None): - doc, link_header = self.documents_downloader.download(url, options) + async def _live_load(self, url: str, options: Optional[Dict] = None): + doc, link_header = await self.documents_downloader.download(url, options) return self.document_parser.parse(doc, link_header) diff --git a/aries_cloudagent/vc/ld_proofs/document_loader.py b/aries_cloudagent/vc/ld_proofs/document_loader.py index e5078c8c6c..68c4e8586a 100644 --- a/aries_cloudagent/vc/ld_proofs/document_loader.py +++ b/aries_cloudagent/vc/ld_proofs/document_loader.py @@ -49,8 +49,8 @@ async def _load_did_document(self, did: str, options: dict): return document - def _load_http_document(self, url: str, options: dict): - document = self.requests_loader(url, options) + async def _load_http_document(self, url: str, options: dict): + document = await self.requests_loader(url, options) return document @@ -62,7 +62,7 @@ async def _load_async(self, url: str, options: dict): if url.startswith("did:"): document = await self._load_did_document(url, options) elif url.startswith("http://") or url.startswith("https://"): - document = self._load_http_document(url, options) + document = await self._load_http_document(url, options) else: raise LinkedDataProofException( "Unrecognized url format. Must start with " diff --git a/aries_cloudagent/vc/ld_proofs/tests/test_document_downloader.py b/aries_cloudagent/vc/ld_proofs/tests/test_document_downloader.py index ba3a9cf41b..103f06ec7c 100644 --- a/aries_cloudagent/vc/ld_proofs/tests/test_document_downloader.py +++ b/aries_cloudagent/vc/ld_proofs/tests/test_document_downloader.py @@ -5,18 +5,18 @@ ) -def test_load_cache_hit(): +async def test_load_cache_hit(): downloader = Mock() context_loader = StaticCacheJsonLdDownloader(document_downloader=downloader) - context_loader.load("https://www.w3.org/2018/credentials/v1") + await context_loader.load("https://www.w3.org/2018/credentials/v1") downloader.download.assert_not_called() -def test_load_cache_miss_triggers_download(): +async def test_load_cache_miss_triggers_download(): downloader = Mock() downloader.download = Mock(return_value=(None, None)) context_loader = StaticCacheJsonLdDownloader(document_downloader=downloader) - context_loader.load("https://www.w3.org/2018/very_unlikely_name/v1") + await context_loader.load("https://www.w3.org/2018/very_unlikely_name/v1") downloader.download.assert_called()