예제 #1
0
 def test_snapshot_network_error(self, mcompress, mexecute, mget):
     objs = [
         {
             "type": "file",
             "path": "/remote_file1",
             "host": {
                 "address": "remote_host1"
             },
         },
         {
             "type": "dir",
             "path": "/remote_dir1",
             "host": {
                 "address": "remote_host1"
             },
         },
         {
             "type": "file",
             "path": "/remote_file1",
             "host": {
                 "address": "remote_host2"
             },
         },
     ]
     drv = mock.MagicMock()
     drv.snapshot.side_effect = [
         fabric.exceptions.NetworkError,
         None,
         fabric.exceptions.NetworkError,
         None,
         None,
     ]
     mget.return_value = drv
     conf = Config()
     conf.objs = deque(objs)
     offline_obj = {
         'path': '/remote_file1',
         'host': {
             'address': 'remote_host1'
         },
         'type': 'offline',
     }
     processed_obj = {
         'path': '/remote_file1',
         'host': {
             'address': 'remote_host2'
         },
         'type': 'file',
     }
     manager = Manager(conf)
     manager.snapshot()
     mget.assert_has_calls([
         mock.call(offline_obj, conf),
         mock.call(processed_obj, conf),
         mock.call(offline_obj, conf),
         mock.call(offline_obj, conf)
     ],
                           any_order=True)
     mexecute.assert_called_once_with('rm -rf /tmp')
예제 #2
0
 def test_snapshot_network_error(self, mcompress, mexecute, mget):
     objs = [
         {"type": "file",
          "path": "/remote_file1",
          "host": {"address": "remote_host1"},
          },
         {"type": "dir",
          "path": "/remote_dir1",
          "host": {"address": "remote_host1"},
          },
         {"type": "file",
          "path": "/remote_file1",
          "host": {"address": "remote_host2"},
          },
     ]
     drv = mock.MagicMock()
     drv.snapshot.side_effect = [
         fabric.exceptions.NetworkError,
         None,
         fabric.exceptions.NetworkError,
         None,
         None,
     ]
     mget.return_value = drv
     conf = Config()
     conf.objs = deque(objs)
     offline_obj = {
         'path': '/remote_file1',
         'host': {'address': 'remote_host1'},
         'type': 'offline',
     }
     processed_obj = {
         'path': '/remote_file1',
         'host': {'address': 'remote_host2'},
         'type': 'file',
     }
     manager = Manager(conf)
     manager.snapshot()
     mget.assert_has_calls([mock.call(offline_obj, conf),
                            mock.call(processed_obj, conf),
                            mock.call(offline_obj, conf),
                            mock.call(offline_obj, conf)], any_order=True)
     mexecute.assert_called_once_with('rm -rf /tmp')