def inner(self, *args, **kwargs): activate_template_schema() test(self, *args, schema='__template__', **kwargs) for schema in Schema.objects.all(): schema.activate() test(self, *args, schema=schema.schema, **kwargs) deactivate_schema()
def serialize_db_to_string(self): from boardinghouse.schema import activate_template_schema, deactivate_schema activate_template_schema() result = super(DatabaseCreation, self).serialize_db_to_string() deactivate_schema() return result
def test_activate_schema_sets_search_path(self): schema = Schema.objects.create(name='a', schema='a') schema.activate() self.assertEqual(schema.schema, get_active_schema_name()) activate_template_schema() self.assertEqual('__template__', _get_search_path())
def test_activate_schema_sets_search_path(self): schema = Schema.objects.create(name="a", schema="a") schema.activate() self.assertEqual(schema.schema, get_active_schema_name()) activate_template_schema() self.assertEqual("__template__", _get_search_path())
def test_schema_creation_clones_template(self): activate_template_schema() cursor = connection.cursor() cursor.execute("CREATE TABLE foo (id SERIAL NOT NULL PRIMARY KEY)") Schema.objects.create(name="Duplicate", schema='duplicate') cursor.execute(TABLE_QUERY, ['duplicate', 'foo']) data = cursor.fetchone() self.assertEqual(('foo',), data) cursor.close()
def test_schema_creation_clones_template(self): activate_template_schema() cursor = connection.cursor() cursor.execute("CREATE TABLE foo (id SERIAL NOT NULL PRIMARY KEY)") Schema.objects.create(name="Duplicate", schema="duplicate") cursor.execute(TABLE_QUERY, ["duplicate", "foo"]) data = cursor.fetchone() self.assertEqual(("foo",), data) cursor.close()
def test_exception_when_no_template_schema_found(self): with self.assertRaises(Exception): activate_template_schema()
def execute_on_template_schema(sender, db_table, function, **kwargs): activate_template_schema() function(*kwargs.get('args', []), **kwargs.get('kwargs', {}))
def deserialize_db_from_string(self, data): from boardinghouse.schema import activate_template_schema, deactivate_schema activate_template_schema() super(DatabaseCreation, self).deserialize_db_from_string(data) deactivate_schema()