# Path: boardinghouse/schema.py
# LOGGER = logging.getLogger(__name__)
# REQUIRED_SHARED_MODELS = [
#     'auth.user',
#     'auth.permission',
#     'auth.group',
#     'boardinghouse.schema',
#     'sites.site',
#     'sessions.session',
#     'contenttypes.contenttype',
#     'admin.logentry',
#     'migrations.migration',
#     # In the case these are not the default values.
#     lazy(lambda: settings.BOARDINGHOUSE_SCHEMA_MODEL.lower())(),
#     lazy(lambda: settings.AUTH_USER_MODEL.lower())(),
# ]
# REQUIRED_SHARED_TABLES = [
#     'django_migrations',
# ]
# def get_schema_model():
# def _get_search_path():
# def _set_search_path(search_path):
# def _schema_exists(schema_name, cursor=None):
# def get_active_schema_name():
# def get_active_schema():
# def get_active_schemata():
# def _get_schema(schema_name):
# def activate_schema(schema_name):
# def activate_template_schema():
# def get_template_schema():
# def deactivate_schema(schema=None):
# def _is_join_model(model):
# def is_shared_model(model):
# def _get_models(apps, stack):
# def _get_join_model(table, table_map):
# def is_shared_table(table, apps=apps):
# def _table_exists(table_name, schema=None):
# def _schema_table_exists():


from django.test import TestCase
from django.db import connection
from django import forms
from django.utils import six
from boardinghouse.schema import (
    activate_schema, deactivate_schema,
    TemplateSchemaActivation,
    is_shared_model,
    get_active_schema_name,
    get_schema_model,
    activate_template_schema,
    _get_search_path,
)

class TestSchemaDrop(TestCase):
    def test_dropping_schema_model(self):
        Schema.objects.mass_create('a', 'b')
        Schema.objects.get(schema='a').delete(drop=True)
        self.assertEqual(['b'],
            list(Schema.objects.values_list('pk', flat=True)))
        cursor = connection.cursor()
        cursor.execute(SCHEMA_QUERY, ['a'])
        self.assertFalse(cursor.fetchone())

    def test_dropping_schema_queryset(self):
        Schema.objects.mass_create('a', 'b', 'c')
        Schema.objects.filter(schema__in=['b', 'c']).delete(drop=True)
        six.assertCountEqual(self, ['a'],
            Schema.objects.values_list('pk', flat=True))

    def test_delete_is_soft_by_default_model(self):
        Schema.objects.mass_create('a', 'b', 'c')
        Schema.objects.get(schema='b').delete()
        six.assertCountEqual(self, ['a', 'b', 'c'],
            Schema.objects.values_list('pk', flat=True))

        six.assertCountEqual(self, ['a', 'c'],
            Schema.objects.active().values_list('schema', flat=True))

    def test_delete_is_soft_by_default_queryset(self):
        Schema.objects.mass_create('a', 'b', 'c', 'd')
        Schema.objects.filter(schema__in=['b', 'd']).delete()
        self.assertSequenceEqual(['a', 'b', 'c', 'd'],

# Path: boardinghouse/schema.py
# LOGGER = logging.getLogger(__name__)
# REQUIRED_SHARED_MODELS = [
#     'auth.user',
#     'auth.permission',
#     'auth.group',
#     'boardinghouse.schema',
#     'sites.site',
#     'sessions.session',
#     'contenttypes.contenttype',
#     'admin.logentry',
#     'migrations.migration',
#     # In the case these are not the default values.
#     lazy(lambda: settings.BOARDINGHOUSE_SCHEMA_MODEL.lower())(),
#     lazy(lambda: settings.AUTH_USER_MODEL.lower())(),
# ]
# REQUIRED_SHARED_TABLES = [
#     'django_migrations',
# ]
# def get_schema_model():
# def _get_search_path():
# def _set_search_path(search_path):
# def _schema_exists(schema_name, cursor=None):
# def get_active_schema_name():
# def get_active_schema():
# def get_active_schemata():
# def _get_schema(schema_name):
# def activate_schema(schema_name):
# def activate_template_schema():
# def get_template_schema():
# def deactivate_schema(schema=None):
# def _is_join_model(model):
# def is_shared_model(model):
# def _get_models(apps, stack):
# def _get_join_model(table, table_map):
# def is_shared_table(table, apps=apps):
# def _table_exists(table_name, schema=None):
# def _schema_table_exists():


# Path: tests/tests/test_schema_creation.py
from django.test import TestCase
from django.db import connection
from django import forms
from django.utils import six
from boardinghouse.schema import (
    activate_schema, deactivate_schema,
    TemplateSchemaActivation,
    is_shared_model,
    get_active_schema_name,
    get_schema_model,
    activate_template_schema,
    _get_search_path,
)


class TestSchemaDrop(TestCase):
    def test_dropping_schema_model(self):
        Schema.objects.mass_create('a', 'b')
        Schema.objects.get(schema='a').delete(drop=True)
        self.assertEqual(['b'],
            list(Schema.objects.values_list('pk', flat=True)))
        cursor = connection.cursor()
        cursor.execute(SCHEMA_QUERY, ['a'])
        self.assertFalse(cursor.fetchone())

    def test_dropping_schema_queryset(self):
        Schema.objects.mass_create('a', 'b', 'c')
        Schema.objects.filter(schema__in=['b', 'c']).delete(drop=True)
        six.assertCountEqual(self, ['a'],
            Schema.objects.values_list('pk', flat=True))

    def test_delete_is_soft_by_default_model(self):
        Schema.objects.mass_create('a', 'b', 'c')
        Schema.objects.get(schema='b').delete()
        six.assertCountEqual(self, ['a', 'b', 'c'],
            Schema.objects.values_list('pk', flat=True))

        six.assertCountEqual(self, ['a', 'c'],
            Schema.objects.active().values_list('schema', flat=True))

    def test_delete_is_soft_by_default_queryset(self):
        Schema.objects.mass_create('a', 'b', 'c', 'd')
        Schema.objects.filter(schema__in=['b', 'd']).delete()
        self.assertSequenceEqual(['a', 'b', 'c', 'd'],

            list(Schema.objects.order_by('schema').values_list('pk', flat=True)))