def test_submit_changeset(self): self.create_test_db() self.server_test = servers_models.Server.objects.create( name='test', hostname=settings.TEST_DB_HOST if settings.TEST_DB_HOST else 'localhost', environment=servers_models.Environment.objects.get(name='test')) conn_opts = self.get_test_db_connection_options() self.schema_version, created = schema_functions.generate_schema_version( self.server_test, settings.TEST_DB_NAME, connection_options=conn_opts ) print 'schema_version = %s' % self.schema_version print 'schema_version.database_schema = %s' % self.schema_version.database_schema changeset = models.Changeset( database_schema=self.schema_version.database_schema, type=models.Changeset.DDL_TABLE_CREATE, classification=models.Changeset.CLASSIFICATION_PAINLESS, ) changeset_detail = models.ChangesetDetail( description = 'create table t01', apply_sql = 'create table t01 (id int)', revert_sql = 'drop table t01' ) changeset = changeset_functions.submit_changeset( from_form=False, submitted_by=self.user_dev01, changeset=changeset, changeset_detail_list=[changeset_detail], unit_testing=True) print 'changeset = %s' % changeset self.assertTrue(changeset.pk is not None) self.assertEqual(changeset.submitted_by, self.user_dev01) self.assertTrue(changeset.submitted_at is not None) changeset_actions = models.ChangesetAction.objects.filter( changeset=changeset).order_by('-id') self.assertTrue(changeset_actions.exists()) changeset_action = changeset_actions[0] self.assertEqual( changeset_action.type, models.ChangesetAction.TYPE_CREATED)
def setUp(self): self.user_admin = users_models.User.objects.get(name='admin') self.user_dba01 = users_models.User.objects.get(name='dba01') self.user_dba02 = users_models.User.objects.get(name='dba02') self.user_dev01 = users_models.User.objects.get(name='dev01') self.user_dev02 = users_models.User.objects.get(name='dev02') self.create_test_db() self.server_test = servers_models.Server.objects.create( name='test', hostname=settings.TEST_DB_HOST if settings.TEST_DB_HOST else 'localhost', environment=servers_models.Environment.objects.get(name='test')) conn_opts = self.get_test_db_connection_options() self.schema_version, created = schema_functions.generate_schema_version( self.server_test, settings.TEST_DB_NAME, connection_options=conn_opts )