示例#1
0
def test_integer():
    """Integer is a thin wrapper over Float that exposes non-decimal objects"""
    typedef = Integer()
    symmetric_test(typedef, (4, "4"))

    assert typedef.dynamo_dump(4.5, context={}) == "4"
    assert typedef.dynamo_load("4", context={}) == 4

    # Corrupted data is truncated
    assert typedef.dynamo_load("4.5", context={}) == 4
示例#2
0
def test_map_path():
    """To support paths in condition expressions, __getitem__ must return another Type.

    Unlike List, Map can return a different Type for each of its keys."""
    foo_type = UUID()
    bar_type = Integer()
    bool_type = Boolean()
    typedef = Map(**{
        "foo": foo_type,
        "bar": bar_type,
        "bool": bool_type,
    })
    assert typedef["foo"] is foo_type
    assert typedef["bar"] is bar_type
    assert typedef["bool"] is bool_type
示例#3
0
def test_mixin_is_():
    condition = c.is_(3)
    assert condition.operation == "=="
    assert condition.column is c
    assert condition.values == [3]

    condition = c.is_not(3)
    assert condition.operation == "!="
    assert condition.column is c
    assert condition.values == [3]


@pytest.mark.parametrize(
    "op, typedefs, args",
    [("begins_with", [
        Integer(),
        List(String),
        Map(s=String),
        Boolean(),
        Set(Integer),
        Set(Binary),
        Set(String)
    ], ("one-arg", )),
     ("contains", [Integer(), Boolean(), Map(s=String)], ("one-arg", )),
     ("between", [
         Set(String),
         Set(Binary),
         Set(String),
         List(String),
         Map(s=String),
         Boolean()