<reponame>marcgarreau/eth-utils<filename>tests/humanize-utils/test_humanize_ipfs_uri.py
import pytest

from eth_utils.humanize import humanize_ipfs_uri, is_ipfs_uri


@pytest.mark.parametrize(
    "uri,expected",
    (
        ("ipfs://<KEY>", "ipfs://QmTK..7r8u"),
        ("ipfs://<KEY>", "ipfs://QmaR..iGMH"),
    ),
)
def test_humanize_ipfs_uri(uri, expected):
    actual = humanize_ipfs_uri(uri)
    assert actual == expected


@pytest.mark.parametrize(
    "uri,expected",
    (
        ("ipfs://<KEY>", True),
        ("ipfs://<KEY>", True),
        (123, False),
        ([], False),
        (False, False),
        ("ipfs://", False),
        ("ipfs//<KEY>", False),
        ("ipfs:/<KEY>", False),
        ("ipfs/<KEY>", False),
        ("<KEY>", False),
        ("http://QmTKB75Y73zhNbD3Y73xeXGjYrZHmaXXNxoZqGCagu7r8u", False),
    ),
)
def test_is_ipfs_uri(uri, expected):
    actual = is_ipfs_uri(uri)
    assert actual == expected
