0001-apiclient-make-description-non-mandatory-69524.patch
src/authentic2/migrations/0043_api_client_description.py | ||
---|---|---|
1 |
# Generated by Django 2.2.26 on 2022-09-27 12:51 |
|
2 | ||
3 |
from django.db import migrations, models |
|
4 | ||
5 | ||
6 |
class Migration(migrations.Migration): |
|
7 | ||
8 |
dependencies = [ |
|
9 |
('authentic2', '0042_api_client'), |
|
10 |
] |
|
11 | ||
12 |
operations = [ |
|
13 |
migrations.AlterField( |
|
14 |
model_name='apiclient', |
|
15 |
name='description', |
|
16 |
field=models.TextField(blank=True, verbose_name='Description'), |
|
17 |
), |
|
18 |
] |
src/authentic2/models.py | ||
---|---|---|
636 | 636 | |
637 | 637 |
class APIClient(models.Model): |
638 | 638 |
name = models.CharField(max_length=128, verbose_name=_('Name')) |
639 |
description = models.TextField(verbose_name=_('Description')) |
|
639 |
description = models.TextField(verbose_name=_('Description'), blank=True)
|
|
640 | 640 |
identifier = models.CharField(max_length=256, verbose_name=_('Identifier')) |
641 | 641 |
password = models.CharField(max_length=256, verbose_name=_('Password')) |
642 | 642 |
restrict_to_anonymised_data = models.BooleanField( |
tests/test_manager.py | ||
---|---|---|
1377 | 1377 |
assert urlparse(response.request.url).path == api_client.get_absolute_url() |
1378 | 1378 | |
1379 | 1379 | |
1380 |
def test_manager_api_client_add_description_non_mandatory(superuser_or_admin, app): |
|
1381 |
assert APIClient.objects.count() == 0 |
|
1382 |
role_1 = Role.objects.create(name='role-1') |
|
1383 |
role_2 = Role.objects.create(name='role-2') |
|
1384 |
resp = login(app, superuser_or_admin, 'a2-manager-api-client-add') |
|
1385 |
form = resp.form |
|
1386 |
form.set('name', 'api-client-name') |
|
1387 |
form.set('identifier', 'api-client-identifier') |
|
1388 |
form.set('password', 'api-client-password') |
|
1389 |
form['apiclient_roles'].force_value([role_1.id, role_2.id]) |
|
1390 |
response = form.submit().follow() |
|
1391 |
assert APIClient.objects.count() == 1 |
|
1392 |
api_client = APIClient.objects.get(name='api-client-name') |
|
1393 |
assert set(api_client.apiclient_roles.all()) == {role_1, role_2} |
|
1394 |
assert urlparse(response.request.url).path == api_client.get_absolute_url() |
|
1395 | ||
1396 | ||
1380 | 1397 |
def test_manager_api_client_detail(superuser_or_admin, app): |
1381 | 1398 |
role_1 = Role.objects.create(name='role-1') |
1382 | 1399 |
role_2 = Role.objects.create(name='role-2') |
1383 |
- |