def test_contrib_models(self):
        from django.contrib.admin.models import LogEntry
        from django.contrib.auth.models import User, Group, Permission

        self.assertTrue(is_shared_model(User()))
        self.assertTrue(is_shared_model(Permission()))
        self.assertTrue(is_shared_model(Group()))
        self.assertTrue(is_shared_model(LogEntry()))
    def test_contrib_models(self):
        from django.contrib.admin.models import LogEntry
        from django.contrib.auth.models import User, Group, Permission

        self.assertTrue(is_shared_model(User()))
        self.assertTrue(is_shared_model(Permission()))
        self.assertTrue(is_shared_model(Group()))
        self.assertTrue(is_shared_model(LogEntry()))
Пример #3
0
def inject_schema_attribute(sender, instance, **kwargs):
    """
    A signal listener that injects the current schema on the object
    just after it is instantiated.

    You may use this in conjunction with :class:`MultiSchemaMixin`, it will
    respect any value that has already been set on the instance.
    """
    if is_shared_model(sender):
        return
    if not getattr(instance, '_schema', None):
        instance._schema = get_active_schema_name()
 def test_co_referential_models(self):
     self.assertFalse(is_shared_model(CoReferentialModelA()))
     self.assertFalse(is_shared_model(CoReferentialModelB()))
 def test_self_referential_model(self):
     self.assertFalse(is_shared_model(SelfReferentialModel()))
 def test_naive_model(self):
     self.assertTrue(is_shared_model(NaiveModel()))
 def test_aware_model(self):
     self.assertFalse(is_shared_model(AwareModel()))
Пример #8
0
 def test_model_in_shared_models_is_shared(self):
     self.assertTrue(is_shared_model(SettingsSharedModel))
 def test_ensure_schema_model_is_not_schema_aware(self):
     self.assertTrue(is_shared_model(Schema))
     self.assertTrue(is_shared_model(Schema()))
 def test_prefix(self):
     self.assertFalse(is_shared_model(ModelA))
     self.assertFalse(is_shared_model(ModelB))
     self.assertFalse(is_shared_model(ModelBPrefix))
 def test_co_referential_models(self):
     self.assertFalse(is_shared_model(CoReferentialModelA()))
     self.assertFalse(is_shared_model(CoReferentialModelB()))
 def test_self_referential_model(self):
     self.assertFalse(is_shared_model(SelfReferentialModel()))
 def test_naive_model(self):
     self.assertTrue(is_shared_model(NaiveModel()))
 def test_aware_model(self):
     self.assertFalse(is_shared_model(AwareModel()))
Пример #15
0
 def test_model_in_private_models_is_not_shared(self):
     self.assertFalse(is_shared_model(SettingsPrivateModel))
 def test_prefix(self):
     self.assertFalse(is_shared_model(ModelA))
     self.assertFalse(is_shared_model(ModelB))
     self.assertFalse(is_shared_model(ModelBPrefix))
 def test_ensure_schema_model_is_not_schema_aware(self):
     self.assertTrue(is_shared_model(Schema))
     self.assertTrue(is_shared_model(Schema()))