#NEWLINE# def test_network_present( self ) : #NEWLINE# #INDENT# '\n        Test dockerng.network_present\n        ' #NEWLINE# dockerng_create_network = Mock ( return_value = 'created' ) #NEWLINE# dockerng_connect_container_to_network = Mock ( return_value = 'connected' ) #NEWLINE# dockerng_inspect_container = Mock ( return_value = { #NEWLINE# #INDENT# 'Id' : 'abcd' , #NEWLINE# #UNINDENT# } ) #NEWLINE# __salt__ = { #NEWLINE# #INDENT# 'dockerng.create_network' : dockerng_create_network , #NEWLINE# 'dockerng.inspect_container' : dockerng_inspect_container , #NEWLINE# 'dockerng.connect_container_to_network' : dockerng_connect_container_to_network , #NEWLINE# 'dockerng.networks' : Mock ( return_value = [ ] ) , #NEWLINE# #UNINDENT# } #NEWLINE# with patch . dict ( dockerng_state . __dict__ , { #NEWLINE# #INDENT# '__salt__' : __salt__ , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# ret = dockerng_state . network_present ( 'network_foo' , containers = [ 'container' ] ) #NEWLINE# #UNINDENT# dockerng_create_network . assert_called_with ( 'network_foo' , driver = None ) #NEWLINE# dockerng_connect_container_to_network . assert_called_with ( 'abcd' , 'network_foo' ) #NEWLINE# self . assertEqual ( ret , { #NEWLINE# #INDENT# 'name' : 'network_foo' , #NEWLINE# 'comment' : '' , #NEWLINE# 'changes' : { #NEWLINE# #INDENT# 'connected' : 'connected' , #NEWLINE# 'created' : 'created' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'result' : True , #NEWLINE# #UNINDENT# } )