Exemple #1
0
 def test_create(self):
     ctxt = context.get_admin_context()
     fake_migration = fake_db_migration()
     self.mox.StubOutWithMock(db, 'migration_create')
     db.migration_create(ctxt, {'source_compute': 'foo'}).AndReturn(
         fake_migration)
     self.mox.ReplayAll()
     mig = migration.Migration(context=ctxt)
     mig.source_compute = 'foo'
     mig.create()
     self.assertEqual(fake_migration['dest_compute'], mig.dest_compute)
Exemple #2
0
 def test_create(self):
     ctxt = context.get_admin_context()
     fake_migration = fake_db_migration()
     self.mox.StubOutWithMock(db, 'migration_create')
     db.migration_create(ctxt, {
         'source_compute': 'foo'
     }).AndReturn(fake_migration)
     self.mox.ReplayAll()
     mig = migration.Migration(context=ctxt)
     mig.source_compute = 'foo'
     mig.create()
     self.assertEqual(fake_migration['dest_compute'], mig.dest_compute)
Exemple #3
0
 def test_recreate_fails(self):
     ctxt = context.get_admin_context()
     fake_migration = fake_db_migration()
     self.mox.StubOutWithMock(db, 'migration_create')
     db.migration_create(ctxt, {'source_compute': 'foo'}).AndReturn(
         fake_migration)
     self.mox.ReplayAll()
     mig = migration.Migration(context=ctxt)
     mig.source_compute = 'foo'
     mig.create()
     self.assertRaises(exception.ObjectActionError, mig.create,
                       self.context)
Exemple #4
0
 def test_recreate_fails(self):
     ctxt = context.get_admin_context()
     fake_migration = fake_db_migration()
     self.mox.StubOutWithMock(db, 'migration_create')
     db.migration_create(ctxt, {
         'source_compute': 'foo'
     }).AndReturn(fake_migration)
     self.mox.ReplayAll()
     mig = migration.Migration(context=ctxt)
     mig.source_compute = 'foo'
     mig.create()
     self.assertRaises(exception.ObjectActionError, mig.create,
                       self.context)
Exemple #5
0
 def create(self):
     if self.obj_attr_is_set('id'):
         raise exception.ObjectActionError(action='create',
                                           reason='already created')
     updates = self.obj_get_changes()
     db_migration = db.migration_create(self._context, updates)
     self._from_db_object(self._context, self, db_migration)
Exemple #6
0
 def create(self):
     if self.obj_attr_is_set('id'):
         raise exception.ObjectActionError(action='create',
                                           reason='already created')
     updates = self.obj_get_changes()
     db_migration = db.migration_create(self._context, updates)
     self._from_db_object(self._context, self, db_migration)