#NEWLINE# def test_removal_of_parameter_is_detected( self ) : #NEWLINE# #INDENT# '\n        Test dockerng.running with deleted parameter.\n\n        1. define your sls\n\n        .. code-block:: yaml\n\n            container:\n                dockerng.running:\n                    - name: super-container\n                    - binds:\n                        - /path:/path:ro\n\n        2. run state.highstate\n\n        3. modify your sls by removing `- binds:`\n\n        .. code-block:: yaml\n\n            container:\n                dockerng.running:\n                    - name: super-container\n\n        4. enjoy your new created container without mounted volumes.\n        ' #NEWLINE# image_id = 'abcdefg' #NEWLINE# dockerng_create = Mock ( return_value = True ) #NEWLINE# dockerng_start = Mock ( ) #NEWLINE# dockerng_list_containers = Mock ( return_value = [ 'cont' ] ) #NEWLINE# dockerng_inspect_container = Mock ( side_effect = [ { #NEWLINE# #INDENT# 'Config' : { #NEWLINE# #INDENT# 'Image' : 'image:latest' , #NEWLINE# 'Tty' : False , #NEWLINE# 'Labels' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# 'Domainname' : '' , #NEWLINE# 'User' : '' , #NEWLINE# 'AttachStderr' : True , #NEWLINE# 'AttachStdout' : True , #NEWLINE# 'Hostname' : 'saltstack-container' , #NEWLINE# 'Env' : [ ] , #NEWLINE# 'WorkingDir' : '/' , #NEWLINE# 'Cmd' : [ 'bash' ] , #NEWLINE# 'Volumes' : { #NEWLINE# #INDENT# '/path' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# 'Entrypoint' : None , #NEWLINE# 'ExposedPorts' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# 'OpenStdin' : False , #NEWLINE# #UNINDENT# } , #NEWLINE# 'HostConfig' : { #NEWLINE# #INDENT# 'PublishAllPorts' : False , #NEWLINE# 'Dns' : [ ] , #NEWLINE# 'Links' : None , #NEWLINE# 'CpusetCpus' : '' , #NEWLINE# 'RestartPolicy' : { #NEWLINE# #INDENT# 'MaximumRetryCount' : 0 , #NEWLINE# 'Name' : '' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'CapAdd' : None , #NEWLINE# 'NetworkMode' : 'default' , #NEWLINE# 'PidMode' : '' , #NEWLINE# 'MemorySwap' : 0 , #NEWLINE# 'ExtraHosts' : None , #NEWLINE# 'PortBindings' : None , #NEWLINE# 'LxcConf' : None , #NEWLINE# 'DnsSearch' : [ ] , #NEWLINE# 'Privileged' : False , #NEWLINE# 'Binds' : [ '/path:/path:ro' ] , #NEWLINE# 'Memory' : 0 , #NEWLINE# 'VolumesFrom' : None , #NEWLINE# 'CpuShares' : 0 , #NEWLINE# 'CapDrop' : None , #NEWLINE# #UNINDENT# } , #NEWLINE# 'NetworkSettings' : { #NEWLINE# #INDENT# 'MacAddress' : '00:00:00:00:00:01' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'Image' : image_id , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'Config' : { #NEWLINE# #INDENT# 'Image' : 'image:latest' , #NEWLINE# 'Tty' : False , #NEWLINE# 'Labels' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# 'Domainname' : '' , #NEWLINE# 'User' : '' , #NEWLINE# 'AttachStderr' : True , #NEWLINE# 'AttachStdout' : True , #NEWLINE# 'Hostname' : 'saltstack-container' , #NEWLINE# 'Env' : [ ] , #NEWLINE# 'WorkingDir' : '/' , #NEWLINE# 'Cmd' : [ 'bash' ] , #NEWLINE# 'Volumes' : { #NEWLINE# #INDENT# '/path' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# 'Entrypoint' : None , #NEWLINE# 'ExposedPorts' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# 'OpenStdin' : False , #NEWLINE# #UNINDENT# } , #NEWLINE# 'HostConfig' : { #NEWLINE# #INDENT# 'PublishAllPorts' : False , #NEWLINE# 'Dns' : [ ] , #NEWLINE# 'Links' : None , #NEWLINE# 'CpusetCpus' : '' , #NEWLINE# 'RestartPolicy' : { #NEWLINE# #INDENT# 'MaximumRetryCount' : 0 , #NEWLINE# 'Name' : '' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'CapAdd' : None , #NEWLINE# 'NetworkMode' : 'default' , #NEWLINE# 'PidMode' : '' , #NEWLINE# 'MemorySwap' : 0 , #NEWLINE# 'ExtraHosts' : None , #NEWLINE# 'PortBindings' : None , #NEWLINE# 'LxcConf' : None , #NEWLINE# 'DnsSearch' : [ ] , #NEWLINE# 'Privileged' : False , #NEWLINE# 'Binds' : None , #NEWLINE# 'Memory' : 0 , #NEWLINE# 'VolumesFrom' : None , #NEWLINE# 'CpuShares' : 0 , #NEWLINE# 'CapDrop' : None , #NEWLINE# #UNINDENT# } , #NEWLINE# 'NetworkSettings' : { #NEWLINE# #INDENT# 'MacAddress' : '00:00:00:00:00:01' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'Image' : image_id , #NEWLINE# #UNINDENT# } ] ) #NEWLINE# dockerng_inspect_image = MagicMock ( return_value = { #NEWLINE# #INDENT# 'Id' : image_id , #NEWLINE# 'Config' : { #NEWLINE# #INDENT# 'Hostname' : 'saltstack-container' , #NEWLINE# 'WorkingDir' : '/' , #NEWLINE# 'Cmd' : [ 'bash' ] , #NEWLINE# 'Volumes' : { #NEWLINE# #INDENT# '/path' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# 'Entrypoint' : None , #NEWLINE# 'ExposedPorts' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) #NEWLINE# __salt__ = { #NEWLINE# #INDENT# 'dockerng.list_containers' : dockerng_list_containers , #NEWLINE# 'dockerng.inspect_container' : dockerng_inspect_container , #NEWLINE# 'dockerng.inspect_image' : dockerng_inspect_image , #NEWLINE# 'dockerng.list_tags' : MagicMock ( ) , #NEWLINE# 'dockerng.pull' : MagicMock ( return_value = True ) , #NEWLINE# 'dockerng.state' : MagicMock ( side_effect = [ 'stopped' , 'running' ] ) , #NEWLINE# 'dockerng.rm' : MagicMock ( return_value = 'cont' ) , #NEWLINE# 'dockerng.create' : dockerng_create , #NEWLINE# 'dockerng.start' : dockerng_start , #NEWLINE# #UNINDENT# } #NEWLINE# with patch . dict ( dockerng_state . __dict__ , { #NEWLINE# #INDENT# '__salt__' : __salt__ , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# ret = dockerng_state . running ( 'cont' , image = 'image:latest' ) #NEWLINE# #UNINDENT# self . assertEqual ( ret , { #NEWLINE# #INDENT# 'name' : 'cont' , #NEWLINE# 'comment' : "Container 'cont' changed state.. Container 'cont' was replaced." , #NEWLINE# 'changes' : { #NEWLINE# #INDENT# 'diff' : { #NEWLINE# #INDENT# 'binds' : { #NEWLINE# #INDENT# 'new' : [ ] , #NEWLINE# 'old' : [ '/path:/path:ro' ] , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# 'image' : True , #NEWLINE# 'removed' : 'cont' , #NEWLINE# 'state' : { #NEWLINE# #INDENT# 'new' : 'running' , #NEWLINE# 'old' : 'stopped' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'added' : True , #NEWLINE# #UNINDENT# } , #NEWLINE# 'result' : True , #NEWLINE# #UNINDENT# } ) #NEWLINE# dockerng_create . assert_called_with ( 'image:latest' , validate_ip_addrs = False , validate_input = False , name = 'cont' , client_timeout = 60 )