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)
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)
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)