def test_decode_ulid_raises_on_non_base32_decode_char(ascii_non_base32_str_26): """ Assert that :func:`~ulid.base32.decode_ulid` raises a :class:`~ValueError` when given a :class:`~str` instance that includes ASCII characters not part of the Base 32 decoding character set. """ with pytest.raises(ValueError) as ex: base32.decode_ulid(ascii_non_base32_str_26) ex.match(NON_BASE_32_EXC_REGEX)
def test_decode_ulid_raises_on_str_length_mismatch(invalid_str_26): """ Assert that :func:`~ulid.base32.decode_ulid` raises a :class:`~ValueError` when given a :class:`~str` instance that is not exactly 26 chars. """ with pytest.raises(ValueError) as ex: base32.decode_ulid(invalid_str_26) assert ex.match(DECODE_ULID_STR_LEN_EXC_REGEX)
def test_decode_ulid_raises_on_non_ascii_str(extended_ascii_str_26): """ Assert that :func:`~ulid.base32.decode_ulid` raises a :class:`~ValueError` when given a :class:`~str` instance that contains extended ascii characters. """ with pytest.raises(ValueError) as ex: base32.decode_ulid(extended_ascii_str_26) assert ex.match(NON_ASCII_EXC_REGEX)
def test_decode_ulid_returns_16_bytes(valid_str_26): """ Assert that :func:`~ulid.base32.decode_ulid` decodes a valid 26 character string into a :class:`~bytes` instance that is 128 bit. """ decoded = base32.decode_ulid(valid_str_26) assert isinstance(decoded, bytes) assert len(decoded) == 16