multitenant: show domain and schema in tenant object str method (#45343)

This commit is contained in:
Thomas NOËL 2020-07-22 09:34:32 +02:00
parent a8c3eaf395
commit ad23d09e3a
2 changed files with 7 additions and 2 deletions

View File

@ -20,7 +20,10 @@ class Tenant(TenantMixin):
pass
def __unicode__(self):
return u'%s' % self.schema_name
return u'Tenant %s (%s)' % (self.domain_url, self.schema_name)
def __str__(self):
return 'Tenant %s (%s)' % (self.domain_url, self.schema_name)
@classmethod
def base(cls):

View File

@ -116,7 +116,9 @@ def test_tenant_command_all_tenants_errors(tenants, monkeypatch, capsys):
with pytest.raises(SystemExit):
klass.run_from_argv(['manage.py', 'tenant_command', 'uni-error', '--all-tenants'])
captured = capsys.readouterr()
assert u'héhé' in captured.err
assert u'Tenant tenant1.example.net (tenant1_example_net): Exception: héhé' in captured.err
assert u'Tenant tenant2.example.net (tenant2_example_net): Exception: héhé' in captured.err
assert u'Command failed on multiple tenants' in captured.err
with pytest.raises(SystemExit):
klass.run_from_argv(['manage.py', 'tenant_command', 'bytes-error', '--all-tenants'])