#NEWLINE# def _test_get_registry_dhcp_server( self , dhcp_server , exception = None ) : #NEWLINE# #INDENT# fake_adapter = mock . sentinel . fake_adapter_name #NEWLINE# self . _moves_mock . winreg . QueryValueEx . return_value = [ dhcp_server ] #NEWLINE# if exception : #NEWLINE# #INDENT# self . _moves_mock . winreg . QueryValueEx . side_effect = [ exception ] #NEWLINE# if ( exception . errno != 2 ) : #NEWLINE# #INDENT# self . assertRaises ( cbinit_exception . CloudbaseInitException , self . network . _get_registry_dhcp_server , fake_adapter ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# response = self . network . _get_registry_dhcp_server ( fake_adapter ) #NEWLINE# if ( dhcp_server == '255.255.255.255' ) : #NEWLINE# #INDENT# self . assertEqual ( None , response ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . assertEqual ( dhcp_server , response ) #NEWLINE# #UNINDENT# self . _moves_mock . winreg . OpenKey . assert_called_once_with ( self . _moves_mock . winreg . HKEY_LOCAL_MACHINE , ( 'SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\%s' % fake_adapter ) , 0 , self . _moves_mock . winreg . KEY_READ ) #NEWLINE# self . _moves_mock . winreg . QueryValueEx . assert_called_once_with ( self . _moves_mock . winreg . OpenKey . return_value . __enter__ ( ) , 'DhcpServer' )