Skip to content

Commit 644d219

Browse files
committed
Move imports to the top level
1 parent a142566 commit 644d219

File tree

3 files changed

+12
-20
lines changed

3 files changed

+12
-20
lines changed

qgis-app/plugins/tests/test_plugin_create_empty.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
import os
66
from unittest.mock import patch
77

8-
from django.contrib.auth.models import User
8+
from django.contrib.auth.models import User, Permission
9+
from django.contrib.contenttypes.models import ContentType
910
from django.core.files.uploadedfile import SimpleUploadedFile
1011
from django.test import Client, TestCase, override_settings
1112
from django.urls import reverse
1213
from plugins.forms import PluginCreateForm
13-
from plugins.models import Plugin, PluginVersion
14+
from plugins.models import Plugin
1415

1516

1617
def do_nothing(*args, **kwargs):
@@ -345,11 +346,8 @@ def test_version_create_auto_approved_for_trusted_user(self):
345346
A user with can_approve permission should have their uploaded version
346347
approved automatically via the version_create view.
347348
"""
348-
from django.contrib.auth.models import Permission
349-
from django.contrib.contenttypes.models import ContentType
350-
from plugins.models import Plugin as PluginModel
351349

352-
ct = ContentType.objects.get_for_model(PluginModel)
350+
ct = ContentType.objects.get_for_model(Plugin)
353351
perm = Permission.objects.get(codename="can_approve", content_type=ct)
354352
self.user.user_permissions.add(perm)
355353
# Refresh to bust Django's permission cache

qgis-app/plugins/tests/test_plugin_upload.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
from django.urls import reverse
55
from django.test import Client, TestCase, override_settings
6-
from django.contrib.auth.models import User
6+
from django.contrib.auth.models import User, Permission
7+
from django.contrib.contenttypes.models import ContentType
78
from django.core.files.uploadedfile import SimpleUploadedFile
89
from plugins.models import Plugin, PluginVersion
910
from plugins.forms import PackageUploadForm
@@ -135,11 +136,7 @@ def test_new_version_auto_approved_for_trusted_user(self):
135136
A user with can_approve permission should have their uploaded version
136137
approved automatically via the plugin_upload view.
137138
"""
138-
from django.contrib.auth.models import Permission
139-
from django.contrib.contenttypes.models import ContentType
140-
from plugins.models import Plugin as PluginModel
141-
142-
ct = ContentType.objects.get_for_model(PluginModel)
139+
ct = ContentType.objects.get_for_model(Plugin)
143140
perm = Permission.objects.get(codename="can_approve", content_type=ct)
144141
self.user.user_permissions.add(perm)
145142
# Refresh to bust Django's permission cache

qgis-app/plugins/tests/test_token_auth.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import os
22
from unittest.mock import patch
33

4-
from django.contrib.auth.models import User
4+
from django.contrib.auth.models import User, Permission
5+
from django.contrib.contenttypes.models import ContentType
56
from django.core.files.uploadedfile import SimpleUploadedFile
67
from django.test import Client, TestCase, override_settings
78
from django.urls import reverse
8-
from plugins.forms import PackageUploadForm
9-
from plugins.models import Plugin, PluginVersion
109
from rest_framework_simplejwt.token_blacklist.models import OutstandingToken
1110
from rest_framework_simplejwt.tokens import RefreshToken
1211

12+
from plugins.models import Plugin, PluginVersion
13+
1314

1415
def do_nothing(*args, **kwargs):
1516
pass
@@ -286,12 +287,8 @@ def test_new_version_auto_approved_for_trusted_token_user(self):
286287
A token whose owner holds can_approve should result in an approved version,
287288
regardless of whether request.user is AnonymousUser (token path).
288289
"""
289-
from django.contrib.auth.models import Permission
290-
from django.contrib.contenttypes.models import ContentType
291-
from plugins.models import Plugin as PluginModel
292-
293290
# Grant can_approve to the token user
294-
ct = ContentType.objects.get_for_model(PluginModel)
291+
ct = ContentType.objects.get_for_model(Plugin)
295292
perm = Permission.objects.get(codename="can_approve", content_type=ct)
296293
self.user.user_permissions.add(perm)
297294
# Refresh to bust the permission cache

0 commit comments

Comments
 (0)