def test_verbosity(self): stdout = StringIO() call_command('createtenant', 'tenant', stdout=stdout, verbosity=3) tenant = Tenant.objects.get(name='tenant') stdout.seek(0) connection = connections[tenant._state.db] try: if connection.vendor == 'postgresql': self.assertIn(tenant.db_schema, stdout.readline()) for model in TenantModelBase.references: if not model._meta.proxy and not model._meta.auto_created: self.assertIn(model._meta.object_name, stdout.readline()) self.assertIn(model._meta.db_table, stdout.readline()) for m2m in model._meta.many_to_many: through_opts = get_remote_field(m2m).through._meta if through_opts.auto_created: self.assertIn(through_opts.db_table, stdout.readline()) finally: tenant.delete()
def get_through_managed(name): field = RelatedTenantModel._meta.get_field(name) return get_remote_field(field).through._meta.managed