def test_serializer_can_define_methods(self): result_dict = MethodizedSerializer(OtherModel()).to_dict() assert_equals("poops", result_dict['custom_field'])
def test_serializer_methods_can_be_keyed(self): result_dict = MethodizedSerializer(OtherModel(), { 'lol': "thing" }).to_dict() assert_equals("lol", result_dict['kek']) assert_equals({'pass_through': {'lol': "thing"}}, result_dict['base'])
def test_serializer_methods_shadow_object_methods(self): result_dict = MethodizedSerializer(OtherModel(), { 'lol': "thing" }).to_dict() assert_equals('overridden func: lol', result_dict['func'])
def test_serializer_passes_through_optional_args(self): result_dict = MethodizedSerializer(OtherModel(), { 'lol': "thing" }).to_dict() assert_equals("object.here:poops, args['lol']:thing", result_dict['custom_field_with_args'])