Esempio n. 1
0
    def test_sync_successful(self, mock_vol_create, mock_vol_update,
                             mock_vol_del, mock_vol_get_all, mock_list_vols,
                             get_lock):
        vol_obj = resources.StorageVolumeTask(
            context, 'c5c91c98-91aa-40e6-85ac-37a1d3b32bda')
        vol_obj.sync()
        self.assertTrue(mock_list_vols.called)
        self.assertTrue(mock_vol_get_all.called)
        self.assertTrue(get_lock.called)

        # collect the volumes from fake_storage
        fake_storage_obj = fake_storage.FakeStorageDriver()

        # add the volumes to DB
        mock_list_vols.return_value = fake_storage_obj.list_volumes(context)
        mock_vol_get_all.return_value = list()
        vol_obj.sync()
        self.assertTrue(mock_vol_create.called)

        # update the volumes to DB
        mock_list_vols.return_value = vols_list
        mock_vol_get_all.return_value = vols_list
        vol_obj.sync()
        self.assertTrue(mock_vol_update.called)

        # delete the volumes to DB
        mock_list_vols.return_value = list()
        mock_vol_get_all.return_value = vols_list
        vol_obj.sync()
        self.assertTrue(mock_vol_del.called)
Esempio n. 2
0
 def test_remove(self, mock_vol_del):
     vol_obj = resources.StorageVolumeTask(
         context, 'c5c91c98-91aa-40e6-85ac-37a1d3b32bda')
     vol_obj.remove()
     self.assertTrue(mock_vol_del.called)