Exemplo n.º 1
0
def unrecognised_fields_are_ignored():
    User = dictobj.data_class("User", ["username"])
    
    input_dict = {"username": "******", "password": "******"}
    converted_user = dictobj.dict_to_obj(input_dict, User)
    
    expected_user = User("bob")
    assert_equal(expected_user, converted_user)
Exemplo n.º 2
0
def conversion_from_dict_to_obj_uses_items_as_constructor_args():
    User = dictobj.data_class("User", ["username", "password"])
    
    input_dict = {"username": "******", "password": "******"}
    converted_user = dictobj.dict_to_obj(input_dict, User)
    
    expected_user = User("bob", "password1")
    assert_equal(expected_user, converted_user)
Exemplo n.º 3
0
def arguments_with_camelcase_names_are_converted_to_use_underscores():
    User = dictobj.data_class("User", ["is_root"])
    
    input_dict = {"isRoot": True}
    converted_user = dictobj.dict_to_obj(input_dict, User)
    
    expected_user = User(is_root=True)
    assert_equal(expected_user, converted_user)