#NEWLINE# def test_son_manipulator_outgoing( self ) : #NEWLINE# #INDENT# class Thing ( object ) : #NEWLINE# #INDENT# def __init__( self , value ) : #NEWLINE# #INDENT# self . value = value #NEWLINE# #UNINDENT# #UNINDENT# class ThingTransformer ( SONManipulator ) : #NEWLINE# #INDENT# def transform_outgoing( self , doc , collection ) : #NEWLINE# #INDENT# if ( 'value' in doc ) : #NEWLINE# #INDENT# return Thing ( doc [ 'value' ] ) #NEWLINE# #UNINDENT# return doc #NEWLINE# #UNINDENT# #UNINDENT# db = self . client . foo #NEWLINE# db . add_son_manipulator ( ThingTransformer ( ) ) #NEWLINE# db . test . delete_many ( { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# db . test . insert_one ( { #NEWLINE# #INDENT# 'value' : 'value' , #NEWLINE# #UNINDENT# } ) #NEWLINE# out = db . test . find_one ( ) #NEWLINE# self . assertTrue ( isinstance ( out , Thing ) ) #NEWLINE# self . assertEqual ( 'value' , out . value ) #NEWLINE# if client_context . version . at_least ( 2 , 6 ) : #NEWLINE# #INDENT# out = next ( db . test . aggregate ( [ ] , cursor = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) ) #NEWLINE# self . assertTrue ( isinstance ( out , Thing ) ) #NEWLINE# self . assertEqual ( 'value' , out . value )