From 99bef9ecfa040a279476e3aedf92e79e10cca59f Mon Sep 17 00:00:00 2001 From: Stu Young Date: Wed, 15 May 2019 15:20:26 -0400 Subject: [PATCH] incr-295 (#20602) * run python modernize * run isort --- .../commands/delete_historical_verify_student_data.py | 6 +++++- .../management/commands/manual_verifications.py | 4 +++- .../management/commands/populate_expiry_date.py | 4 +++- .../commands/retry_failed_photo_verifications.py | 2 +- .../commands/send_verification_expiry_email.py | 6 ++++-- .../commands/tests/test_manual_verify_student.py | 10 +++++++--- .../commands/tests/test_populate_expiry_date.py | 9 ++++----- .../tests/test_send_verification_expiry_email.py | 9 ++++----- .../management/commands/tests/test_verify_student.py | 2 ++ 9 files changed, 33 insertions(+), 19 deletions(-) diff --git a/lms/djangoapps/verify_student/management/commands/delete_historical_verify_student_data.py b/lms/djangoapps/verify_student/management/commands/delete_historical_verify_student_data.py index 4681239771..ec30f5a58b 100644 --- a/lms/djangoapps/verify_student/management/commands/delete_historical_verify_student_data.py +++ b/lms/djangoapps/verify_student/management/commands/delete_historical_verify_student_data.py @@ -2,9 +2,13 @@ Command to delete all rows from the verify_student_historicalverificationdeadline table. """ +from __future__ import absolute_import + import logging + from lms.djangoapps.verify_student.models import VerificationDeadline -from openedx.core.djangoapps.util.row_delete import delete_rows, BaseDeletionCommand +from openedx.core.djangoapps.util.row_delete import BaseDeletionCommand, delete_rows + log = logging.getLogger(__name__) diff --git a/lms/djangoapps/verify_student/management/commands/manual_verifications.py b/lms/djangoapps/verify_student/management/commands/manual_verifications.py index 304042239a..2f2d5c6c56 100644 --- a/lms/djangoapps/verify_student/management/commands/manual_verifications.py +++ b/lms/djangoapps/verify_student/management/commands/manual_verifications.py @@ -1,12 +1,14 @@ """ Django admin commands related to verify_student """ +from __future__ import absolute_import + import logging import os from pprint import pformat -from django.core.management.base import BaseCommand, CommandError from django.contrib.auth.models import User +from django.core.management.base import BaseCommand, CommandError from lms.djangoapps.verify_student.models import ManualVerification from lms.djangoapps.verify_student.utils import earliest_allowed_verification_date diff --git a/lms/djangoapps/verify_student/management/commands/populate_expiry_date.py b/lms/djangoapps/verify_student/management/commands/populate_expiry_date.py index adf6db2125..0c56118b6a 100644 --- a/lms/djangoapps/verify_student/management/commands/populate_expiry_date.py +++ b/lms/djangoapps/verify_student/management/commands/populate_expiry_date.py @@ -1,6 +1,8 @@ """ Django admin command to populate expiry_date for approved verifications in SoftwareSecurePhotoVerification """ +from __future__ import absolute_import + import logging import time from datetime import timedelta @@ -8,9 +10,9 @@ from datetime import timedelta from django.conf import settings from django.core.management.base import BaseCommand from django.db.models import F -from util.query import use_read_replica_if_available from lms.djangoapps.verify_student.models import SoftwareSecurePhotoVerification +from util.query import use_read_replica_if_available logger = logging.getLogger(__name__) diff --git a/lms/djangoapps/verify_student/management/commands/retry_failed_photo_verifications.py b/lms/djangoapps/verify_student/management/commands/retry_failed_photo_verifications.py index 598c868286..fd4c3cfbe0 100644 --- a/lms/djangoapps/verify_student/management/commands/retry_failed_photo_verifications.py +++ b/lms/djangoapps/verify_student/management/commands/retry_failed_photo_verifications.py @@ -1,7 +1,7 @@ """ Django admin commands related to verify_student """ -from __future__ import print_function +from __future__ import absolute_import, print_function from django.core.management.base import BaseCommand diff --git a/lms/djangoapps/verify_student/management/commands/send_verification_expiry_email.py b/lms/djangoapps/verify_student/management/commands/send_verification_expiry_email.py index 1da6bfeb09..0b08cdc89a 100644 --- a/lms/djangoapps/verify_student/management/commands/send_verification_expiry_email.py +++ b/lms/djangoapps/verify_student/management/commands/send_verification_expiry_email.py @@ -1,6 +1,8 @@ """ Django admin command to send verification expiry email to learners """ +from __future__ import absolute_import + import logging import time from datetime import timedelta @@ -14,14 +16,14 @@ from django.urls import reverse from django.utils.timezone import now from edx_ace import ace from edx_ace.recipient import Recipient -from util.query import use_read_replica_if_available -from verify_student.message_types import VerificationExpiry from lms.djangoapps.verify_student.models import SoftwareSecurePhotoVerification from openedx.core.djangoapps.ace_common.template_context import get_base_template_context from openedx.core.djangoapps.lang_pref import LANGUAGE_KEY from openedx.core.djangoapps.user_api.preferences.api import get_user_preference from openedx.core.lib.celery.task_utils import emulate_http_request +from util.query import use_read_replica_if_available +from verify_student.message_types import VerificationExpiry logger = logging.getLogger(__name__) diff --git a/lms/djangoapps/verify_student/management/commands/tests/test_manual_verify_student.py b/lms/djangoapps/verify_student/management/commands/tests/test_manual_verify_student.py index 134386dbfb..170e15d131 100644 --- a/lms/djangoapps/verify_student/management/commands/tests/test_manual_verify_student.py +++ b/lms/djangoapps/verify_student/management/commands/tests/test_manual_verify_student.py @@ -2,16 +2,20 @@ Tests for django admin commands in the verify_student module """ +from __future__ import absolute_import + import logging import os import tempfile -from django.core.management import call_command, CommandError +import six +from django.core.management import CommandError, call_command from django.test import TestCase +from testfixtures import LogCapture + from lms.djangoapps.verify_student.models import ManualVerification from lms.djangoapps.verify_student.utils import earliest_allowed_verification_date from student.tests.factories import UserFactory -from testfixtures import LogCapture LOGGER_NAME = 'lms.djangoapps.verify_student.management.commands.manual_verifications' @@ -27,7 +31,7 @@ class TestVerifyStudentCommand(TestCase): self.user1 = UserFactory.create() self.user2 = UserFactory.create() self.user3 = UserFactory.create() - self.invalid_email = unicode('unknown@unknown.com') + self.invalid_email = six.text_type('unknown@unknown.com') self.create_email_ids_file( self.tmp_file_path, diff --git a/lms/djangoapps/verify_student/management/commands/tests/test_populate_expiry_date.py b/lms/djangoapps/verify_student/management/commands/tests/test_populate_expiry_date.py index 7c4f10b651..9337a2b1c3 100644 --- a/lms/djangoapps/verify_student/management/commands/tests/test_populate_expiry_date.py +++ b/lms/djangoapps/verify_student/management/commands/tests/test_populate_expiry_date.py @@ -2,6 +2,8 @@ Tests for django admin command `populate_expiry_date` in the verify_student module """ +from __future__ import absolute_import + from datetime import timedelta import boto @@ -9,15 +11,12 @@ from django.conf import settings from django.core.management import call_command from django.test import TestCase from mock import patch -from student.tests.factories import UserFactory from testfixtures import LogCapture from common.test.utils import MockS3Mixin from lms.djangoapps.verify_student.models import SoftwareSecurePhotoVerification -from lms.djangoapps.verify_student.tests.test_models import ( - FAKE_SETTINGS, - mock_software_secure_post -) +from lms.djangoapps.verify_student.tests.test_models import FAKE_SETTINGS, mock_software_secure_post +from student.tests.factories import UserFactory LOGGER_NAME = 'lms.djangoapps.verify_student.management.commands.populate_expiry_date' diff --git a/lms/djangoapps/verify_student/management/commands/tests/test_send_verification_expiry_email.py b/lms/djangoapps/verify_student/management/commands/tests/test_send_verification_expiry_email.py index dcbd7d960f..5f3a0beafd 100644 --- a/lms/djangoapps/verify_student/management/commands/tests/test_send_verification_expiry_email.py +++ b/lms/djangoapps/verify_student/management/commands/tests/test_send_verification_expiry_email.py @@ -2,6 +2,8 @@ Tests for django admin command `send_verification_expiry_email` in the verify_student module """ +from __future__ import absolute_import + from datetime import timedelta import boto @@ -12,15 +14,12 @@ from django.core.management import call_command from django.test import TestCase from django.utils.timezone import now from mock import patch -from student.tests.factories import UserFactory from testfixtures import LogCapture from common.test.utils import MockS3Mixin from lms.djangoapps.verify_student.models import SoftwareSecurePhotoVerification -from lms.djangoapps.verify_student.tests.test_models import ( - FAKE_SETTINGS, - mock_software_secure_post -) +from lms.djangoapps.verify_student.tests.test_models import FAKE_SETTINGS, mock_software_secure_post +from student.tests.factories import UserFactory LOGGER_NAME = 'lms.djangoapps.verify_student.management.commands.send_verification_expiry_email' diff --git a/lms/djangoapps/verify_student/management/commands/tests/test_verify_student.py b/lms/djangoapps/verify_student/management/commands/tests/test_verify_student.py index 468fa3d529..5f8fbd9979 100644 --- a/lms/djangoapps/verify_student/management/commands/tests/test_verify_student.py +++ b/lms/djangoapps/verify_student/management/commands/tests/test_verify_student.py @@ -3,6 +3,8 @@ Tests for django admin commands in the verify_student module Lots of imports from verify_student's model tests, since they cover similar ground """ +from __future__ import absolute_import + import boto from django.conf import settings from django.core.management import call_command