def test_bulk_create_creates_schemata(self): schemata = ['first', 'second', 'third'] Schema.objects.mass_create(*schemata) cursor = connection.cursor() for schema in schemata: activate_schema(schema) cursor.execute(SCHEMA_QUERY, [schema]) data = cursor.fetchone() self.assertEqual((schema,), data) cursor.close()
def test_bulk_create_creates_schemata(self): schemata = ["first", "second", "third"] Schema.objects.mass_create(*schemata) cursor = connection.cursor() for schema in schemata: activate_schema(schema) cursor.execute(SCHEMA_QUERY, [schema]) data = cursor.fetchone() self.assertEqual((schema,), data) cursor.close()
def test_activate_schema_function(self): self.assertRaises(TemplateSchemaActivation, activate_schema, '__template__') Schema.objects.mass_create('a', 'b') activate_schema('a') self.assertEqual('a', get_active_schema_name()) activate_schema('b') self.assertEqual('b', get_active_schema_name()) deactivate_schema() self.assertEqual(None, get_active_schema_name())
def test_activate_schema_function(self): self.assertRaises(TemplateSchemaActivation, activate_schema, "__template__") Schema.objects.mass_create("a", "b") activate_schema("a") self.assertEqual("a", get_active_schema_name()) activate_schema("b") self.assertEqual("b", get_active_schema_name()) deactivate_schema() self.assertEqual(None, get_active_schema_name())
def test_deleting_schema_removes_it_from_session(self): schema = Schema.objects.mass_create('a')[0] user = User.objects.create_user(**CREDENTIALS) user.schemata.add(schema) self.client.login(**CREDENTIALS) self.client.post('/__change_schema__/a/') self.assertTrue('a', self.client.session['schema']) schema.delete(drop=True) self.assertEqual(0, Schema.objects.count()) with self.assertRaises(SchemaNotFound): activate_schema('a') self.client.get('/') self.assertFalse('schema' in self.client.session)
def activate_schema_view(request, schema): # Don't do this. activate_schema(schema) return HttpResponse(schema)
def activate(self): activate_schema(self.schema)
def activate(self): if self.expired: raise DemoSchemaExpired() activate_schema(self.schema)