

def test_domain_admins_limit(self):
    response = self.client.get(reverse('admin:identity_list'))
    self.assertContains(response, 'Domain admins (0%)')
    self.assertContains(response, 'Mailboxes (0%)')
    self.assertContains(response, 'Mailbox aliases (0%)')
    self._create_domain('domain.tld')
    self._create_account('admin1@domain.tld', role='DomainAdmins')
    self._check_limit('domain_admins', 1, 2)
    self._create_account('admin2@domain.tld', role='DomainAdmins')
    self._check_limit('domain_admins', 2, 2)
    resp = self._create_account('admin3@domain.tld', role='DomainAdmins', status=400)
    self.assertEqual(resp['form_errors']['role'][0], 'Select a valid choice. DomainAdmins is not one of the available choices.')
    self._check_limit('domain_admins', 2, 2)
    self.user.userobjectlimit_set.filter(name='mailboxes').update(max_value=3)
    self._create_account('user1@domain.tld')
    user = User.objects.get(username='user1@domain.tld')
    values = {
        'username': user.username,
        'role': 'DomainAdmins',
        'quota_act': True,
        'is_active': user.is_active,
        'email': user.email,
    }
    resp = self.ajax_post(reverse('admin:account_change', args=[user.id]), values, status=400)
    self.assertEqual(resp['form_errors']['role'][0], 'Select a valid choice. DomainAdmins is not one of the available choices.')
    self._check_limit('domain_admins', 2, 2)

dataset/ETHPy150Open tonioo/modoboa/modoboa/limits/tests/test_user_limits.py ResellerTestCase.test_domain_admins_limit/original