* Enable isort in ruff

* auto-format codebase with isort
This commit is contained in:
Andrew Williamson 2023-05-23 15:36:16 +01:00 коммит произвёл GitHub
Родитель a00a837e45
Коммит e4038c3805
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
307 изменённых файлов: 556 добавлений и 725 удалений

Просмотреть файл

@ -100,9 +100,10 @@ def pytest_configure(config):
def instrument_jinja():
"""Make sure the "templates" list in a response is properly updated, even
though we're using Jinja2 and not the default django template engine."""
import jinja2
from django import test
import jinja2
old_render = jinja2.Template.render
def instrumented_render(self, *args, **kwargs):
@ -117,6 +118,7 @@ def instrument_jinja():
def default_prefixer(settings):
"""Make sure each test starts with a default URL prefixer."""
from django import http
from olympia import amo
request = http.HttpRequest()
@ -131,10 +133,11 @@ def default_prefixer(settings):
def test_pre_setup(request, tmpdir, settings):
from django.core.cache import caches
from django.utils import translation
from olympia import amo, core
from olympia.translations.hold import clean_translations
from waffle.utils import get_cache as waffle_get_cache
from waffle import models as waffle_models
from waffle.utils import get_cache as waffle_get_cache
# Clear all cache-instances. They'll be re-initialized by Django
# This will make sure that our random `KEY_PREFIX` is applied

Просмотреть файл

@ -6,6 +6,7 @@
import json
import os
translations_dump = {}
translations_reordered = {}

Просмотреть файл

@ -1,6 +1,6 @@
#!/usr/bin/env python
import sys
import os
import sys
if __name__ == '__main__':

Просмотреть файл

