Пример #1
0
def test_rejects_blank_strings():
    """
    rejects blank strings
    """
    input_string = ""

    with pytest.raises(ValueError) as err:
        uxid.decode(input_string)
    assert "input is required" in str(err.value)
Пример #2
0
def test_rejects_malformed_strings():
    """
    rejects malformed strings
    """
    input_string = "this is not a UXID"

    with pytest.raises(ValueError) as err:
        uxid.decode(input_string)
    assert "expected input to be a Base32 encoded string, got: 'this is not a UXID'" in str(
        err.value)
Пример #3
0
def test_returns_a_uxid_with_input():
    """
    returns a UXID with input
    """
    input_string = "01E9VB3RWNAR89HSKMS84K9HCS"

    decoded_id = uxid.decode(input_string)
    assert isinstance(decoded_id, uxid.UXID)
    assert decoded_id.encoded == "01E9VB3RWNAR89HSKMS84K9HCS"
Пример #4
0
def test_accepts_the_maximum_allowed_timestamp():
    """
    accepts the maximum allowed timestamp
    """
    input_string = "7ZZZZZZZZZZZZZZZZZZZZZZZZZ"

    decoded_id = uxid.decode(input_string)
    assert isinstance(decoded_id, uxid.UXID)

    assert decoded_id.time == 281474976710655
Пример #5
0
def test_accepts_a_ulid():
    """
    accepts a ULID
    """
    input_string = "01E9VB3RWNAR89HSKMS84K9HCS"

    decoded_id = uxid.decode(input_string)
    assert isinstance(decoded_id, uxid.UXID)

    assert decoded_id.time == 1591129269141
Пример #6
0
def test_uxid_decode_exists():
    """
    UXID decode exists
    """
    result = uxid.decode("01E9VB3RWNAR89HSKMS84K9HCS")
    assert result, "Expected result to be defined"