예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #5
0
파일: migration.py 프로젝트: hsluoyz/patron
 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)
예제 #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)