0013-misc-fix-len-as-condition-pylint-error-56982.patch
src/authentic2/api_views.py | ||
---|---|---|
1001 | 1001 |
except User.DoesNotExist: |
1002 | 1002 |
raise ValidationError(_('No known user for UUID %s') % entry['uuid']) |
1003 | 1003 | |
1004 |
if not len(self.members) and request.method in ('POST', 'DELETE'):
|
|
1004 |
if not self.members and request.method in ('POST', 'DELETE'):
|
|
1005 | 1005 |
raise ValidationError(_('No valid user UUID')) |
1006 | 1006 | |
1007 | 1007 |
def post(self, request, *args, **kwargs): |
src/authentic2/middleware.py | ||
---|---|---|
233 | 233 |
return response |
234 | 234 |
# Check if there is some messages to show |
235 | 235 |
storage = messages.get_messages(request) |
236 |
if not len(storage):
|
|
236 |
if not storage:
|
|
237 | 237 |
return response |
238 | 238 |
return utils_misc.redirect(request, 'continue', resolve=True, params={'next': url}) |
239 | 239 |
src/authentic2/views.py | ||
---|---|---|
1496 | 1496 |
self.only_info = True |
1497 | 1497 | |
1498 | 1498 |
storage = messages.get_messages(request) |
1499 |
if not len(storage):
|
|
1499 |
if not storage:
|
|
1500 | 1500 |
return utils_misc.redirect(request, self.url, resolve=False) |
1501 | 1501 | |
1502 | 1502 |
for message in storage: |
tests/test_api.py | ||
---|---|---|
455 | 455 | |
456 | 456 |
resp = app.get('/api/users/?q=some') |
457 | 457 |
results = resp.json['results'] |
458 |
assert not len(results)
|
|
458 |
assert len(results) == 0
|
|
459 | 459 | |
460 | 460 | |
461 | 461 |
def test_api_member_users_list_search_text(app, superuser, simple_role): |
... | ... | |
1304 | 1304 |
def test_api_delete_role(app, admin_ou1, role_ou1): |
1305 | 1305 |
app.authorization = ('Basic', (admin_ou1.username, admin_ou1.username)) |
1306 | 1306 |
app.delete(f'/api/roles/{role_ou1.uuid}/') |
1307 |
assert not len(Role.objects.filter(slug='role_ou1'))
|
|
1307 |
assert not Role.objects.filter(slug='role_ou1').exists()
|
|
1308 | 1308 |
assert_event('manager.role.deletion', user=admin_ou1, api=True, role_name=role_ou1.name) |
1309 | 1309 | |
1310 | 1310 | |
... | ... | |
1338 | 1338 |
app.patch_json(f'/api/roles/{role_ou1.uuid}/', params=role_data, status=404) |
1339 | 1339 |
role_ou1.refresh_from_db() |
1340 | 1340 |
assert role_ou1.slug == 'role_ou1' |
1341 |
assert not len(Role.objects.filter(slug='updated-role'))
|
|
1341 |
assert not Role.objects.filter(slug='updated-role').exists()
|
|
1342 | 1342 | |
1343 | 1343 | |
1344 | 1344 |
def test_api_put_role(app, admin_ou1, role_ou1, ou1): |
... | ... | |
1484 | 1484 |
role_data = {'slug': 'mocca-manager', 'name': 'Mocca Manager', 'ou': 'ou1'} |
1485 | 1485 | |
1486 | 1486 |
app.post_json('/api/roles/', params=role_data, status=403) |
1487 |
assert not len(Role.objects.filter(slug='mocca-manager'))
|
|
1487 |
assert not Role.objects.filter(slug='mocca-manager').exists()
|
|
1488 | 1488 | |
1489 | 1489 | |
1490 | 1490 |
def test_api_get_role_description(app, admin_rando_role, role_random): |
tests/test_views.py | ||
---|---|---|
56 | 56 | |
57 | 57 |
def test_account_delete(app, simple_user, mailoutbox): |
58 | 58 |
assert simple_user.is_active |
59 |
assert not len(mailoutbox)
|
|
59 |
assert len(mailoutbox) == 0
|
|
60 | 60 |
page = login(app, simple_user, path=reverse('delete_account')) |
61 | 61 |
assert simple_user.email in page.text |
62 | 62 |
page.form.submit(name='submit').follow() |
... | ... | |
80 | 80 | |
81 | 81 |
def test_account_delete_when_logged_out(app, simple_user, mailoutbox): |
82 | 82 |
assert simple_user.is_active |
83 |
assert not len(mailoutbox)
|
|
83 |
assert len(mailoutbox) == 0
|
|
84 | 84 |
page = login(app, simple_user, path=reverse('delete_account')) |
85 | 85 |
page.form.submit(name='submit').follow() |
86 | 86 |
assert len(mailoutbox) == 1 |
... | ... | |
104 | 104 |
def test_account_delete_by_other_user(app, simple_user, user_ou1, mailoutbox): |
105 | 105 |
assert simple_user.is_active |
106 | 106 |
assert user_ou1.is_active |
107 |
assert not len(mailoutbox)
|
|
107 |
assert len(mailoutbox) == 0
|
|
108 | 108 |
page = login(app, simple_user, path=reverse('delete_account')) |
109 | 109 |
page.form.submit(name='submit').follow() |
110 | 110 |
assert len(mailoutbox) == 1 |
111 |
- |