#NEWLINE# def test_attach_endpoint_to_inport( inport , outport ) : #NEWLINE# #INDENT# inport . owner . did_connect = Mock ( ) #NEWLINE# old_inport = InPort ( 'in' , actor ( ) ) #NEWLINE# old_endpoint = LocalInEndpoint ( OutPort ( 'out' , actor ( ) ) , old_inport ) #NEWLINE# endpoint = LocalInEndpoint ( outport , inport ) #NEWLINE# inport . attach_endpoint ( old_endpoint ) #NEWLINE# assert inport . is_connected_to ( inport . id ) #NEWLINE# prev_endpoint = inport . attach_endpoint ( endpoint ) #NEWLINE# assert ( prev_endpoint == old_endpoint ) #NEWLINE# assert inport . is_connected_to ( inport . id ) #NEWLINE# assert ( not inport . is_connected_to ( old_inport . id ) ) #NEWLINE# assert inport . owner . did_connect . called