def test_dump_none_vector_types(engine, typedef, nones): context = {"engine": engine} for values in nones: assert typedef._dump(values, context=context) == actions.wrap(None) assert typedef.dynamo_dump(values, context=context) is None assert typedef.dynamo_dump(None, context=context) is None
def test_ref_pop_unknown(reference_tracker): """Popping an unknown ref doesn't do anything""" # Add a name and value ref so we can make sure nothing is cleared name = reference_tracker.any_ref(column=Document.id).name value = reference_tracker.any_ref(column=Document.id, value=3).name unknown_name_ref = Reference(name="foo", type="value", action=actions.wrap(None)) unknown_value_ref = Reference(name="bar", type="name", action=actions.wrap(None)) reference_tracker.pop_refs(unknown_name_ref, unknown_value_ref) assert name in reference_tracker.attr_names assert value in reference_tracker.attr_values
def test_none_scalar_types(typedef): """single-value types without an explicit 'lack of value' sentinel should return None when given None""" type = typedef() context = {} assert type._load(None, context=context) is None assert type._load({typedef.backing_type: None}, context=context) is None assert type.dynamo_load(None, context=context) is None assert type._dump(None, context=context) == actions.wrap(None) assert type.dynamo_dump(None, context=context) is None
def test_dynamic_dump_none(): """DynamicType doesn't delegate when dumping None, since there isn't type information""" dt = DynamicType() assert dt._dump(None) == actions.wrap(None)
def test_dynamic_load_dump_symmetric(wire, local): dt = DynamicType() assert dt._dump(local, context=None) == actions.wrap(wire) assert dt._load(wire, context=None) == local
def test_wrap_action(value, func): action = func(value) assert wrap(action) is action
def test_wrap_non_action(value, type): w = wrap(value) assert w.value is value assert w.type is type