# 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: tests/models.py
# class AwareModel(models.Model):
#     name = models.CharField(max_length=10, unique=True)
#     status = models.BooleanField(default=False)
#     factor = models.PositiveSmallIntegerField(default=7)
# 
#     objects = MultiSchemaManager()


from django.test import TestCase
from boardinghouse.schema import get_schema_model
from ..models import AwareModel


Schema = get_schema_model()


class TestMultiSchemaManager(TestCase):
    def test_multi_schema_fetches_objects_correctly(self):
        Schema.objects.mass_create('a', 'b')

        a = Schema.objects.get(name='a')
        a.activate()
        AwareModel.objects.create(name='foo')
        AwareModel.objects.create(name='bar')
        AwareModel.objects.create(name='baz')

        b = Schema.objects.get(name='b')
        b.activate()
        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: tests/models.py
# class AwareModel(models.Model):
#     name = models.CharField(max_length=10, unique=True)
#     status = models.BooleanField(default=False)
#     factor = models.PositiveSmallIntegerField(default=7)
# 
#     objects = MultiSchemaManager()


# Path: tests/tests/test_multi_schema_manager.py
from django.test import TestCase
from boardinghouse.schema import get_schema_model
from ..models import AwareModel



Schema = get_schema_model()


class TestMultiSchemaManager(TestCase):
    def test_multi_schema_fetches_objects_correctly(self):
        Schema.objects.mass_create('a', 'b')

        a = Schema.objects.get(name='a')
        a.activate()
        AwareModel.objects.create(name='foo')
        AwareModel.objects.create(name='bar')
        AwareModel.objects.create(name='baz')

        b = Schema.objects.get(name='b')
        b.activate()
        AwareModel.objects.create(name='foo')

        AwareModel.objects.create(name='bar')