# Path: boardinghouse/schema.py
# def is_shared_model(model):
#     """
#     Is the model (or instance of a model) one that should be in the
#     public/shared schema?
#     """
#     if model._is_shared_model:
#         return True
# 
#     app_model = '{m.app_label}.{m.model_name}'.format(m=model._meta).lower()
# 
#     # These should be case insensitive!
#     if app_model in REQUIRED_SHARED_MODELS:
#         return True
# 
#     if app_model in [x.lower() for x in settings.SHARED_MODELS]:
#         return True
# 
#     # Sometimes, we want a join table to be private.
#     if app_model in [x.lower() for x in settings.PRIVATE_MODELS]:
#         return False
# 
#     # if all fields are auto or fk, then we are a join model,
#     # and if all related objects are shared, then we must
#     # also be shared, unless we were explicitly marked as private
#     # above.
#     if _is_join_model(model):
#         return all(
#             is_shared_model(field.remote_field.model)
#             for field in model._meta.fields
#             if field.remote_field
#         )
# 
#     return False
# 
# Path: tests/models.py
# class SettingsSharedModel(models.Model):
#     pass
# 
# class SettingsPrivateModel(models.Model):
#     pass


from django.test import TestCase
from boardinghouse.schema import is_shared_model
from ..models import SettingsSharedModel, SettingsPrivateModel




class TestSettingsModels(TestCase):
    def test_model_in_shared_models_is_shared(self):
        self.assertTrue(is_shared_model(SettingsSharedModel))

    def test_model_in_private_models_is_not_shared(self):

# Path: boardinghouse/schema.py
# def is_shared_model(model):
#     """
#     Is the model (or instance of a model) one that should be in the
#     public/shared schema?
#     """
#     if model._is_shared_model:
#         return True
# 
#     app_model = '{m.app_label}.{m.model_name}'.format(m=model._meta).lower()
# 
#     # These should be case insensitive!
#     if app_model in REQUIRED_SHARED_MODELS:
#         return True
# 
#     if app_model in [x.lower() for x in settings.SHARED_MODELS]:
#         return True
# 
#     # Sometimes, we want a join table to be private.
#     if app_model in [x.lower() for x in settings.PRIVATE_MODELS]:
#         return False
# 
#     # if all fields are auto or fk, then we are a join model,
#     # and if all related objects are shared, then we must
#     # also be shared, unless we were explicitly marked as private
#     # above.
#     if _is_join_model(model):
#         return all(
#             is_shared_model(field.remote_field.model)
#             for field in model._meta.fields
#             if field.remote_field
#         )
# 
#     return False
# 
# Path: tests/models.py
# class SettingsSharedModel(models.Model):
#     pass
# 
# class SettingsPrivateModel(models.Model):
#     pass


# Path: tests/tests/test_settings_models.py
from django.test import TestCase
from boardinghouse.schema import is_shared_model
from ..models import SettingsSharedModel, SettingsPrivateModel





class TestSettingsModels(TestCase):
    def test_model_in_shared_models_is_shared(self):
        self.assertTrue(is_shared_model(SettingsSharedModel))

    def test_model_in_private_models_is_not_shared(self):

        self.assertFalse(is_shared_model(SettingsPrivateModel))