#NEWLINE# def test_repl_connection( self ) : #NEWLINE# #INDENT# node = { #NEWLINE# #INDENT# 'replication_ip' : '127.0.0.1' , #NEWLINE# 'replication_port' : 80 , #NEWLINE# 'device' : 'sdb1' , #NEWLINE# #UNINDENT# } #NEWLINE# conn = db_replicator . ReplConnection ( node , '1234567890' , 'abcdefg' , logging . getLogger ( ) ) #NEWLINE# def req( method , path , body , headers ) : #NEWLINE# #INDENT# self . assertEqual ( method , 'REPLICATE' ) #NEWLINE# self . assertEqual ( headers [ 'Content-Type' ] , 'application/json' ) #NEWLINE# #UNINDENT# class Resp ( object ) : #NEWLINE# #INDENT# def read( self ) : #NEWLINE# #INDENT# return 'data' #NEWLINE# #UNINDENT# #UNINDENT# resp = Resp ( ) #NEWLINE# conn . request = req #NEWLINE# conn . getresponse = ( lambda * args : resp ) #NEWLINE# self . assertEqual ( conn . replicate ( 1 , 2 , 3 ) , resp ) #NEWLINE# def other_req( method , path , body , headers ) : #NEWLINE# #INDENT# raise Exception ( 'blah' ) #NEWLINE# #UNINDENT# conn . request = other_req #NEWLINE# self . assertEqual ( conn . replicate ( 1 , 2 , 3 ) , None )