#NEWLINE# def test_getChild_exists( self ) : #NEWLINE# #INDENT# self . config . get = MagicMock ( return_value = '' ) #NEWLINE# zone = MagicMock ( ) #NEWLINE# def get_zone( x ) : #NEWLINE# #INDENT# if ( x == 'foo' ) : #NEWLINE# #INDENT# return zone #NEWLINE# #UNINDENT# raise KeyError #NEWLINE# #UNINDENT# self . dnsserver . get_zone . side_effect = get_zone #NEWLINE# rv = self . resource . getChild ( 'foo' , None ) #NEWLINE# self . assert_ ( isinstance ( rv , DomainResource ) ) #NEWLINE# self . assertEqual ( get_zone . zone , zone ) #NEWLINE# rv = self . resource . getChild ( 'bar' , None ) #NEWLINE# self . assert_ ( isinstance ( rv , MissingDomainResource ) ) #NEWLINE# self . assertEqual ( rv . name , 'bar' )