Esempio n. 1
0
 def test_network_absent(self):
     '''
     Test dockerng.network_absent
     '''
     dockerng_remove_network = Mock(return_value='removed')
     dockerng_disconnect_container_from_network = Mock(
         return_value='disconnected')
     __salt__ = {
         'dockerng.remove_network':
         dockerng_remove_network,
         'dockerng.disconnect_container_from_network':
         dockerng_disconnect_container_from_network,
         'dockerng.networks':
         Mock(return_value=[{
             'Containers': {
                 'container': {}
             }
         }]),
     }
     with patch.dict(dockerng_state.__dict__, {'__salt__': __salt__}):
         ret = dockerng_state.network_absent('network_foo', )
     dockerng_disconnect_container_from_network.assert_called_with(
         'container', 'network_foo')
     dockerng_remove_network.assert_called_with('network_foo')
     self.assertEqual(
         ret, {
             'name': 'network_foo',
             'comment': '',
             'changes': {
                 'disconnected': 'disconnected',
                 'removed': 'removed'
             },
             'result': True
         })
Esempio n. 2
0
 def test_network_absent(self):
     '''
     Test dockerng.network_absent
     '''
     dockerng_remove_network = Mock(return_value='removed')
     dockerng_disconnect_container_from_network = Mock(return_value='disconnected')
     __salt__ = {'dockerng.remove_network': dockerng_remove_network,
                 'dockerng.disconnect_container_from_network': dockerng_disconnect_container_from_network,
                 'dockerng.networks': Mock(return_value=[{'Containers': {'container': {}}}]),
                 }
     with patch.dict(dockerng_state.__dict__,
                     {'__salt__': __salt__}):
         ret = dockerng_state.network_absent(
             'network_foo',
             )
     dockerng_disconnect_container_from_network.assert_called_with('container',
                                                                   'network_foo')
     dockerng_remove_network.assert_called_with('network_foo')
     self.assertEqual(ret, {'name': 'network_foo',
                            'comment': '',
                            'changes': {'disconnected': 'disconnected',
                                        'removed': 'removed'},
                            'result': True})