@ -27,6 +27,7 @@ select = [
"B",
"E",
"F",
"I",
"Q",
"W",
]
@ -34,6 +35,13 @@ select = [
[tool.ruff.flake8-quotes]
inline-quotes = "single"
[tool.ruff.isort]
combine-as-imports = true
lines-after-imports = 2
section-order = ["future", "standard-library", "django", "third-party", "first-party", "local-folder"]
[tool.ruff.isort.sections]
"django" = ["django"]
[tool.pytest.ini_options]
addopts = "-vs --reuse-db --showlocals --tb=short"
python_files = "test*.py"

Просмотреть файл

@ -1,5 +1,6 @@
#!/usr/bin/env python
import uuid
# Generate build id for docker image.
print('BUILD_ID = "%s"' % uuid.uuid4())

Просмотреть файл

@ -9,6 +9,7 @@ from urllib.parse import urlparse
from olympia.lib.settings_base import * # noqa
WSGI_APPLICATION = 'olympia.wsgi.application'
INTERNAL_ROUTES_ALLOWED = True
@ -134,8 +135,8 @@ REMOTE_SETTINGS_IS_TEST_SERVER = True
try:
from local_settings import * # noqa
except ImportError:
import warnings
import traceback
import warnings
warnings.warn(
'Could not import local_settings module. {}'.format(traceback.format_exc())

Просмотреть файл

@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from setuptools import setup, find_packages
from setuptools import find_packages, setup
setup(

Просмотреть файл

@ -1,10 +1,9 @@
from rest_framework import serializers
from django.http import Http404
from django.utils.translation import gettext_lazy as _
import olympia.core.logger
from rest_framework import serializers
import olympia.core.logger
from olympia import amo
from olympia.abuse.models import AbuseReport
from olympia.accounts.serializers import BaseUserSerializer

Просмотреть файл

@ -14,10 +14,10 @@ from olympia.abuse.admin import AbuseReportAdmin
from olympia.abuse.models import AbuseReport
from olympia.addons.models import AddonApprovalsCounter
from olympia.amo.tests import (
TestCase,
addon_factory,
days_ago,
grant_permission,
TestCase,
user_factory,
)
from olympia.ratings.models import Rating

Просмотреть файл

@ -1,5 +1,5 @@
from olympia.abuse.models import AbuseReport
from olympia.amo.tests import addon_factory, TestCase, user_factory
from olympia.amo.tests import TestCase, addon_factory, user_factory
class TestAbuse(TestCase):

Просмотреть файл

@ -1,5 +1,4 @@
from datetime import datetime
from unittest.mock import Mock
from django.contrib.auth.models import AnonymousUser

Просмотреть файл

@ -1,6 +1,7 @@
from django.urls import include, re_path
from rest_framework.routers import SimpleRouter
from .views import AddonAbuseViewSet, UserAbuseViewSet

Просмотреть файл

@ -1,5 +1,5 @@
from django.urls import reverse
from django.contrib import admin
from django.urls import reverse
from django.utils.html import format_html
from olympia.amo.admin import AMOModelAdmin

Просмотреть файл

@ -3,7 +3,6 @@ from django.db import models
from django.db.models import signals
import olympia.core.logger
from olympia import activity, amo
from olympia.amo.fields import PositiveAutoField
from olympia.amo.models import ModelBase

Просмотреть файл

@ -1,21 +1,21 @@
import pytest
from django.contrib.auth.models import AnonymousUser
import pytest
from olympia import amo
from olympia.access.models import Group, GroupUser
from olympia.addons.models import Addon, AddonUser
from olympia.amo.tests import addon_factory, TestCase, user_factory
from olympia.amo.tests import TestCase, addon_factory, user_factory
from olympia.users.models import UserProfile
from .acl import (
action_allowed_for,
check_addon_ownership,
is_listed_addons_reviewer,
is_reviewer,
is_static_theme_reviewer,
is_unlisted_addons_reviewer,
is_unlisted_addons_viewer_or_reviewer,
is_reviewer,
is_user_any_kind_of_reviewer,
match_rules,
reserved_guid_addon_submission_allowed,

Просмотреть файл

@ -4,16 +4,15 @@ from django.utils.translation import gettext
from rest_framework import serializers
import olympia.core.logger
from olympia import amo
from olympia.access import acl
from olympia.access.models import Group
from olympia.amo.templatetags.jinja_helpers import absolutify
from olympia.amo.utils import (
clean_nl,
has_links,
ImageCheck,
SafeStorage,
clean_nl,
has_links,
subscribe_newsletter,
unsubscribe_newsletter,
urlparams,

Просмотреть файл

@ -4,7 +4,6 @@ from datetime import datetime
from waffle import switch_is_active
import olympia.core.logger
from olympia import amo
from olympia.activity.models import ActivityLog
from olympia.amo.celery import task

Просмотреть файл

@ -1,7 +1,7 @@
from urllib.parse import quote_plus
from django_jinja import library
import jinja2
from django_jinja import library
from olympia.accounts.utils import path_with_query
from olympia.amo.templatetags.jinja_helpers import drf_url

Просмотреть файл

@ -11,7 +11,7 @@ from olympia.accounts.tasks import (
primary_email_change_event,
)
from olympia.activity.models import ActivityLog
from olympia.amo.tests import addon_factory, collection_factory, TestCase, user_factory
from olympia.amo.tests import TestCase, addon_factory, collection_factory, user_factory
from olympia.bandwagon.models import Collection
from olympia.ratings.models import Rating

Просмотреть файл

@ -1,7 +1,6 @@
import base64
import json
import time
from datetime import datetime
from ipaddress import IPv4Address
from os import path
@ -12,9 +11,9 @@ from django import http
from django.conf import settings
from django.contrib.auth import login
from django.contrib.auth.models import AnonymousUser
from django.urls import reverse
from django.test import RequestFactory
from django.test.utils import override_settings
from django.urls import reverse
from django.utils.encoding import force_str
import freezegun

Просмотреть файл

@ -1,6 +1,5 @@
import binascii
import os
from base64 import urlsafe_b64encode
from urllib.parse import urlencode

Просмотреть файл

@ -3,7 +3,6 @@ import time
from django.conf import settings
import requests
from django_statsd.clients import statsd
import olympia.core.logger

Просмотреть файл

@ -3,7 +3,6 @@ import binascii
import functools
import os
import time
from urllib.parse import quote_plus
from django.conf import settings
@ -20,18 +19,16 @@ from django.views.decorators.cache import never_cache
import jwt
import requests
import waffle
from corsheaders.conf import conf as corsheaders_conf
from corsheaders.middleware import (
ACCESS_CONTROL_ALLOW_ORIGIN,
ACCESS_CONTROL_ALLOW_CREDENTIALS,
ACCESS_CONTROL_ALLOW_HEADERS,
ACCESS_CONTROL_ALLOW_METHODS,
ACCESS_CONTROL_ALLOW_ORIGIN,
ACCESS_CONTROL_MAX_AGE,
)
from django_statsd.clients import statsd
from rest_framework import exceptions
from rest_framework import serializers
from rest_framework import exceptions, serializers
from rest_framework.authentication import SessionAuthentication
from rest_framework.decorators import action
from rest_framework.generics import GenericAPIView
@ -49,7 +46,6 @@ from rest_framework.viewsets import GenericViewSet
from waffle.decorators import waffle_switch
import olympia.core.logger
from olympia import amo
from olympia.access import acl
from olympia.access.models import GroupUser

Просмотреть файл

@ -1,7 +1,6 @@
from django.core.management.base import BaseCommand
import olympia.core.logger
from olympia import amo
from olympia.activity.models import ActivityLog
from olympia.activity.tasks import create_ratinglog

Просмотреть файл

@ -1,7 +1,6 @@
from django.core.management.base import BaseCommand, CommandError
import olympia.core.logger
from olympia.activity.models import ActivityLogToken

Просмотреть файл

@ -1,6 +1,5 @@
import json
import uuid
from collections import defaultdict
from copy import copy
@ -14,7 +13,6 @@ from django.utils.html import format_html, mark_safe
from django.utils.translation import gettext, ngettext
import olympia.core.logger
from olympia import amo, constants
from olympia.access.models import Group
from olympia.addons.models import Addon
@ -25,7 +23,6 @@ from olympia.blocklist.models import Block
from olympia.files.models import File
from olympia.ratings.models import Rating
from olympia.reviewers.models import ReviewActionReason
from olympia.tags.models import Tag
from olympia.users.models import UserProfile
from olympia.versions.models import Version

Просмотреть файл

@ -1,5 +1,4 @@
import olympia.core.logger
from olympia.activity.models import ActivityLog, ActivityLogEmails, RatingLog
from olympia.activity.utils import add_email_to_activity_log_wrapper
from olympia.amo.celery import task

Просмотреть файл

@ -2,10 +2,9 @@ from django.urls import reverse
from pyquery import PyQuery as pq
from olympia import amo, core
from olympia import activity
from olympia.amo.tests import TestCase, addon_factory, user_factory
from olympia import activity, amo, core
from olympia.activity.models import ActivityLog, ReviewActionReasonLog
from olympia.amo.tests import TestCase, addon_factory, user_factory
from olympia.reviewers.models import ReviewActionReason

Просмотреть файл

@ -1,7 +1,7 @@
from ipaddress import IPv4Address
from unittest.mock import Mock
from uuid import UUID
from unittest.mock import Mock
from pyquery import PyQuery as pq
from olympia import amo, core
@ -18,8 +18,8 @@ from olympia.activity.models import (
)
from olympia.addons.models import Addon, AddonUser
from olympia.amo.tests import (
addon_factory,
TestCase,
addon_factory,
user_factory,
version_factory,
)

Просмотреть файл

@ -1,4 +1,5 @@
from unittest import mock
import pytest
from olympia.activity.models import ActivityLogEmails

Просмотреть файл

@ -2,16 +2,14 @@ import copy
import datetime
import json
import os
from email.utils import formataddr
from unittest import mock
from django.conf import settings
from django.core import mail
from django.urls import reverse
from unittest import mock
import pytest
from waffle.testutils import override_switch
from olympia import amo
@ -20,6 +18,7 @@ from olympia.activity.models import MAX_TOKEN_USE_COUNT, ActivityLog, ActivityLo
from olympia.activity.utils import (
ACTIVITY_MAIL_GROUP,
ADDON_REVIEWER_NAME,
NOTIFICATIONS_FROM_EMAIL,
ActivityEmailEncodingError,
ActivityEmailError,
ActivityEmailParser,
@ -29,11 +28,10 @@ from olympia.activity.utils import (
add_email_to_activity_log_wrapper,
log_and_notify,
notify_about_activity_log,
NOTIFICATIONS_FROM_EMAIL,
send_activity_mail,
)
from olympia.amo.templatetags.jinja_helpers import absolutify
from olympia.amo.tests import TestCase, addon_factory, SQUOTE_ESCAPED, user_factory
from olympia.amo.tests import SQUOTE_ESCAPED, TestCase, addon_factory, user_factory
TESTS_DIR = os.path.dirname(os.path.abspath(__file__))

Просмотреть файл

@ -1,8 +1,7 @@
import json
import io
from unittest import mock
import json
from datetime import datetime, timedelta
from unittest import mock
from django.conf import settings
from django.test.utils import override_settings
@ -11,14 +10,14 @@ from rest_framework.exceptions import ErrorDetail
from rest_framework.test import APIRequestFactory
from olympia import amo
from olympia.activity.models import ActivityLog, ActivityLogToken, GENERIC_USER_NAME
from olympia.activity.models import GENERIC_USER_NAME, ActivityLog, ActivityLogToken
from olympia.activity.tests.test_serializers import LogMixin
from olympia.activity.tests.test_utils import sample_message_content
from olympia.activity.views import inbound_email, InboundEmailIPPermission
from olympia.activity.views import InboundEmailIPPermission, inbound_email
from olympia.addons.models import (
AddonUser,
AddonRegionalRestrictions,
AddonReviewerFlags,
AddonUser,
)
from olympia.addons.utils import generate_addon_guid
from olympia.amo.tests import (

Просмотреть файл

@ -1,5 +1,4 @@
import re
from datetime import datetime
from email.utils import formataddr
from html import unescape
@ -12,11 +11,9 @@ from django.urls import reverse
from django.utils import translation
import waffle
from email_reply_parser import EmailReplyParser
import olympia.core.logger
from olympia import amo
from olympia.access import acl
from olympia.activity.models import ActivityLog, ActivityLogToken

Просмотреть файл

@ -1,6 +1,5 @@
from django.conf import settings
from django.shortcuts import get_object_or_404
from django.utils.translation import gettext, gettext_lazy as _
from rest_framework import exceptions, status
@ -14,7 +13,6 @@ from rest_framework.response import Response
from rest_framework.viewsets import GenericViewSet
import olympia.core.logger
from olympia import amo
from olympia.access import acl
from olympia.activity.models import ActivityLog
@ -24,11 +22,11 @@ from olympia.activity.serializers import (
)
from olympia.activity.tasks import process_email
from olympia.activity.utils import (
USER_TYPE_ADDON_AUTHOR,
action_from_user,
filter_queryset_to_pending_replies,
log_and_notify,
type_of_user,
USER_TYPE_ADDON_AUTHOR,
)
from olympia.addons.views import AddonChildMixin
from olympia.api.permissions import (

Просмотреть файл

@ -1,7 +1,7 @@
import functools
from urllib.parse import urlencode, urljoin
from django import http, forms
from django import forms, http
from django.conf import settings
from django.contrib import admin
from django.contrib.admin.utils import display_for_field

Просмотреть файл

@ -9,11 +9,11 @@ from olympia.tags.views import TagListView
from .views import (
AddonAuthorViewSet,
AddonPendingAuthorViewSet,
AddonAutoCompleteSearchView,
AddonFeaturedView,
AddonRecommendationView,
AddonPendingAuthorViewSet,
AddonPreviewViewSet,
AddonRecommendationView,
AddonSearchView,
AddonVersionViewSet,
AddonViewSet,

Просмотреть файл

@ -1,9 +1,8 @@
from datetime import date
from django.db.models import Value, IntegerField
from django.db.models import IntegerField, Value
import olympia.core.logger
from olympia import amo
from olympia.addons.models import Addon, FrozenAddon
from olympia.addons.tasks import (

Просмотреть файл

@ -2,21 +2,20 @@ import copy
import os
import tarfile
import zipfile
from urllib.parse import urlsplit, urlunsplit
from django.conf import settings
from django.db.models import Q
from django.http.request import QueryDict
from django.urls import reverse
from django.utils.encoding import smart_str
from django.utils.translation import gettext, gettext_lazy as _
from django.urls import reverse
from rest_framework import exceptions, serializers
from olympia import amo
from olympia.amo.utils import ImageCheck, sorted_groupby
from olympia.amo.templatetags.jinja_helpers import absolutify
from olympia.amo.utils import ImageCheck, sorted_groupby
from olympia.api.fields import (
ESTranslationSerializerField,
GetTextTranslationSerializerField,
@ -29,9 +28,9 @@ from olympia.constants.categories import CATEGORIES
from olympia.constants.licenses import LICENSES_BY_SLUG
from olympia.files.utils import SafeTar, SafeZip
from olympia.versions.models import (
VALID_SOURCE_EXTENSIONS,
ApplicationsVersions,
License,
VALID_SOURCE_EXTENSIONS,
)

Просмотреть файл

@ -1,11 +1,10 @@
from django.conf import settings
from olympia.constants.promoted import RECOMMENDED
import olympia.core.logger
from olympia import amo
from olympia.amo.utils import attach_trans_dict
from olympia.amo.celery import create_chunked_tasks_signatures
from olympia.amo.utils import to_language
from olympia.amo.utils import attach_trans_dict, to_language
from olympia.constants.promoted import RECOMMENDED
from olympia.constants.search import SEARCH_LANGUAGE_TO_ANALYZER
from olympia.search.utils import create_index
from olympia.versions.compare import version_int

Просмотреть файл

@ -5,6 +5,7 @@ from olympia.core.logger import getLogger
from olympia.versions.compare import version_dict
from olympia.versions.models import AppVersion, Version
log = getLogger('z.fix_langpacks_with_max_version_star')

Просмотреть файл

@ -13,6 +13,7 @@ from olympia.addons.tasks import (
find_inconsistencies_between_es_and_db,
recreate_theme_previews,
)
from olympia.amo.management import ProcessObjectsCommand
from olympia.blocklist.models import Block
from olympia.constants.base import (
_ADDON_LPADDON,
@ -21,7 +22,6 @@ from olympia.constants.base import (
_ADDON_THEME,
_ADDON_WEBAPP,
)
from olympia.amo.management import ProcessObjectsCommand
from olympia.devhub.tasks import get_preview_sizes, recreate_previews
from olympia.lib.crypto.tasks import sign_addons
from olympia.ratings.tasks import addon_rating_aggregates

Просмотреть файл

@ -4,7 +4,6 @@ import os
import re
import time
import uuid
from datetime import datetime
from urllib.parse import urlsplit
@ -26,12 +25,11 @@ from django.dispatch import receiver
from django.urls import reverse
from django.utils import translation
from django.utils.functional import cached_property
from django.utils.translation import trans_real, gettext_lazy as _
from django.utils.translation import gettext_lazy as _, trans_real
from django_statsd.clients import statsd
import olympia.core.logger
from olympia import activity, amo, core
from olympia.addons.utils import generate_addon_guid
from olympia.amo.decorators import use_primary_db
@ -778,9 +776,10 @@ class Addon(OnChangeMixin, ModelBase):
@transaction.atomic
def delete(self, msg='', reason='', send_delete_email=True):
# To avoid a circular import
from . import tasks
from olympia.versions import tasks as version_tasks
from . import tasks
# Check for soft deletion path. Happens only if the addon status isn't
# 0 (STATUS_INCOMPLETE) with no versions.
soft_deletion = self.is_soft_deleteable()

Просмотреть файл

@ -13,7 +13,7 @@ from olympia import amo
from olympia.accounts.serializers import BaseUserSerializer
from olympia.activity.models import ActivityLog
from olympia.amo.templatetags.jinja_helpers import absolutify
from olympia.amo.utils import remove_icons, SafeStorage, slug_validator
from olympia.amo.utils import SafeStorage, remove_icons, slug_validator
from olympia.amo.validators import (
CreateOnlyValidator,
OneOrMoreLetterOrNumberCharacterValidator,
@ -28,12 +28,12 @@ from olympia.api.fields import (
SplitField,
TranslationSerializerField,
)
from olympia.api.serializers import BaseESSerializer, AMOModelSerializer
from olympia.api.serializers import AMOModelSerializer, BaseESSerializer
from olympia.api.utils import is_gate_active
from olympia.applications.models import AppVersion
from olympia.bandwagon.models import Collection
from olympia.blocklist.models import Block
from olympia.constants.applications import APPS_ALL, APP_IDS
from olympia.constants.applications import APP_IDS, APPS_ALL
from olympia.constants.base import ADDON_TYPE_CHOICES_API
from olympia.constants.categories import CATEGORIES_BY_ID
from olympia.constants.promoted import PROMOTED_GROUPS, RECOMMENDED
@ -41,10 +41,10 @@ from olympia.core.languages import AMO_LANGUAGES
from olympia.files.models import File, FileUpload
from olympia.files.utils import DuplicateAddonID, parse_addon
from olympia.promoted.models import PromotedAddon
from olympia.search.filters import AddonAppVersionQueryParam
from olympia.ratings.utils import get_grouped_ratings
from olympia.search.filters import AddonAppVersionQueryParam
from olympia.tags.models import Tag
from olympia.users.models import EmailUserRestriction, RESTRICTION_TYPES, UserProfile
from olympia.users.models import RESTRICTION_TYPES, EmailUserRestriction, UserProfile
from olympia.versions.models import (
ApplicationsVersions,
License,
@ -77,15 +77,15 @@ from .utils import (
validate_version_number_is_gt_latest_signed_listed_version,
)
from .validators import (
AddonMetadataValidator,
AddonDefaultLocaleValidator,
AddonMetadataValidator,
CanSetCompatibilityValidator,
MatchingGuidValidator,
ReviewedSourceFileValidator,
VersionAddonMetadataValidator,
NoFallbackDefaultLocaleValidator,
VersionLicenseValidator,
ReviewedSourceFileValidator,
VerifyMozillaTrademark,
VersionAddonMetadataValidator,
VersionLicenseValidator,
)

Просмотреть файл

@ -8,7 +8,6 @@ from django.db.models.functions import Collate
from elasticsearch_dsl import Search
import olympia.core
from olympia import activity, amo
from olympia.addons.indexers import AddonIndexer
from olympia.addons.models import (

Просмотреть файл

@ -1,7 +1,5 @@
from datetime import datetime, timedelta
from pyquery import PyQuery as pq
from django.conf import settings
from django.contrib import admin
from django.contrib.messages.storage import default_storage as default_messages_storage
@ -10,10 +8,13 @@ from django.test.client import RequestFactory
from django.urls import reverse
from django.utils import formats, timezone
from pyquery import PyQuery as pq
from olympia import amo, core
from olympia.activity.models import ActivityLog
from olympia.addons.admin import AddonAdmin, ReplacementAddonAdmin
from olympia.addons.models import Addon, AddonRegionalRestrictions, ReplacementAddon
from olympia.amo.reverse import django_reverse
from olympia.amo.tests import (
TestCase,
addon_factory,
@ -21,7 +22,6 @@ from olympia.amo.tests import (
user_factory,
version_factory,
)
from olympia.amo.reverse import django_reverse
from olympia.blocklist.models import Block
from olympia.git.models import GitExtractionEntry

Просмотреть файл

@ -1,22 +1,22 @@
import random
from contextlib import contextmanager
from datetime import timedelta
from unittest import mock
from django.conf import settings
from django.core.management import call_command
from django.core.management.base import CommandError
from freezegun import freeze_time
from unittest import mock
import pytest
from freezegun import freeze_time
from olympia import amo
from olympia.abuse.models import AbuseReport
from olympia.addons.management.commands import (
fix_langpacks_with_max_version_star,
process_addons,
)
from olympia.addons.models import Addon, DeniedGuid
from olympia.abuse.models import AbuseReport
from olympia.amo.tests import (
TestCase,
addon_factory,

Просмотреть файл

@ -1,15 +1,15 @@
from celery import group
from unittest import mock
from celery import group
from olympia import amo
from olympia.addons import cron
from olympia.addons.models import Addon, FrozenAddon
from olympia.addons.tasks import (
update_addon_average_daily_users,
update_addon_weekly_downloads,
)
from olympia.addons.models import Addon, FrozenAddon
from olympia.amo.tests import addon_factory, TestCase
from olympia.amo.tests import TestCase, addon_factory
from olympia.files.models import File

Просмотреть файл

@ -1,8 +1,8 @@
from django import http
from unittest import mock
from urllib.parse import quote
from django import http
from olympia.addons import decorators as dec
from olympia.addons.models import Addon
from olympia.amo.tests import TestCase, addon_factory

Просмотреть файл

@ -6,7 +6,7 @@ from django.conf import settings
from olympia import amo
from olympia.addons.indexers import AddonIndexer
from olympia.addons.models import Addon, Preview, attach_tags, attach_translations_dict
from olympia.amo.tests import addon_factory, ESTestCase, TestCase
from olympia.amo.tests import ESTestCase, TestCase, addon_factory
from olympia.bandwagon.models import Collection
from olympia.constants.applications import FIREFOX
from olympia.constants.licenses import LICENSES_BY_BUILTIN

Просмотреть файл

@ -15,9 +15,11 @@ from olympia import amo, core
from olympia.activity.models import ActivityLog, AddonLog
from olympia.addons import models as addons_models
from olympia.addons.models import (
UPCOMING_DUE_DATE_CUT_OFF_DAYS_CONFIG_KEY,
Addon,
AddonApprovalsCounter,
AddonCategory,
AddonGUID,
AddonRegionalRestrictions,
AddonReviewerFlags,
AddonUser,
@ -27,9 +29,7 @@ from olympia.addons.models import (
GuidAlreadyDeniedError,
MigratedLWT,
Preview,
AddonGUID,
track_addon_status_change,
UPCOMING_DUE_DATE_CUT_OFF_DAYS_CONFIG_KEY,
)
from olympia.amo.tests import (
TestCase,

Просмотреть файл

@ -21,11 +21,10 @@ from olympia.addons.models import (
)
from olympia.addons.serializers import (
AddonAuthorSerializer,
UserSerializerWithPictureUrl,
AddonSerializer,
DeveloperAddonSerializer,
DeveloperVersionSerializer,
DeveloperListVersionSerializer,
DeveloperVersionSerializer,
ESAddonAutoCompleteSerializer,
ESAddonSerializer,
LanguageToolsSerializer,
@ -33,6 +32,7 @@ from olympia.addons.serializers import (
ListVersionSerializer,
ReplacementAddonSerializer,
SimpleVersionSerializer,
UserSerializerWithPictureUrl,
VersionSerializer,
)
from olympia.addons.utils import generate_addon_guid
@ -53,11 +53,12 @@ from olympia.amo.tests import (
from olympia.amo.urlresolvers import get_outgoing_url
from olympia.bandwagon.models import Collection
from olympia.constants.categories import CATEGORIES
from olympia.constants.licenses import LICENSES_BY_BUILTIN, LICENSE_GPL3
from olympia.constants.licenses import LICENSE_GPL3, LICENSES_BY_BUILTIN
from olympia.constants.promoted import RECOMMENDED
from olympia.files.models import WebextPermission
from olympia.promoted.models import PromotedAddon
from olympia.ratings.models import Rating
from olympia.users.models import UserProfile
from olympia.versions.models import (
ApplicationsVersions,
AppVersion,
@ -65,7 +66,6 @@ from olympia.versions.models import (
Version,
VersionPreview,
)
from olympia.users.models import UserProfile
class AddonSerializerOutputTestMixin:

Просмотреть файл

@ -14,7 +14,7 @@ from waffle.testutils import override_switch
from olympia import amo
from olympia.activity.models import ActivityLog
from olympia.addons.indexers import AddonIndexer
from olympia.amo.tests import addon_factory, TestCase, user_factory
from olympia.amo.tests import TestCase, addon_factory, user_factory
from olympia.amo.tests.test_helpers import get_image_path
from olympia.amo.utils import image_size
from olympia.constants.reviewers import EXTRA_REVIEW_TARGET_PER_DAY_CONFIG_KEY

Просмотреть файл

@ -6,7 +6,6 @@ from django.forms import ValidationError
from django.test.client import RequestFactory
import pytest
from freezegun import freeze_time
from olympia import amo
@ -14,17 +13,17 @@ from olympia.amo.tests import TestCase, addon_factory, user_factory, version_fac
from olympia.users.models import Group, GroupUser
from ..utils import (
DeleteTokenSigner,
get_addon_recommendations,
get_addon_recommendations_invalid,
is_outcome_recommended,
TAAR_LITE_FALLBACK_REASON_EMPTY,
TAAR_LITE_FALLBACK_REASON_INVALID,
TAAR_LITE_FALLBACK_REASON_TIMEOUT,
TAAR_LITE_FALLBACKS,
TAAR_LITE_OUTCOME_CURATED,
TAAR_LITE_OUTCOME_REAL_FAIL,
TAAR_LITE_OUTCOME_REAL_SUCCESS,
TAAR_LITE_FALLBACK_REASON_INVALID,
DeleteTokenSigner,
get_addon_recommendations,
get_addon_recommendations_invalid,
is_outcome_recommended,
validate_version_number_is_gt_latest_signed_listed_version,
verify_mozilla_trademark,
webext_version_stats,

Просмотреть файл

@ -6,7 +6,6 @@ import stat
import tarfile
import tempfile
import zipfile
from collections import Counter, OrderedDict
from datetime import datetime, timedelta
from unittest import mock
@ -22,7 +21,6 @@ from django.utils.encoding import force_bytes, force_str
from django.utils.http import urlsafe_base64_encode
import pytest
from elasticsearch import Elasticsearch
from freezegun import freeze_time
from rest_framework.exceptions import ErrorDetail
@ -34,9 +32,9 @@ from olympia import amo
from olympia.activity.models import ActivityLog
from olympia.amo.templatetags.jinja_helpers import absolutify
from olympia.amo.tests import (
ESTestCase,
APITestClientJWT,
APITestClientSessionID,
ESTestCase,
TestCase,
addon_factory,
collection_factory,
@ -52,14 +50,14 @@ from olympia.constants.categories import CATEGORIES, CATEGORIES_BY_ID
from olympia.constants.licenses import LICENSE_GPL3
from olympia.constants.promoted import (
LINE,
SPOTLIGHT,
STRATEGIC,
RECOMMENDED,
SPONSORED,
SPOTLIGHT,
STRATEGIC,
VERIFIED,
)
from olympia.files.utils import parse_addon, parse_xpi
from olympia.files.tests.test_models import UploadMixin
from olympia.files.utils import parse_addon, parse_xpi
from olympia.ratings.models import Rating
from olympia.reviewers.models import AutoApprovalSummary
from olympia.search.utils import get_es
@ -76,21 +74,21 @@ from olympia.versions.models import (
from ..models import (
Addon,
AddonCategory,
AddonApprovalsCounter,
AddonCategory,
AddonRegionalRestrictions,
AddonReviewerFlags,
AddonUser,
AddonUserPendingConfirmation,
DeniedSlug,
ReplacementAddon,
Preview,
ReplacementAddon,
)
from ..serializers import (
AddonAuthorSerializer,
AddonPendingAuthorSerializer,
DeveloperAddonSerializer,
CompactLicenseSerializer,
DeveloperAddonSerializer,
DeveloperVersionSerializer,
LicenseSerializer,
)

Просмотреть файл

@ -7,7 +7,7 @@ from django.shortcuts import redirect
from django.utils.cache import patch_cache_control
from django.utils.translation import gettext
from elasticsearch_dsl import Q, query, Search
from elasticsearch_dsl import Q, Search, query
from rest_framework import exceptions, serializers, status
from rest_framework.decorators import action
from rest_framework.generics import ListAPIView
@ -25,7 +25,6 @@ from rest_framework.views import APIView
from rest_framework.viewsets import GenericViewSet
import olympia.core.logger
from olympia import amo
from olympia.access import acl
from olympia.activity.models import ActivityLog
@ -41,9 +40,9 @@ from olympia.api.permissions import (
AllowAddonAuthor,
AllowAddonOwner,
AllowIfNotMozillaDisabled,
AllowListedViewerOrReviewer,
AllowReadOnlyIfPublic,
AllowRelatedObjectPermissions,
AllowListedViewerOrReviewer,
AllowUnlistedViewerOrReviewer,
AnyOf,
APIGatePermission,
@ -78,21 +77,21 @@ from .decorators import addon_view_factory
from .indexers import AddonIndexer
from .models import Addon, AddonUser, AddonUserPendingConfirmation, ReplacementAddon
from .serializers import (
AddonEulaPolicySerializer,
AddonAuthorSerializer,
AddonEulaPolicySerializer,
AddonPendingAuthorSerializer,
AddonSerializer,
DeveloperAddonSerializer,
DeveloperVersionSerializer,
DeveloperListVersionSerializer,
DeveloperVersionSerializer,
ESAddonAutoCompleteSerializer,
ESAddonSerializer,
LanguageToolsSerializer,
ReplacementAddonSerializer,
AddonPendingAuthorSerializer,
ListVersionSerializer,
PreviewSerializer,
ReplacementAddonSerializer,
StaticCategorySerializer,
VersionSerializer,
ListVersionSerializer,
)
from .utils import (
DeleteTokenSigner,

Просмотреть файл

@ -3,17 +3,15 @@ import ipaddress
import operator
from collections import OrderedDict
from rangefilter.filter import DateRangeFilter as DateRangeFilterBase
from django import forms
from django.contrib import admin
from django.contrib.admin.options import IncorrectLookupParameters
from django.contrib.admin.views.main import (
ChangeList,
ChangeListSearchForm,
ERROR_FLAG,
PAGE_VAR,
SEARCH_VAR,
ChangeList,
ChangeListSearchForm,
)
from django.core.exceptions import FieldDoesNotExist
from django.core.paginator import InvalidPage
@ -22,9 +20,12 @@ from django.db.models.constants import LOOKUP_SEP
from django.http.request import QueryDict
from django.utils.html import format_html, format_html_join
from rangefilter.filter import DateRangeFilter as DateRangeFilterBase
from olympia.activity.models import IPLog
from olympia.amo.models import GroupConcat, Inet6Ntoa
from olympia.constants.activity import LOG_BY_ID
from .models import FakeEmail

Просмотреть файл

@ -1,3 +1,5 @@
from urllib.parse import quote
from django.conf import settings
from django.contrib.auth.models import AnonymousUser
from django.urls import reverse
@ -6,8 +8,6 @@ from django.utils.translation import get_language, get_language_bidi, gettext
from olympia import amo
from olympia.access import acl
from urllib.parse import quote
def i18n(request):
lang = get_language()

Просмотреть файл

@ -1,23 +1,23 @@
from datetime import datetime, timedelta
from django.core.files.storage import default_storage as storage
import olympia.core.logger
from olympia import amo
from olympia.activity.models import ActivityLog
from olympia.constants.activity import RETENTION_DAYS
from olympia.addons.models import Addon
from olympia.addons.tasks import delete_addons
from olympia.amo.models import FakeEmail
from olympia.amo.utils import chunked
from olympia.constants.activity import RETENTION_DAYS
from olympia.files.models import FileUpload
from olympia.scanners.models import ScannerResult
from olympia.amo.models import FakeEmail
from . import tasks
from .sitemap import (
get_sitemap_path,
get_sitemaps,
get_sitemap_section_pages,
get_sitemaps,
render_index_xml,
)

Просмотреть файл

@ -192,7 +192,7 @@ def api_authentication(f):
already have been attempted by this point so api auth will only be tried for
anonymous (unauthenticated) requests."""
from olympia.api.authentication import SessionIDAuthentication, JWTKeyAuthentication
from olympia.api.authentication import JWTKeyAuthentication, SessionIDAuthentication
@functools.wraps(f)
def wrapper(request, *args, **kw):

Просмотреть файл

@ -1,5 +1,5 @@
import re
import ipaddress
import re
from django.conf import settings
from django.core import exceptions

Просмотреть файл

@ -1,8 +1,8 @@
from django import forms
from django.utils.functional import cached_property
from olympia.amo.utils import BaseModelSerializerAndFormMixin
from olympia.translations.fields import TranslatedField
from django.utils.functional import cached_property
class AMOModelForm(BaseModelSerializerAndFormMixin, forms.ModelForm):

Просмотреть файл

@ -3,7 +3,6 @@ from django.core import mail
from django.core.mail.backends.base import BaseEmailBackend
import olympia.core.logger
from olympia.amo.models import FakeEmail

Просмотреть файл

@ -2,7 +2,6 @@ from django.core.management.base import BaseCommand, CommandError
from django.db import IntegrityError
import olympia.core.logger
from olympia import amo
from olympia.applications.models import AppVersion

Просмотреть файл

@ -3,8 +3,8 @@ import os
import subprocess
from django.conf import settings
from django.core.management.base import BaseCommand, CommandError
from django.contrib.staticfiles.finders import find as find_static_path
from django.core.management.base import BaseCommand, CommandError
from olympia.lib.jingo_minify_helpers import ensure_path_exists

Просмотреть файл

@ -1,5 +1,4 @@
import argparse
from datetime import datetime
from importlib import import_module

Просмотреть файл

@ -1,5 +1,4 @@
import os
from datetime import datetime, timedelta
from os import scandir

Просмотреть файл

@ -5,7 +5,6 @@ from django.template import loader
from django.utils import safestring
import markupsafe
from rest_framework.request import Request

Просмотреть файл

@ -1,7 +1,6 @@
import contextlib
import re
import uuid
from urllib.parse import quote
from django.conf import settings
@ -20,6 +19,7 @@ from django.http import (
)
from django.middleware import common
from django.template.response import TemplateResponse
from django.urls import is_valid_path
from django.utils.cache import (
add_never_cache_headers,
get_max_age,
@ -30,19 +30,17 @@ from django.utils.crypto import constant_time_compare
from django.utils.deprecation import MiddlewareMixin
from django.utils.encoding import force_str, iri_to_uri
from django.utils.translation import activate, gettext_lazy as _
from django.urls import is_valid_path
from django_statsd.clients import statsd
from rest_framework import permissions
import MySQLdb as mysql
from django_statsd.clients import statsd
from rest_framework import permissions
import olympia.core.logger
from olympia import amo
from olympia.accounts.utils import redirect_for_login
from olympia.accounts.verify import (
check_and_update_fxa_access_token,
IdentificationError,
check_and_update_fxa_access_token,
)
from . import urlresolvers

Просмотреть файл

@ -1,7 +1,6 @@
import contextlib
import os
import time
from urllib.parse import urljoin
from django.conf import settings
@ -20,7 +19,6 @@ from django.utils.functional import cached_property
import multidb.pinning
import olympia.core.logger
from olympia.translations.hold import save_translations
@ -131,9 +129,10 @@ class ManagerBase(models.Manager):
return self._with_translations(qs)
def _with_translations(self, qs):
from olympia.translations import transformer
from django.db.models import Value
from olympia.translations import transformer
if hasattr(self.model._meta, 'translated_fields'):
qs = qs.transform(transformer.get_trans)
# Annotate the queryset with the current language to prevent any

Просмотреть файл

@ -1,5 +1,5 @@
import os
import io
import os
import socket
import traceback
@ -7,13 +7,11 @@ from django.conf import settings
import celery
import requests
from django_statsd.clients import statsd
from kombu import Connection
from PIL import Image
import olympia.core.logger
from olympia.amo.models import use_primary_db
from olympia.blocklist.tasks import monitor_remote_settings
from olympia.search.utils import get_es

Просмотреть файл

@ -10,17 +10,17 @@ from django.contrib.sitemaps import Sitemap as DjangoSitemap
from django.core.paginator import PageNotAnInteger
from django.db.models import Count, Max, Q
from django.template import loader
from django.utils.functional import cached_property
from django.urls import reverse
from django.utils.functional import cached_property
from olympia import amo
from olympia.addons.models import Addon, AddonCategory
from olympia.amo.reverse import get_url_prefix, override_url_prefix
from olympia.amo.templatetags.jinja_helpers import absolutify
from olympia.amo.utils import id_to_path
from olympia.bandwagon.models import Collection
from olympia.constants.categories import CATEGORIES
from olympia.constants.promoted import RECOMMENDED
from olympia.bandwagon.models import Collection
from olympia.promoted.models import PromotedAddon
from olympia.tags.models import AddonTag, Tag
from olympia.users.models import UserProfile

Просмотреть файл

@ -4,7 +4,6 @@ from django.apps import apps
from django.core.mail import EmailMessage, EmailMultiAlternatives
import olympia.core.logger
from olympia import amo
from olympia.amo.celery import task
from olympia.amo.utils import get_email_backend

Просмотреть файл

@ -1,10 +1,9 @@
import json as jsonlib
from urllib.parse import urljoin
from django.conf import settings
from django.forms import CheckboxInput
from django.template import defaultfilters, Library, loader
from django.template import Library, defaultfilters, loader
from django.templatetags.static import static
from django.urls import reverse
from django.utils.encoding import smart_str
@ -18,10 +17,9 @@ from django.utils.translation import get_language, gettext
import jinja2
import markupsafe
import waffle
from jinja2.ext import Extension
from babel.support import Format
from django_jinja import library
from jinja2.ext import Extension
from rest_framework.reverse import reverse as drf_reverse
from rest_framework.settings import api_settings

Просмотреть файл

@ -9,9 +9,9 @@ from contextlib import contextmanager
from datetime import datetime, timedelta
from functools import partial
from importlib import import_module
from urllib.parse import parse_qs, urlparse
from unittest import mock
from tempfile import NamedTemporaryFile
from unittest import mock
from urllib.parse import parse_qs, urlparse
from django import forms, test
from django.conf import settings
@ -46,10 +46,10 @@ from olympia.addons.models import (
AddonReviewerFlags,
update_search_index as addon_update_search_index,
)
from olympia.addons.tasks import compute_last_updated
from olympia.amo.reverse import get_url_prefix, set_url_prefix
from olympia.amo.urlresolvers import Prefixer
from olympia.amo.utils import SafeStorage, use_fake_fxa
from olympia.addons.tasks import compute_last_updated
from olympia.api.tests import JWTAuthKeyTester
from olympia.applications.models import AppVersion
from olympia.bandwagon.models import Collection
@ -64,13 +64,13 @@ from olympia.promoted.models import (
from olympia.search.utils import get_es, timestamp_index
from olympia.tags.models import Tag
from olympia.translations.models import Translation
from olympia.users.models import UserProfile
from olympia.versions.models import (
ApplicationsVersions,
License,
Version,
VersionReviewerFlags,
)
from olympia.users.models import UserProfile
from . import dynamic_urls

Просмотреть файл

@ -1,13 +1,13 @@
import os
import tempfile
from unittest import mock
from django.conf import settings
from django.core.validators import ValidationError
from unittest import mock
import pytest
from olympia.amo.tests import get_temp_filename, TestCase
from olympia.amo.tests import TestCase, get_temp_filename
from olympia.amo.utils import (
SafeStorage,
escape_all,

Просмотреть файл

@ -1,7 +1,6 @@
import datetime
import importlib
import time
import datetime
from datetime import timedelta
from unittest import mock
@ -12,8 +11,8 @@ from django.test.testcases import TransactionTestCase
from celery import group
from post_request_task.task import _discard_tasks, _stop_queuing_tasks
from olympia.amo.tests import TestCase
from olympia.amo.celery import app, create_chunked_tasks_signatures, task
from olympia.amo.tests import TestCase
from olympia.amo.utils import utc_millesecs_from_epoch

Просмотреть файл

@ -1,35 +1,35 @@
import os
import io
import os
from datetime import datetime, timedelta
from importlib import import_module
from unittest import mock
from django.conf import settings
from django.core.management import call_command
from django.core.management.base import CommandError
from django.test.utils import override_settings
from unittest import mock
import pytest
from olympia.addons.models import Preview
from olympia.amo.management.commands.get_changed_files import (
collect_user_pics,
collect_files,
collect_sources,
collect_addon_previews,
collect_theme_previews,
collect_addon_icons,
collect_editoral,
collect_git,
collect_addon_previews,
collect_blocklist,
collect_editoral,
collect_files,
collect_git,
collect_sources,
collect_theme_previews,
collect_user_pics,
)
from olympia.amo.tests import addon_factory, TestCase, user_factory, version_factory
from olympia.amo.tests import TestCase, addon_factory, user_factory, version_factory
from olympia.amo.utils import id_to_path
from olympia.blocklist.utils import datetime_to_ts
from olympia.files.models import File, files_upload_to_callback
from olympia.git.utils import AddonGitRepository
from olympia.hero.models import PrimaryHeroImage
from olympia.versions.models import source_upload_path, VersionPreview
from olympia.versions.models import VersionPreview, source_upload_path
def sample_cron_job(*args):

Просмотреть файл

@ -8,7 +8,6 @@ from django.test import RequestFactory
from django.utils.encoding import force_str
import pytest
from rest_framework import exceptions as drf_exceptions
from olympia import amo

Просмотреть файл

@ -1,7 +1,7 @@
from ipaddress import IPv4Address, IPv6Address
from django.core import exceptions
from django.db import connection, DataError
from django.db import DataError, connection
from django.test.utils import override_settings
from olympia.access.models import Group

Просмотреть файл

@ -1,21 +1,18 @@
import mimetypes
import os
from datetime import datetime, timedelta
from unittest.mock import Mock, patch
from django.conf import settings
from django.core.files.uploadedfile import SimpleUploadedFile
from django.urls import NoReverseMatch
from django.test.client import RequestFactory
from django.urls import NoReverseMatch
from django.utils.encoding import force_bytes
import pytest
from pyquery import PyQuery
import olympia
from olympia import amo
from olympia.amo import urlresolvers, utils
from olympia.amo.reverse import set_url_prefix

Просмотреть файл

@ -1,5 +1,4 @@
import django.contrib.messages as django_messages
from django.contrib.messages.storage import default_storage
from django.http import HttpRequest
from django.template import loader

Просмотреть файл

@ -1,3 +1,5 @@
from unittest.mock import Mock, PropertyMock, patch
from django import test
from django.conf import settings
from django.contrib.auth import SESSION_KEY
@ -8,8 +10,6 @@ from django.test.utils import override_settings
from django.urls import reverse
import pytest
from unittest.mock import patch, Mock, PropertyMock
from pyquery import PyQuery as pq
from olympia.accounts.utils import fxa_login_url, path_with_query
@ -22,7 +22,7 @@ from olympia.amo.middleware import (
SetRemoteAddrFromForwardedFor,
TokenValidMiddleware,
)
from olympia.amo.tests import addon_factory, reverse_ns, TestCase, user_factory
from olympia.amo.tests import TestCase, addon_factory, reverse_ns, user_factory
from olympia.zadmin.models import Config

Просмотреть файл

@ -1,5 +1,4 @@
import os
import pytest
from unittest.mock import Mock
from django.conf import settings
@ -7,6 +6,8 @@ from django.core.files.storage import default_storage as storage
from django.test.utils import override_settings
from django.urls import reverse
import pytest
from olympia import amo
from olympia.addons.models import Addon
from olympia.amo import models as amo_models

Просмотреть файл

@ -1,12 +1,11 @@
import json
from unittest.mock import Mock, patch
from django.conf import settings
from django.test.utils import override_settings
import responses
from unittest.mock import Mock, patch
from olympia.amo import monitors
from olympia.amo.tests import TestCase

Просмотреть файл

@ -1,9 +1,9 @@
from unittest.mock import MagicMock, Mock
from django.core.paginator import EmptyPage, InvalidPage, PageNotAnInteger, Paginator
import pytest
from unittest.mock import MagicMock, Mock
from olympia.amo.pagination import ESPaginator
from olympia.amo.templatetags.jinja_helpers import PaginationRenderer
from olympia.amo.tests import TestCase

Просмотреть файл

@ -1,8 +1,7 @@
"""Testing the pytest fixtures themselves which are declared in conftest.py."""
import pytest
import responses
import requests
import responses
from requests.exceptions import ConnectionError
from olympia.access.models import Group

Просмотреть файл

@ -2,7 +2,6 @@ from django.db import models
import MySQLdb as mysql
import pytest
from pyquery import PyQuery as pq
from olympia.addons.models import Addon

Просмотреть файл

@ -1,13 +1,12 @@
import mimetypes
import os.path
from unittest import mock
from django.conf import settings
from django.core import mail
from django.core.mail import EmailMessage
from django.utils import translation
from unittest import mock
from celery.exceptions import Retry
from olympia.amo.models import FakeEmail

Просмотреть файл

@ -1,12 +1,11 @@
import os
import json
import os
from copy import deepcopy
from sentry_sdk.hub import Hub
from django.conf import settings
from sentry_sdk.hub import Hub
from olympia.core.sentry import get_sentry_release

Просмотреть файл

@ -1,6 +1,6 @@
import os
from unittest import mock
from datetime import datetime
from unittest import mock
from django.conf import settings
from django.core.paginator import PageNotAnInteger
@ -11,24 +11,24 @@ import pytest
from olympia import amo
from olympia.addons.models import AddonCategory
from olympia.amo.reverse import override_url_prefix
from olympia.amo.sitemap import (
AccountSitemap,
AddonSitemap,
AMOSitemap,
CategoriesSitemap,
CollectionSitemap,
InvalidSection,
TagPagesSitemap,
get_sitemap_path,
get_sitemap_section_pages,
get_sitemaps,
InvalidSection,
render_index_xml,
TagPagesSitemap,
)
from olympia.amo.reverse import override_url_prefix
from olympia.amo.tests import (
TestCase,
addon_factory,
collection_factory,
TestCase,
user_factory,
version_factory,
)

Просмотреть файл

@ -1,6 +1,5 @@
import os
import tempfile
from functools import partial
from django.conf import settings
@ -10,7 +9,7 @@ from django.utils.encoding import force_str
import pytest
from olympia.amo.tests import TestCase
from olympia.amo.utils import rm_local_tmp_dir, SafeStorage
from olympia.amo.utils import SafeStorage, rm_local_tmp_dir
pytestmark = pytest.mark.django_db

Просмотреть файл

@ -1,14 +1,14 @@
from django import shortcuts
from django.conf import settings
from django.urls import resolve, reverse, set_script_prefix
from django.test.client import Client, RequestFactory
from django.urls import resolve, reverse, set_script_prefix
import pytest
from olympia.amo import urlresolvers
from olympia.amo.middleware import LocaleAndAppURLMiddleware
from olympia.amo.reverse import clean_url_prefixes, set_url_prefix
from olympia.amo.tests import addon_factory, TestCase
from olympia.amo.tests import TestCase, addon_factory
pytestmark = pytest.mark.django_db

Просмотреть файл

@ -2,6 +2,7 @@ import collections
import datetime
import os.path
import tempfile
from unittest import mock
from urllib.parse import urlparse
from django.conf import settings
@ -11,9 +12,7 @@ from django.utils.functional import cached_property
from django.utils.http import quote_etag
import freezegun
from unittest import mock
import pytest
from babel import Locale
from olympia import amo

Просмотреть файл

@ -2,8 +2,8 @@ import json
import os
import re
import sys
from unittest import mock
from unittest.mock import patch
from urllib.parse import urlparse
import django
@ -14,9 +14,7 @@ from django.test.utils import override_settings
from django.urls import reverse
import pytest
from lxml import etree
from unittest.mock import patch
from pyquery import PyQuery as pq
from olympia import amo, core

Просмотреть файл

@ -1,7 +1,6 @@
import hashlib
import hmac
import re
from urllib.parse import quote
from django.conf import settings

Просмотреть файл

@ -3,6 +3,7 @@ from django.views.generic.base import TemplateView
from . import views
services_patterns = [
re_path(
r'^__heartbeat__$', views.services_heartbeat, name='amo.services_heartbeat'

Просмотреть файл

@ -14,17 +14,15 @@ import subprocess
import tempfile
import time
import unicodedata
from urllib.parse import (
parse_qsl,
ParseResult,
parse_qsl,
unquote_to_bytes,
urlencode as urllib_urlencode,
urlparse,
)
import django.core.mail
from django.conf import settings
from django.core.exceptions import FieldDoesNotExist
from django.core.files.storage import FileSystemStorage, default_storage as storage
@ -36,21 +34,20 @@ from django.http.response import HttpResponseRedirectBase
from django.template import engines, loader
from django.urls import reverse
from django.utils import translation
from django.utils.functional import cached_property
from django.utils.encoding import force_bytes, force_str
from django.utils.functional import cached_property
from django.utils.http import (
_urlparse as django_urlparse,
quote_etag,
url_has_allowed_host_and_scheme,
)
import basket
import bleach
import colorgram
import html5lib
import markupsafe
import pytz
import basket
from babel import Locale
from django_statsd.clients import statsd
from html5lib.serializer import HTMLSerializer
@ -58,12 +55,12 @@ from PIL import Image
from rest_framework.utils.encoders import JSONEncoder
from rest_framework.utils.formatting import lazy_format
from olympia.core.logger import getLogger
from olympia.amo import ADDON_ICON_SIZES
from olympia.amo.urlresolvers import linkify_with_outgoing
from olympia.core.logger import getLogger
from olympia.lib import unicodehelper
from olympia.translations.models import Translation
from olympia.users.utils import UnsubscribeCode
from olympia.lib import unicodehelper
log = getLogger('z.amo')
@ -187,8 +184,8 @@ def send_mail(
Adds deny checking and error logging.
"""
from olympia.amo.templatetags.jinja_helpers import absolutify
from olympia.amo.tasks import send_email
from olympia.amo.templatetags.jinja_helpers import absolutify
from olympia.users import notifications
from olympia.users.models import UserNotification

Просмотреть файл

@ -26,7 +26,7 @@ from olympia.api.serializers import SiteStatusSerializer
from olympia.users.models import UserProfile
from . import monitors
from .sitemap import get_sitemap_path, get_sitemaps, InvalidSection, render_index_xml
from .sitemap import InvalidSection, get_sitemap_path, get_sitemaps, render_index_xml
@never_cache
@ -147,7 +147,7 @@ def handler500(request, **kwargs):
@non_atomic_requests
def csrf_failure(request, reason=''):
from django.middleware.csrf import REASON_NO_REFERER, REASON_NO_CSRF_COOKIE
from django.middleware.csrf import REASON_NO_CSRF_COOKIE, REASON_NO_REFERER
ctx = {
'reason': reason,

Просмотреть файл

@ -4,16 +4,14 @@ from django.utils.encoding import force_str, smart_str
from django.utils.translation import gettext
import jwt
from rest_framework import exceptions
from rest_framework.authentication import BaseAuthentication, get_authorization_header
import olympia.core.logger
from olympia import core
from olympia.accounts.verify import (
check_and_update_fxa_access_token,
IdentificationError,
check_and_update_fxa_access_token,
)
from olympia.api import jwt_auth
from olympia.api.models import APIKey

Просмотреть файл

@ -6,8 +6,7 @@ from django.core.signals import got_request_exception
from django.http import Http404
from django.utils.translation import gettext_lazy as _
from rest_framework import exceptions
from rest_framework import status
from rest_framework import exceptions, status
from rest_framework.response import Response
from rest_framework.views import set_rollback

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше