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

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

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

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

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

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

@ -27,6 +27,7 @@ select = [
"B", "B",
"E", "E",
"F", "F",
"I",
"Q", "Q",
"W", "W",
] ]
@ -34,6 +35,13 @@ select = [
[tool.ruff.flake8-quotes] [tool.ruff.flake8-quotes]
inline-quotes = "single" 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] [tool.pytest.ini_options]
addopts = "-vs --reuse-db --showlocals --tb=short" addopts = "-vs --reuse-db --showlocals --tb=short"
python_files = "test*.py" python_files = "test*.py"

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

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

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

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

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

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

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

@ -1,10 +1,9 @@
from rest_framework import serializers
from django.http import Http404 from django.http import Http404
from django.utils.translation import gettext_lazy as _ 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 import amo
from olympia.abuse.models import AbuseReport from olympia.abuse.models import AbuseReport
from olympia.accounts.serializers import BaseUserSerializer from olympia.accounts.serializers import BaseUserSerializer

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

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

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

@ -1,5 +1,5 @@
from olympia.abuse.models import AbuseReport 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): class TestAbuse(TestCase):

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

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

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

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

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

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

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

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

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

@ -1,21 +1,21 @@
import pytest
from django.contrib.auth.models import AnonymousUser from django.contrib.auth.models import AnonymousUser
import pytest
from olympia import amo from olympia import amo
from olympia.access.models import Group, GroupUser from olympia.access.models import Group, GroupUser
from olympia.addons.models import Addon, AddonUser 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 olympia.users.models import UserProfile
from .acl import ( from .acl import (
action_allowed_for, action_allowed_for,
check_addon_ownership, check_addon_ownership,
is_listed_addons_reviewer, is_listed_addons_reviewer,
is_reviewer,
is_static_theme_reviewer, is_static_theme_reviewer,
is_unlisted_addons_reviewer, is_unlisted_addons_reviewer,
is_unlisted_addons_viewer_or_reviewer, is_unlisted_addons_viewer_or_reviewer,
is_reviewer,
is_user_any_kind_of_reviewer, is_user_any_kind_of_reviewer,
match_rules, match_rules,
reserved_guid_addon_submission_allowed, reserved_guid_addon_submission_allowed,

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

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

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

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

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

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

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

@ -11,7 +11,7 @@ from olympia.accounts.tasks import (
primary_email_change_event, primary_email_change_event,
) )
from olympia.activity.models import ActivityLog 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.bandwagon.models import Collection
from olympia.ratings.models import Rating from olympia.ratings.models import Rating

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -1,8 +1,7 @@
import json
import io import io
from unittest import mock import json
from datetime import datetime, timedelta from datetime import datetime, timedelta
from unittest import mock
from django.conf import settings from django.conf import settings
from django.test.utils import override_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 rest_framework.test import APIRequestFactory
from olympia import amo 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_serializers import LogMixin
from olympia.activity.tests.test_utils import sample_message_content 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 ( from olympia.addons.models import (
AddonUser,
AddonRegionalRestrictions, AddonRegionalRestrictions,
AddonReviewerFlags, AddonReviewerFlags,
AddonUser,
) )
from olympia.addons.utils import generate_addon_guid from olympia.addons.utils import generate_addon_guid
from olympia.amo.tests import ( from olympia.amo.tests import (

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -1,11 +1,10 @@
from django.conf import settings from django.conf import settings
from olympia.constants.promoted import RECOMMENDED
import olympia.core.logger import olympia.core.logger
from olympia import amo from olympia import amo
from olympia.amo.utils import attach_trans_dict
from olympia.amo.celery import create_chunked_tasks_signatures 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.constants.search import SEARCH_LANGUAGE_TO_ANALYZER
from olympia.search.utils import create_index from olympia.search.utils import create_index
from olympia.versions.compare import version_int 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.compare import version_dict
from olympia.versions.models import AppVersion, Version from olympia.versions.models import AppVersion, Version
log = getLogger('z.fix_langpacks_with_max_version_star') log = getLogger('z.fix_langpacks_with_max_version_star')

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

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

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

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

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

@ -13,7 +13,7 @@ from olympia import amo
from olympia.accounts.serializers import BaseUserSerializer from olympia.accounts.serializers import BaseUserSerializer
from olympia.activity.models import ActivityLog from olympia.activity.models import ActivityLog
from olympia.amo.templatetags.jinja_helpers import absolutify 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 ( from olympia.amo.validators import (
CreateOnlyValidator, CreateOnlyValidator,
OneOrMoreLetterOrNumberCharacterValidator, OneOrMoreLetterOrNumberCharacterValidator,
@ -28,12 +28,12 @@ from olympia.api.fields import (
SplitField, SplitField,
TranslationSerializerField, 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.api.utils import is_gate_active
from olympia.applications.models import AppVersion from olympia.applications.models import AppVersion
from olympia.bandwagon.models import Collection from olympia.bandwagon.models import Collection
from olympia.blocklist.models import Block 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.base import ADDON_TYPE_CHOICES_API
from olympia.constants.categories import CATEGORIES_BY_ID from olympia.constants.categories import CATEGORIES_BY_ID
from olympia.constants.promoted import PROMOTED_GROUPS, RECOMMENDED 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.models import File, FileUpload
from olympia.files.utils import DuplicateAddonID, parse_addon from olympia.files.utils import DuplicateAddonID, parse_addon
from olympia.promoted.models import PromotedAddon from olympia.promoted.models import PromotedAddon
from olympia.search.filters import AddonAppVersionQueryParam
from olympia.ratings.utils import get_grouped_ratings from olympia.ratings.utils import get_grouped_ratings
from olympia.search.filters import AddonAppVersionQueryParam
from olympia.tags.models import Tag 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 ( from olympia.versions.models import (
ApplicationsVersions, ApplicationsVersions,
License, License,
@ -77,15 +77,15 @@ from .utils import (
validate_version_number_is_gt_latest_signed_listed_version, validate_version_number_is_gt_latest_signed_listed_version,
) )
from .validators import ( from .validators import (
AddonMetadataValidator,
AddonDefaultLocaleValidator, AddonDefaultLocaleValidator,
AddonMetadataValidator,
CanSetCompatibilityValidator, CanSetCompatibilityValidator,
MatchingGuidValidator, MatchingGuidValidator,
ReviewedSourceFileValidator,
VersionAddonMetadataValidator,
NoFallbackDefaultLocaleValidator, NoFallbackDefaultLocaleValidator,
VersionLicenseValidator, ReviewedSourceFileValidator,
VerifyMozillaTrademark, VerifyMozillaTrademark,
VersionAddonMetadataValidator,
VersionLicenseValidator,
) )

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

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

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

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

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

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

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

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

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

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

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

@ -6,7 +6,7 @@ from django.conf import settings
from olympia import amo from olympia import amo
from olympia.addons.indexers import AddonIndexer from olympia.addons.indexers import AddonIndexer
from olympia.addons.models import Addon, Preview, attach_tags, attach_translations_dict 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.bandwagon.models import Collection
from olympia.constants.applications import FIREFOX from olympia.constants.applications import FIREFOX
from olympia.constants.licenses import LICENSES_BY_BUILTIN 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.activity.models import ActivityLog, AddonLog
from olympia.addons import models as addons_models from olympia.addons import models as addons_models
from olympia.addons.models import ( from olympia.addons.models import (
UPCOMING_DUE_DATE_CUT_OFF_DAYS_CONFIG_KEY,
Addon, Addon,
AddonApprovalsCounter, AddonApprovalsCounter,
AddonCategory, AddonCategory,
AddonGUID,
AddonRegionalRestrictions, AddonRegionalRestrictions,
AddonReviewerFlags, AddonReviewerFlags,
AddonUser, AddonUser,
@ -27,9 +29,7 @@ from olympia.addons.models import (
GuidAlreadyDeniedError, GuidAlreadyDeniedError,
MigratedLWT, MigratedLWT,
Preview, Preview,
AddonGUID,
track_addon_status_change, track_addon_status_change,
UPCOMING_DUE_DATE_CUT_OFF_DAYS_CONFIG_KEY,
) )
from olympia.amo.tests import ( from olympia.amo.tests import (
TestCase, TestCase,

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

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

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

@ -14,7 +14,7 @@ from waffle.testutils import override_switch
from olympia import amo from olympia import amo
from olympia.activity.models import ActivityLog from olympia.activity.models import ActivityLog
from olympia.addons.indexers import AddonIndexer 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.tests.test_helpers import get_image_path
from olympia.amo.utils import image_size from olympia.amo.utils import image_size
from olympia.constants.reviewers import EXTRA_REVIEW_TARGET_PER_DAY_CONFIG_KEY 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 from django.test.client import RequestFactory
import pytest import pytest
from freezegun import freeze_time from freezegun import freeze_time
from olympia import amo 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 olympia.users.models import Group, GroupUser
from ..utils import ( from ..utils import (
DeleteTokenSigner,
get_addon_recommendations,
get_addon_recommendations_invalid,
is_outcome_recommended,
TAAR_LITE_FALLBACK_REASON_EMPTY, TAAR_LITE_FALLBACK_REASON_EMPTY,
TAAR_LITE_FALLBACK_REASON_INVALID,
TAAR_LITE_FALLBACK_REASON_TIMEOUT, TAAR_LITE_FALLBACK_REASON_TIMEOUT,
TAAR_LITE_FALLBACKS, TAAR_LITE_FALLBACKS,
TAAR_LITE_OUTCOME_CURATED, TAAR_LITE_OUTCOME_CURATED,
TAAR_LITE_OUTCOME_REAL_FAIL, TAAR_LITE_OUTCOME_REAL_FAIL,
TAAR_LITE_OUTCOME_REAL_SUCCESS, 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, validate_version_number_is_gt_latest_signed_listed_version,
verify_mozilla_trademark, verify_mozilla_trademark,
webext_version_stats, webext_version_stats,

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

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

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

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

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

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

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

@ -1,3 +1,5 @@
from urllib.parse import quote
from django.conf import settings from django.conf import settings
from django.contrib.auth.models import AnonymousUser from django.contrib.auth.models import AnonymousUser
from django.urls import reverse 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 import amo
from olympia.access import acl from olympia.access import acl
from urllib.parse import quote
def i18n(request): def i18n(request):
lang = get_language() lang = get_language()

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

@ -1,23 +1,23 @@
from datetime import datetime, timedelta from datetime import datetime, timedelta
from django.core.files.storage import default_storage as storage from django.core.files.storage import default_storage as storage
import olympia.core.logger import olympia.core.logger
from olympia import amo from olympia import amo
from olympia.activity.models import ActivityLog from olympia.activity.models import ActivityLog
from olympia.constants.activity import RETENTION_DAYS
from olympia.addons.models import Addon from olympia.addons.models import Addon
from olympia.addons.tasks import delete_addons from olympia.addons.tasks import delete_addons
from olympia.amo.models import FakeEmail
from olympia.amo.utils import chunked from olympia.amo.utils import chunked
from olympia.constants.activity import RETENTION_DAYS
from olympia.files.models import FileUpload from olympia.files.models import FileUpload
from olympia.scanners.models import ScannerResult from olympia.scanners.models import ScannerResult
from olympia.amo.models import FakeEmail
from . import tasks from . import tasks
from .sitemap import ( from .sitemap import (
get_sitemap_path, get_sitemap_path,
get_sitemaps,
get_sitemap_section_pages, get_sitemap_section_pages,
get_sitemaps,
render_index_xml, 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 already have been attempted by this point so api auth will only be tried for
anonymous (unauthenticated) requests.""" anonymous (unauthenticated) requests."""
from olympia.api.authentication import SessionIDAuthentication, JWTKeyAuthentication from olympia.api.authentication import JWTKeyAuthentication, SessionIDAuthentication
@functools.wraps(f) @functools.wraps(f)
def wrapper(request, *args, **kw): def wrapper(request, *args, **kw):

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

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

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

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

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

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

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

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

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

@ -3,8 +3,8 @@ import os
import subprocess import subprocess
from django.conf import settings 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.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 from olympia.lib.jingo_minify_helpers import ensure_path_exists

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

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

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

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

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

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

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

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

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

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

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

@ -1,5 +1,5 @@
import os
import io import io
import os
import socket import socket
import traceback import traceback
@ -7,13 +7,11 @@ from django.conf import settings
import celery import celery
import requests import requests
from django_statsd.clients import statsd from django_statsd.clients import statsd
from kombu import Connection from kombu import Connection
from PIL import Image from PIL import Image
import olympia.core.logger import olympia.core.logger
from olympia.amo.models import use_primary_db from olympia.amo.models import use_primary_db
from olympia.blocklist.tasks import monitor_remote_settings from olympia.blocklist.tasks import monitor_remote_settings
from olympia.search.utils import get_es 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.core.paginator import PageNotAnInteger
from django.db.models import Count, Max, Q from django.db.models import Count, Max, Q
from django.template import loader from django.template import loader
from django.utils.functional import cached_property
from django.urls import reverse from django.urls import reverse
from django.utils.functional import cached_property
from olympia import amo from olympia import amo
from olympia.addons.models import Addon, AddonCategory from olympia.addons.models import Addon, AddonCategory
from olympia.amo.reverse import get_url_prefix, override_url_prefix from olympia.amo.reverse import get_url_prefix, override_url_prefix
from olympia.amo.templatetags.jinja_helpers import absolutify from olympia.amo.templatetags.jinja_helpers import absolutify
from olympia.amo.utils import id_to_path from olympia.amo.utils import id_to_path
from olympia.bandwagon.models import Collection
from olympia.constants.categories import CATEGORIES from olympia.constants.categories import CATEGORIES
from olympia.constants.promoted import RECOMMENDED from olympia.constants.promoted import RECOMMENDED
from olympia.bandwagon.models import Collection
from olympia.promoted.models import PromotedAddon from olympia.promoted.models import PromotedAddon
from olympia.tags.models import AddonTag, Tag from olympia.tags.models import AddonTag, Tag
from olympia.users.models import UserProfile from olympia.users.models import UserProfile

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

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

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

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

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

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

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

@ -1,13 +1,13 @@
import os import os
import tempfile import tempfile
from unittest import mock
from django.conf import settings from django.conf import settings
from django.core.validators import ValidationError from django.core.validators import ValidationError
from unittest import mock
import pytest 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 ( from olympia.amo.utils import (
SafeStorage, SafeStorage,
escape_all, escape_all,

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

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

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

@ -1,35 +1,35 @@
import os
import io import io
import os
from datetime import datetime, timedelta from datetime import datetime, timedelta
from importlib import import_module from importlib import import_module
from unittest import mock
from django.conf import settings from django.conf import settings
from django.core.management import call_command from django.core.management import call_command
from django.core.management.base import CommandError from django.core.management.base import CommandError
from django.test.utils import override_settings from django.test.utils import override_settings
from unittest import mock
import pytest import pytest
from olympia.addons.models import Preview from olympia.addons.models import Preview
from olympia.amo.management.commands.get_changed_files import ( 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_addon_icons,
collect_editoral, collect_addon_previews,
collect_git,
collect_blocklist, 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.amo.utils import id_to_path
from olympia.blocklist.utils import datetime_to_ts from olympia.blocklist.utils import datetime_to_ts
from olympia.files.models import File, files_upload_to_callback from olympia.files.models import File, files_upload_to_callback
from olympia.git.utils import AddonGitRepository from olympia.git.utils import AddonGitRepository
from olympia.hero.models import PrimaryHeroImage 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): def sample_cron_job(*args):

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

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

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

@ -1,7 +1,7 @@
from ipaddress import IPv4Address, IPv6Address from ipaddress import IPv4Address, IPv6Address
from django.core import exceptions 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 django.test.utils import override_settings
from olympia.access.models import Group from olympia.access.models import Group

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

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

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

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

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

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

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

@ -1,5 +1,4 @@
import os import os
import pytest
from unittest.mock import Mock from unittest.mock import Mock
from django.conf import settings 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.test.utils import override_settings
from django.urls import reverse from django.urls import reverse
import pytest
from olympia import amo from olympia import amo
from olympia.addons.models import Addon from olympia.addons.models import Addon
from olympia.amo import models as amo_models from olympia.amo import models as amo_models

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

@ -1,12 +1,11 @@
import json import json
from unittest.mock import Mock, patch
from django.conf import settings from django.conf import settings
from django.test.utils import override_settings from django.test.utils import override_settings
import responses import responses
from unittest.mock import Mock, patch
from olympia.amo import monitors from olympia.amo import monitors
from olympia.amo.tests import TestCase 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 from django.core.paginator import EmptyPage, InvalidPage, PageNotAnInteger, Paginator
import pytest import pytest
from unittest.mock import MagicMock, Mock
from olympia.amo.pagination import ESPaginator from olympia.amo.pagination import ESPaginator
from olympia.amo.templatetags.jinja_helpers import PaginationRenderer from olympia.amo.templatetags.jinja_helpers import PaginationRenderer
from olympia.amo.tests import TestCase from olympia.amo.tests import TestCase

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -1,14 +1,14 @@
from django import shortcuts from django import shortcuts
from django.conf import settings from django.conf import settings
from django.urls import resolve, reverse, set_script_prefix
from django.test.client import Client, RequestFactory from django.test.client import Client, RequestFactory
from django.urls import resolve, reverse, set_script_prefix
import pytest import pytest
from olympia.amo import urlresolvers from olympia.amo import urlresolvers
from olympia.amo.middleware import LocaleAndAppURLMiddleware from olympia.amo.middleware import LocaleAndAppURLMiddleware
from olympia.amo.reverse import clean_url_prefixes, set_url_prefix 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 pytestmark = pytest.mark.django_db

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

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

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

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

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

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

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

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

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

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

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

@ -26,7 +26,7 @@ from olympia.api.serializers import SiteStatusSerializer
from olympia.users.models import UserProfile from olympia.users.models import UserProfile
from . import monitors 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 @never_cache
@ -147,7 +147,7 @@ def handler500(request, **kwargs):
@non_atomic_requests @non_atomic_requests
def csrf_failure(request, reason=''): 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 = { ctx = {
'reason': reason, 'reason': reason,

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

@ -4,16 +4,14 @@ from django.utils.encoding import force_str, smart_str
from django.utils.translation import gettext from django.utils.translation import gettext
import jwt import jwt
from rest_framework import exceptions from rest_framework import exceptions
from rest_framework.authentication import BaseAuthentication, get_authorization_header from rest_framework.authentication import BaseAuthentication, get_authorization_header
import olympia.core.logger import olympia.core.logger
from olympia import core from olympia import core
from olympia.accounts.verify import ( from olympia.accounts.verify import (
check_and_update_fxa_access_token,
IdentificationError, IdentificationError,
check_and_update_fxa_access_token,
) )
from olympia.api import jwt_auth from olympia.api import jwt_auth
from olympia.api.models import APIKey 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.http import Http404
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from rest_framework import exceptions from rest_framework import exceptions, status
from rest_framework import status
from rest_framework.response import Response from rest_framework.response import Response
from rest_framework.views import set_rollback from rest_framework.views import set_rollback

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