# Path: boardinghouse/schema.py
# def get_schema_model():
#     """
#     Return the class that is currently set as the schema model.
#     """
#     try:
#         return apps.get_model(settings.BOARDINGHOUSE_SCHEMA_MODEL)
#     except AttributeError:
#         raise ImproperlyConfigured("BOARDINGHOUSE_SCHEMA_MODEL is not set: is 'boardinghouse' in your INSTALLED_APPS?")
#     except ValueError:
#         raise ImproperlyConfigured("BOARDINGHOUSE_SCHEMA_MODEL must be of the form 'app_label.model_name'")
#     except LookupError:
#         raise ImproperlyConfigured(
#             "BOARDINGHOUSE_SCHEMA_MODEL refers to model '{0!s}' that has not been installed".format(
#                 settings.BOARDINGHOUSE_SCHEMA_MODEL))
# 
# Path: boardinghouse/contrib/template/models.py
# class SchemaTemplate(SharedSchemaMixin, models.Model):
#     """
#     A ``boardinghouse.contrib.template.models.SchemaTemplate`` can be used
#     for creating a new schema complete with some initial data.
#     """
#     template_schema_id = models.AutoField(primary_key=True)
#     name = models.CharField(max_length=128, unique=True)
#     is_active = models.BooleanField(default=True)
#     description = models.TextField(null=True, blank=True)
# 
#     objects = SchemaTemplateQuerySet.as_manager()
# 
#     class Meta:
#         default_permissions = ('add', 'change', 'delete', 'view', 'activate', 'clone')
#         verbose_name = lazy(verbose_name, six.text_type)()
#         verbose_name_plural = lazy(verbose_name_plural, six.text_type)()
# 
#     def __str__(self):
#         return self.name
# 
#     @property
#     def schema(self):
#         return '{0}{1}'.format(settings.BOARDINGHOUSE_TEMPLATE_PREFIX, self.pk)
# 
#     def activate(self):
#         activate_schema(self.schema)
# 
#     def deactivate(self):
#         deactivate_schema()
# 
# Path: tests/models.py
# class AwareModel(models.Model):
# class NaiveModel(SharedSchemaModel):
# class SelfReferentialModel(models.Model):
# class CoReferentialModelA(models.Model):
# class CoReferentialModelB(models.Model):
# class ModelA(models.Model):
# class ModelB(models.Model):
# class ModelBPrefix(models.Model):
# class SettingsSharedModel(models.Model):
# class SettingsPrivateModel(models.Model):
# class ViewBackedModel(models.Model):
#     class Meta:


from django.contrib import admin
from django.contrib.admin.models import LogEntry, ADDITION
from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentType
    from django.urls import reverse
    from django.core.urlresolvers import reverse
from django.test import TestCase, modify_settings
from django.utils import six
from boardinghouse.schema import get_schema_model
from boardinghouse.contrib.template.models import SchemaTemplate
from ..models import AwareModel, NaiveModel, User
        from boardinghouse.admin import schemata

        User.objects.create_superuser(
            username="su",
            password="su",
            email="su@example.com"
        )

        self.client.login(username='su', password='su')

        response = self.client.get(reverse('admin:tests_awaremodel_changelist'))
        # Should we handle this, and provide feedback?
        self.assertEqual(302, response.status_code)

    def test_schemata_list(self):

        user = User.objects.create_user(
            username='user', password='password', email='user@example.com'
        )
        Schema.objects.mass_create('a', 'b', 'c')
        self.assertEqual('', schemata(user))

        user.schemata.add(*Schema.objects.all())
        self.assertEqual(set(['a', 'b', 'c']), set(schemata(user).split('<br>')))

    def test_admin_log_includes_schema(self):
        Schema.objects.mass_create('a')
        schema = Schema.objects.get(name='a')
        schema.activate()

        aware = AwareModel.objects.create(name='foo')

