diff --git a/allianceauth/analytics/tests/test_utils.py b/allianceauth/analytics/tests/test_utils.py index 60ee44bd..b9a22329 100644 --- a/allianceauth/analytics/tests/test_utils.py +++ b/allianceauth/analytics/tests/test_utils.py @@ -1,6 +1,7 @@ from django.apps import apps from allianceauth.authentication.models import User -from allianceauth.analytics.utils import install_stat_users, install_stat_addons +from esi.models import Token +from allianceauth.analytics.utils import install_stat_users, install_stat_tokens, install_stat_addons from django.test.testcases import TestCase diff --git a/allianceauth/authentication/decorators.py b/allianceauth/authentication/decorators.py index 13b4ed0a..d9d93faa 100644 --- a/allianceauth/authentication/decorators.py +++ b/allianceauth/authentication/decorators.py @@ -1,3 +1,6 @@ +from django.urls import include +from django.contrib.auth.decorators import user_passes_test +from django.core.exceptions import PermissionDenied from functools import wraps from typing import Callable, Iterable, Optional diff --git a/allianceauth/authentication/models.py b/allianceauth/authentication/models.py index 3df43b4a..714f1934 100644 --- a/allianceauth/authentication/models.py +++ b/allianceauth/authentication/models.py @@ -5,6 +5,7 @@ from django.db import models, transaction from django.utils.translation import gettext_lazy as _ from allianceauth.eveonline.models import EveCharacter, EveCorporationInfo, EveAllianceInfo, EveFactionInfo from allianceauth.notifications import notify +from django.conf import settings from .managers import CharacterOwnershipManager, StateManager diff --git a/allianceauth/authentication/tests/__init__.py b/allianceauth/authentication/tests/__init__.py index 474a2c20..13410df4 100644 --- a/allianceauth/authentication/tests/__init__.py +++ b/allianceauth/authentication/tests/__init__.py @@ -1,3 +1,9 @@ +from django.db.models.signals import ( + m2m_changed, + post_save, + pre_delete, + pre_save +) from django.urls import reverse from unittest import mock diff --git a/allianceauth/authentication/tests/test_middleware.py b/allianceauth/authentication/tests/test_middleware.py index 10bd7ed0..70335e58 100644 --- a/allianceauth/authentication/tests/test_middleware.py +++ b/allianceauth/authentication/tests/test_middleware.py @@ -1,3 +1,4 @@ +from unittest import mock from allianceauth.authentication.middleware import UserSettingsMiddleware from unittest.mock import Mock from django.http import HttpResponse diff --git a/allianceauth/authentication/tests/test_signals.py b/allianceauth/authentication/tests/test_signals.py index 1e54e785..8f7ba716 100644 --- a/allianceauth/authentication/tests/test_signals.py +++ b/allianceauth/authentication/tests/test_signals.py @@ -4,10 +4,16 @@ from allianceauth.eveonline.models import ( EveCorporationInfo, EveAllianceInfo ) -from django.db.models.signals import post_save +from django.db.models.signals import ( + pre_save, + post_save, + pre_delete, + m2m_changed +) from allianceauth.tests.auth_utils import AuthUtils from django.test.testcases import TestCase +from unittest.mock import Mock from . import patch diff --git a/allianceauth/authentication/views.py b/allianceauth/authentication/views.py index ea73a01f..2e8f4e2c 100644 --- a/allianceauth/authentication/views.py +++ b/allianceauth/authentication/views.py @@ -11,6 +11,7 @@ from django.conf import settings from django.contrib import messages from django.contrib.auth import authenticate, login from django.contrib.auth.decorators import login_required, user_passes_test +from django.contrib.auth.models import User from django.core import signing from django.http import JsonResponse from django.shortcuts import redirect, render diff --git a/allianceauth/crontab/tests/test_utils.py b/allianceauth/crontab/tests/test_utils.py index 563d42cf..48592c99 100644 --- a/allianceauth/crontab/tests/test_utils.py +++ b/allianceauth/crontab/tests/test_utils.py @@ -1,3 +1,5 @@ +# myapp/tests/test_tasks.py + import logging from unittest.mock import patch from django.test import TestCase diff --git a/allianceauth/custom_css/widgets.py b/allianceauth/custom_css/widgets.py index f3da39cb..32ed07dd 100644 --- a/allianceauth/custom_css/widgets.py +++ b/allianceauth/custom_css/widgets.py @@ -5,6 +5,9 @@ Form widgets for custom_css app # Django from django import forms +# Alliance Auth +from allianceauth.custom_css.models import CustomCSS + class CssEditorWidget(forms.Textarea): """ diff --git a/allianceauth/eveonline/autogroups/tests/test_models.py b/allianceauth/eveonline/autogroups/tests/test_models.py index 4b04471d..f9c59389 100644 --- a/allianceauth/eveonline/autogroups/tests/test_models.py +++ b/allianceauth/eveonline/autogroups/tests/test_models.py @@ -1,5 +1,6 @@ from django.test import TestCase from django.contrib.auth.models import Group +from django.db import transaction from allianceauth.tests.auth_utils import AuthUtils diff --git a/allianceauth/eveonline/evelinks/tests/test_evelinks.py b/allianceauth/eveonline/evelinks/tests/test_evelinks.py index 1b520edc..09aa30fb 100644 --- a/allianceauth/eveonline/evelinks/tests/test_evelinks.py +++ b/allianceauth/eveonline/evelinks/tests/test_evelinks.py @@ -1,6 +1,8 @@ from django.test import TestCase +from ...models import EveCharacter, EveCorporationInfo, EveAllianceInfo from .. import dotlan, zkillboard, evewho, eveimageserver +from ...templatetags import evelinks class TestEveWho(TestCase): diff --git a/allianceauth/fleetactivitytracking/views.py b/allianceauth/fleetactivitytracking/views.py index fa7cd204..232fa456 100644 --- a/allianceauth/fleetactivitytracking/views.py +++ b/allianceauth/fleetactivitytracking/views.py @@ -8,7 +8,7 @@ from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import permission_required from django.contrib.auth.models import User from django.core.exceptions import ValidationError, ObjectDoesNotExist -from django.shortcuts import render, redirect, get_object_or_404 +from django.shortcuts import render, redirect, get_object_or_404, Http404 from django.utils import timezone from django.utils.translation import gettext_lazy as _ from esi.decorators import token_required diff --git a/allianceauth/menu/tests/templatetags/test_menu_menu_items.py b/allianceauth/menu/tests/templatetags/test_menu_menu_items.py index 66117b4f..3e3e829a 100644 --- a/allianceauth/menu/tests/templatetags/test_menu_menu_items.py +++ b/allianceauth/menu/tests/templatetags/test_menu_menu_items.py @@ -186,7 +186,7 @@ class TestRenderDefaultMenu(TestCase): classes = "fa-solid fa-users-gear" url_name = "groupmanagement:management" - def render(self, request): + def render(Self, request): # simulate no perms return "" diff --git a/allianceauth/notifications/tests/test_templatetags.py b/allianceauth/notifications/tests/test_templatetags.py index 626d7226..587970be 100644 --- a/allianceauth/notifications/tests/test_templatetags.py +++ b/allianceauth/notifications/tests/test_templatetags.py @@ -1,4 +1,4 @@ -from unittest.mock import patch +from unittest.mock import patch, Mock from django.test import TestCase, override_settings diff --git a/allianceauth/notifications/tests/test_views.py b/allianceauth/notifications/tests/test_views.py index 2e8024da..7fa95bc8 100644 --- a/allianceauth/notifications/tests/test_views.py +++ b/allianceauth/notifications/tests/test_views.py @@ -1,6 +1,6 @@ import json -from unittest.mock import patch +from unittest.mock import patch, Mock from django.test import TestCase, RequestFactory from django.urls import reverse diff --git a/allianceauth/permissions_tool/views.py b/allianceauth/permissions_tool/views.py index 3552e04c..e845a466 100644 --- a/allianceauth/permissions_tool/views.py +++ b/allianceauth/permissions_tool/views.py @@ -1,7 +1,7 @@ import logging from django.contrib.auth.decorators import login_required, permission_required -from django.contrib.auth.models import Permission +from django.contrib.auth.models import Permission, User from django.db.models import Count from django.shortcuts import render, Http404 diff --git a/allianceauth/services/hooks.py b/allianceauth/services/hooks.py index ebfaa04b..084d8e49 100644 --- a/allianceauth/services/hooks.py +++ b/allianceauth/services/hooks.py @@ -1,6 +1,13 @@ from string import Formatter +from django.urls import include, re_path from typing import Iterable, Optional +from django.conf import settings +from django.core.exceptions import ObjectDoesNotExist +from django.template.loader import render_to_string +from django.urls import include, re_path +from django.utils.functional import cached_property + from allianceauth.hooks import get_hooks from allianceauth.menu.hooks import MenuItemHook from django.conf import settings diff --git a/allianceauth/services/modules/discord/tests/piloting_tasks.py b/allianceauth/services/modules/discord/tests/piloting_tasks.py index 715d1b80..4b1d0c7b 100644 --- a/allianceauth/services/modules/discord/tests/piloting_tasks.py +++ b/allianceauth/services/modules/discord/tests/piloting_tasks.py @@ -37,6 +37,7 @@ import random from django.contrib.auth.models import User, Group +from allianceauth.services.modules.discord.models import DiscordUser from allianceauth.utils.cache import get_redis_client logger = logging.getLogger('allianceauth') diff --git a/allianceauth/services/modules/discourse/manager.py b/allianceauth/services/modules/discourse/manager.py index fde966ea..03cbbdee 100644 --- a/allianceauth/services/modules/discourse/manager.py +++ b/allianceauth/services/modules/discourse/manager.py @@ -1,4 +1,5 @@ import logging +import requests import re from django.conf import settings from django.core.cache import cache diff --git a/allianceauth/services/modules/discourse/views.py b/allianceauth/services/modules/discourse/views.py index 8a19f8e7..a777fbb7 100644 --- a/allianceauth/services/modules/discourse/views.py +++ b/allianceauth/services/modules/discourse/views.py @@ -1,7 +1,7 @@ from django.conf import settings from django.contrib import messages from django.contrib.auth.decorators import login_required -from django.shortcuts import redirect +from django.shortcuts import render, redirect from django.utils.translation import gettext_lazy as _ from .manager import DiscourseManager diff --git a/allianceauth/services/modules/ips4/tasks.py b/allianceauth/services/modules/ips4/tasks.py index e2ba70c0..b6c5dce8 100644 --- a/allianceauth/services/modules/ips4/tasks.py +++ b/allianceauth/services/modules/ips4/tasks.py @@ -1,3 +1,4 @@ +from django.conf import settings from django.core.exceptions import ObjectDoesNotExist from allianceauth.services.hooks import NameFormatter diff --git a/allianceauth/tests/test_auth_utils.py b/allianceauth/tests/test_auth_utils.py index 027e6c1c..2fa5215c 100644 --- a/allianceauth/tests/test_auth_utils.py +++ b/allianceauth/tests/test_auth_utils.py @@ -1,6 +1,12 @@ +from unittest import mock + from django.contrib.auth.models import User, Group, Permission from django.test import TestCase +from allianceauth.eveonline.models import ( + EveCorporationInfo, EveAllianceInfo, EveCharacter +) + from .auth_utils import AuthUtils diff --git a/allianceauth/urls.py b/allianceauth/urls.py index 16adfa9c..71a43b26 100644 --- a/allianceauth/urls.py +++ b/allianceauth/urls.py @@ -1,5 +1,6 @@ from typing import List, Iterable, Callable +from django.urls import include import esi.urls from django.conf import settings from django.contrib import admin