Esempio n. 1
0
    def test_sync_successful(self, mock_disk_create, mock_disk_update,
                             mock_disk_del, mock_disk_get_all, mock_list_disks,
                             get_lock):
        disk_obj = resources.StorageDiskTask(
            context, 'c5c91c98-91aa-40e6-85ac-37a1d3b32bda')
        disk_obj.sync()
        self.assertTrue(mock_list_disks.called)
        self.assertTrue(mock_disk_get_all.called)
        self.assertTrue(get_lock.called)

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

        # add the disks to DB
        mock_list_disks.return_value = fake_storage_obj.list_disks(context)
        mock_disk_get_all.return_value = list()
        disk_obj.sync()
        self.assertTrue(mock_disk_create.called)

        # update the disks to DB
        mock_list_disks.return_value = disks_list
        mock_disk_get_all.return_value = disks_list
        disk_obj.sync()
        self.assertTrue(mock_disk_update.called)

        # delete the disks to DB
        mock_list_disks.return_value = list()
        mock_disk_get_all.return_value = disks_list
        disk_obj.sync()
        self.assertTrue(mock_disk_del.called)
Esempio n. 2
0
 def test_remove(self, mock_disk_del):
     disk_obj = resources.StorageDiskTask(
         context, 'c5c91c98-91aa-40e6-85ac-37a1d3b32bda')
     disk_obj.remove()
     self.assertTrue(mock_disk_del.called)