# Path: boardinghouse/schema.py
# def get_schema_model():
#     """
#     Return the class that is currently set as the schema model.
#     """
#     try:
#         return apps.get_model(settings.BOARDINGHOUSE_SCHEMA_MODEL)
#     except AttributeError:
#         raise ImproperlyConfigured("BOARDINGHOUSE_SCHEMA_MODEL is not set: is 'boardinghouse' in your INSTALLED_APPS?")
#     except ValueError:
#         raise ImproperlyConfigured("BOARDINGHOUSE_SCHEMA_MODEL must be of the form 'app_label.model_name'")
#     except LookupError:
#         raise ImproperlyConfigured(
#             "BOARDINGHOUSE_SCHEMA_MODEL refers to model '{0!s}' that has not been installed".format(
#                 settings.BOARDINGHOUSE_SCHEMA_MODEL))
# 
# Path: boardinghouse/contrib/template/models.py
# class SchemaTemplate(SharedSchemaMixin, models.Model):
#     """
#     A ``boardinghouse.contrib.template.models.SchemaTemplate`` can be used
#     for creating a new schema complete with some initial data.
#     """
#     template_schema_id = models.AutoField(primary_key=True)
#     name = models.CharField(max_length=128, unique=True)
#     is_active = models.BooleanField(default=True)
#     description = models.TextField(null=True, blank=True)
# 
#     objects = SchemaTemplateQuerySet.as_manager()
# 
#     class Meta:
#         default_permissions = ('add', 'change', 'delete', 'view', 'activate', 'clone')
#         verbose_name = lazy(verbose_name, six.text_type)()
#         verbose_name_plural = lazy(verbose_name_plural, six.text_type)()
# 
#     def __str__(self):
#         return self.name
# 
#     @property
#     def schema(self):
#         return '{0}{1}'.format(settings.BOARDINGHOUSE_TEMPLATE_PREFIX, self.pk)
# 
#     def activate(self):
#         activate_schema(self.schema)
# 
#     def deactivate(self):
#         deactivate_schema()
# 
# Path: tests/models.py
# class AwareModel(models.Model):
# class NaiveModel(SharedSchemaModel):
# class SelfReferentialModel(models.Model):
# class CoReferentialModelA(models.Model):
# class CoReferentialModelB(models.Model):
# class ModelA(models.Model):
# class ModelB(models.Model):
# class ModelBPrefix(models.Model):
# class SettingsSharedModel(models.Model):
# class SettingsPrivateModel(models.Model):
# class ViewBackedModel(models.Model):
#     class Meta:


# Path: tests/tests/test_admin.py
from django.contrib import admin
from django.contrib.admin.models import LogEntry, ADDITION
from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentType
    from django.urls import reverse
    from django.core.urlresolvers import reverse
from django.test import TestCase, modify_settings
from django.utils import six
from boardinghouse.schema import get_schema_model
from boardinghouse.contrib.template.models import SchemaTemplate
from ..models import AwareModel, NaiveModel, User
        from boardinghouse.admin import schemata


        User.objects.create_superuser(
            username="su",
            password="su",
            email="su@example.com"
        )

        self.client.login(username='su', password='su')

        response = self.client.get(reverse('admin:tests_awaremodel_changelist'))
        # Should we handle this, and provide feedback?
        self.assertEqual(302, response.status_code)

    def test_schemata_list(self):

        user = User.objects.create_user(
            username='user', password='password', email='user@example.com'
        )
        Schema.objects.mass_create('a', 'b', 'c')
        self.assertEqual('', schemata(user))

        user.schemata.add(*Schema.objects.all())
        self.assertEqual(set(['a', 'b', 'c']), set(schemata(user).split('<br>')))

    def test_admin_log_includes_schema(self):
        Schema.objects.mass_create('a')
        schema = Schema.objects.get(name='a')
        schema.activate()

        aware = AwareModel.objects.create(name='foo')

        user = User.objects.create_user(username='test', password='test')