Skip to content

Commit

Permalink
BACK-3396: fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
zylora committed Aug 5, 2024
1 parent 9693f8d commit 45b23b8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion offchain/metadata/adapters/data_uri.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def decode_data_url(data_url): # type: ignore[no-untyped-def]
decoded_data = base64.b64decode(data)
decoded_text = decoded_data.decode("utf-8")
return decoded_text
elif "json;utf8" in data_parts[0] or "json" in data_parts[0]:
elif "json" in data_parts[0]:
decoded_data = urlopen(data_url).read()
decoded_text = json.dumps(json.loads(decoded_data))
return decoded_text
Expand Down
12 changes: 11 additions & 1 deletion tests/metadata/fetchers/test_metadata_fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,17 @@ async def test_gen_fetch_data_adapter(self): # type: ignore[no-untyped-def]

@pytest.mark.asyncio
async def test_gen_fetch_ipfs_adapter(self): # type: ignore[no-untyped-def]
fetcher = MetadataFetcher()
fetcher = MetadataFetcher(
async_adapter_configs=[
AdapterConfig(
adapter_cls=IPFSAdapter,
mount_prefixes=[
"ipfs://",
],
host_prefixes=["https://ipfs.decentralized-content.com/ipfs/"],
),
]
)
content = await fetcher.gen_fetch_content(
"ipfs://bafkreiboyxwytfyufln3uzyzaixslzvmrqs5ezjo2cio2fymfqf6u57u6u" # noqa
)
Expand Down

0 comments on commit 45b23b8

Please sign in to comment.