#NEWLINE# def test_is_pid_cmdline_correct( self ) : #NEWLINE# #INDENT# fake_open = mock . mock_open ( read_data = 'no-such-process' ) #NEWLINE# with mock . patch . object ( linux_net , 'open' , fake_open , create = True ) : #NEWLINE# #INDENT# self . assertFalse ( linux_net . is_pid_cmdline_correct ( 1 , 'foo' ) , "foo should not be in 'no-such-process'" ) #NEWLINE# #UNINDENT# fake_open = mock . mock_open ( read_data = '/usr/sbin/dnsmasq --conf-file=/var/run/NetworkManager/dnsmasq.conf' ) #NEWLINE# with mock . patch . object ( linux_net , 'open' , fake_open , create = True ) : #NEWLINE# #INDENT# self . assertFalse ( linux_net . is_pid_cmdline_correct ( 1 , 'nova-br100.conf' ) , 'nova-br100.conf should not have been found' ) #NEWLINE# #UNINDENT# fake_open = mock . mock_open ( read_data = '/usr/sbin/dnsmasq --dhcp-hostsfile=/opt/stack/data/nova/networks/nova-br100.conf' ) #NEWLINE# with mock . patch . object ( linux_net , 'open' , fake_open , create = True ) : #NEWLINE# #INDENT# self . assertTrue ( linux_net . is_pid_cmdline_correct ( 1 , 'nova-br100.conf' ) , 'nova-br100.conf should have been found' ) #NEWLINE# #UNINDENT# for err in ( IOError , OSError ) : #NEWLINE# #INDENT# fake_open = mock . mock_open ( read_data = '/usr/sbin/dnsmasq --dhcp-hostsfile=/opt/stack/data/nova/networks/nova-br100.conf' ) #NEWLINE# fake_open . side_effect = err #NEWLINE# with mock . patch . object ( linux_net , 'open' , fake_open , create = True ) : #NEWLINE# #INDENT# self . assertFalse ( linux_net . is_pid_cmdline_correct ( 1 , 'nova-br100.conf' ) , 'nova-br100.conf should not have been found' )