Exemplo n.º 1
0
 def test_serializer_can_define_methods(self):
     result_dict = MethodizedSerializer(OtherModel()).to_dict()
     assert_equals("poops", result_dict['custom_field'])
Exemplo n.º 2
0
 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'])
Exemplo n.º 3
0
 def test_serializer_methods_shadow_object_methods(self):
     result_dict = MethodizedSerializer(OtherModel(), {
         'lol': "thing"
     }).to_dict()
     assert_equals('overridden func: lol', result_dict['func'])
Exemplo n.º 4
0
 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'])