Beispiel #1
0
    def test_sync_successful(self, mock_pool_create, mock_pool_update,
                             mock_pool_del, mock_pool_get_all, mock_list_pools,
                             get_lock):
        pool_obj = resources.StoragePoolTask(
            context, 'c5c91c98-91aa-40e6-85ac-37a1d3b32bda')
        pool_obj.sync()

        self.assertTrue(mock_list_pools.called)
        self.assertTrue(mock_pool_get_all.called)
        self.assertTrue(get_lock.called)

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

        # add the new pool to DB
        mock_list_pools.return_value = fake_storage_obj.list_storage_pools(
            context)
        mock_pool_get_all.return_value = list()
        pool_obj.sync()
        self.assertTrue(mock_pool_create.called)

        # update the new pool of DB
        mock_list_pools.return_value = pools_list
        mock_pool_get_all.return_value = pools_list
        pool_obj.sync()
        self.assertTrue(mock_pool_update.called)

        # delete the new pool to DB
        mock_list_pools.return_value = list()
        mock_pool_get_all.return_value = pools_list
        pool_obj.sync()
        self.assertTrue(mock_pool_del.called)
Beispiel #2
0
 def test_remove(self, mock_pool_del):
     pool_obj = resources.StoragePoolTask(
         context, 'c5c91c98-91aa-40e6-85ac-37a1d3b32bda')
     pool_obj.remove()
     self.assertTrue(mock_pool_del.called)