Commit 6cf48dab by Tyler Hallada

Run isort on openedx/

parent c6bcaad6
......@@ -4,14 +4,14 @@ import uuid
from django.http import HttpRequest
from django.template import VariableDoesNotExist
from django.test import override_settings
from edx_ace import Message, Recipient
from mock import patch
from edx_ace import Message, Recipient
from openedx.core.djangoapps.ace_common.templatetags.ace import (
_get_google_analytics_tracking_url,
ensure_url_is_absolute,
with_link_tracking,
google_analytics_tracking_pixel,
_get_google_analytics_tracking_url
with_link_tracking
)
from openedx.core.djangoapps.ace_common.tests.mixins import QueryStringAssertionMixin
from openedx.core.djangoapps.site_configuration.tests.factories import SiteFactory
......
......@@ -5,10 +5,11 @@ from django.test import override_settings
from openedx.core.djangoapps.ace_common.tests.mixins import QueryStringAssertionMixin
from openedx.core.djangoapps.ace_common.tracking import (
CampaignTrackingInfo,
DEFAULT_CAMPAIGN_SOURCE,
DEFAULT_CAMPAIGN_MEDIUM,
GoogleAnalyticsTrackingPixel)
DEFAULT_CAMPAIGN_SOURCE,
CampaignTrackingInfo,
GoogleAnalyticsTrackingPixel
)
from openedx.core.djangoapps.site_configuration.tests.factories import SiteConfigurationFactory
from openedx.core.djangolib.testing.utils import CacheIsolationTestCase
......
......@@ -3,10 +3,9 @@ Tests for the `api_admin` api module.
"""
import json
from rest_framework.reverse import reverse
from django.contrib.auth.models import User
from django.test import TestCase
from rest_framework.reverse import reverse
from openedx.core.djangoapps.api_admin.tests import factories
from openedx.core.djangolib.testing.utils import skip_unless_lms
......
......@@ -2,16 +2,15 @@
API Views.
"""
from django_filters.rest_framework import DjangoFilterBackend
from edx_rest_framework_extensions.authentication import JwtAuthentication
from rest_framework.authentication import SessionAuthentication
from rest_framework.permissions import IsAuthenticated
from rest_framework.generics import ListAPIView
from rest_framework.permissions import IsAuthenticated
from rest_framework_oauth.authentication import OAuth2Authentication
from openedx.core.djangoapps.api_admin.api.filters import IsOwnerOrStaffFilterBackend
from openedx.core.djangoapps.api_admin.api.v1 import serializers as api_access_serializers
from openedx.core.djangoapps.api_admin.models import ApiAccessRequest
from openedx.core.djangoapps.api_admin.api.filters import IsOwnerOrStaffFilterBackend
class ApiAccessRequestView(ListAPIView):
......
......@@ -3,8 +3,10 @@ Command to delete all rows from the api_admin_historicalapiaccessrequest table.
"""
import logging
from openedx.core.djangoapps.api_admin.models import ApiAccessRequest
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__)
......
......@@ -13,9 +13,9 @@ from django.db import models
from django.db.models.signals import post_save, pre_save
from django.dispatch import receiver
from django.utils.translation import ugettext as _
from model_utils.models import TimeStampedModel
from edxmako.shortcuts import render_to_string
from model_utils.models import TimeStampedModel
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
log = logging.getLogger(__name__)
......
"""Factories for API management."""
import factory
from factory.fuzzy import FuzzyInteger, FuzzyText
from factory.django import DjangoModelFactory
from factory.fuzzy import FuzzyInteger, FuzzyText
from oauth2_provider.models import get_application_model
from microsite_configuration.tests.factories import SiteFactory
from openedx.core.djangoapps.api_admin.models import ApiAccessRequest, Catalog
from student.tests.factories import UserFactory
Application = get_application_model() # pylint: disable=invalid-name
......
......@@ -2,13 +2,13 @@
from smtplib import SMTPException
import ddt
import mock
from django.db import IntegrityError
from django.test import TestCase
import mock
from microsite_configuration.tests.factories import SiteFactory
from openedx.core.djangoapps.api_admin.models import ApiAccessRequest, ApiAccessConfig
from openedx.core.djangoapps.api_admin.models import log as model_log
from openedx.core.djangoapps.api_admin.models import ApiAccessConfig, ApiAccessRequest
from openedx.core.djangoapps.api_admin.tests.factories import ApiAccessRequestFactory
from openedx.core.djangolib.testing.utils import skip_unless_lms
from student.tests.factories import UserFactory
......
......@@ -5,7 +5,8 @@ Django-OAuth2-Provider.
# pylint: disable=protected-access
from unittest import skip, expectedFailure
from unittest import expectedFailure, skip
from django.test.client import RequestFactory
from openedx.core.djangoapps.oauth_dispatch import adapters
......
......@@ -4,19 +4,19 @@ Tests for OAuth token exchange forms
"""
import unittest
import httpretty
import social_django.utils as social_utils
from django.contrib.sessions.middleware import SessionMiddleware
from django.test import TestCase
from django.test.client import RequestFactory
import httpretty
from provider import scope
from social_django.models import Partial
import social_django.utils as social_utils
from third_party_auth.tests.utils import ThirdPartyOAuthTestMixinFacebook, ThirdPartyOAuthTestMixinGoogle
from ..forms import AccessTokenExchangeForm
from .utils import AccessTokenExchangeTestMixin, TPA_FEATURE_ENABLED, TPA_FEATURES_KEY
from .mixins import DOPAdapterMixin, DOTAdapterMixin
from .utils import TPA_FEATURE_ENABLED, TPA_FEATURES_KEY, AccessTokenExchangeTestMixin
class AccessTokenExchangeFormTest(AccessTokenExchangeTestMixin):
......
......@@ -4,25 +4,26 @@ Tests for OAuth token exchange views
# pylint: disable=no-member
from datetime import timedelta
import json
import mock
import unittest
from datetime import timedelta
import ddt
import httpretty
import mock
import provider.constants
from django.conf import settings
from django.core.urlresolvers import reverse
from django.test import TestCase
import httpretty
import provider.constants
from provider.oauth2.models import AccessToken, Client
from rest_framework.test import APIClient
from social_django.models import Partial
from student.tests.factories import UserFactory
from third_party_auth.tests.utils import ThirdPartyOAuthTestMixinFacebook, ThirdPartyOAuthTestMixinGoogle
from .mixins import DOPAdapterMixin, DOTAdapterMixin
from .utils import AccessTokenExchangeTestMixin, TPA_FEATURE_ENABLED, TPA_FEATURES_KEY
from .utils import TPA_FEATURE_ENABLED, TPA_FEATURES_KEY, AccessTokenExchangeTestMixin
@ddt.ddt
......
......@@ -3,11 +3,10 @@ Test utilities for OAuth access token exchange
"""
from django.conf import settings
from social_django.models import UserSocialAuth, Partial
from social_django.models import Partial, UserSocialAuth
from third_party_auth.tests.utils import ThirdPartyOAuthTestMixin
TPA_FEATURES_KEY = 'ENABLE_THIRD_PARTY_AUTH'
TPA_FEATURE_ENABLED = TPA_FEATURES_KEY in settings.FEATURES
......
......@@ -2,8 +2,8 @@
Bookmarks Python API.
"""
from django.conf import settings
from eventtracking import tracker
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.exceptions import ItemNotFoundError
......
......@@ -2,12 +2,14 @@
Factories for Bookmark models.
"""
from functools import partial
import factory
from factory.django import DjangoModelFactory
from functools import partial
from opaque_keys.edx.locator import CourseLocator
from student.tests.factories import UserFactory
from opaque_keys.edx.locator import CourseLocator
from ..models import Bookmark, XBlockCache
COURSE_KEY = CourseLocator(u'edX', u'test_course', u'test')
......
......@@ -3,20 +3,18 @@ Tests for bookmarks api.
"""
import ddt
import pytest
from mock import patch
from nose.plugins.attrib import attr
from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist
from mock import patch
from nose.plugins.attrib import attr
from opaque_keys.edx.keys import UsageKey
from openedx.core.djangoapps.bookmarks.api import BookmarksLimitReachedError
from openedx.core.djangolib.testing.utils import skip_unless_lms
from xmodule.modulestore.exceptions import ItemNotFoundError
from .. import api
from ..models import Bookmark
from openedx.core.djangoapps.bookmarks.api import BookmarksLimitReachedError
from .test_models import BookmarksTestsBase
......
......@@ -7,6 +7,7 @@ from nose.plugins.attrib import attr
from opaque_keys.edx.keys import UsageKey
from openedx.core.djangolib.testing.utils import skip_unless_lms
from ..services import BookmarksService
from .test_models import BookmarksTestsBase
......
......@@ -6,7 +6,8 @@ import pytest
from nose.plugins.attrib import attr
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.tests.factories import check_mongo_calls, ItemFactory
from xmodule.modulestore.tests.factories import ItemFactory, check_mongo_calls
from ..models import XBlockCache
from ..tasks import _calculate_course_xblocks_data, _update_xblocks_cache
from .test_models import BookmarksTestsBase
......
......@@ -14,6 +14,7 @@ from rest_framework.test import APIClient
from openedx.core.djangolib.testing.utils import skip_unless_lms
from xmodule.modulestore import ModuleStoreEnum
from .test_api import BookmarkApiEventTestMixin
from .test_models import BookmarksTestsBase
......
......@@ -6,6 +6,7 @@ https://openedx.atlassian.net/wiki/display/TNL/Bookmarks+API
"""
import logging
import eventtracking
from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist
from django.utils.translation import ugettext as _
......@@ -19,7 +20,6 @@ from rest_framework.response import Response
from rest_framework.views import APIView
from rest_framework_oauth.authentication import OAuth2Authentication
import eventtracking
from openedx.core.djangoapps.bookmarks.api import BookmarksLimitReachedError
from openedx.core.lib.api.paginators import DefaultPagination
from openedx.core.lib.api.permissions import IsUserInUrl
......
......@@ -4,8 +4,7 @@ automatically caching template fragments.
"""
from django import template
from django.core.cache import cache
from django.template import Node, TemplateSyntaxError, Variable
from django.template import resolve_variable
from django.template import Node, TemplateSyntaxError, Variable, resolve_variable
register = template.Library() # pylint: disable=invalid-name
......
......@@ -6,10 +6,7 @@ from django.contrib.sites.models import Site
from django.core.cache import cache
from django.core.management import BaseCommand
from openedx.core.djangoapps.catalog.cache import (
PROGRAM_CACHE_KEY_TPL,
SITE_PROGRAM_UUIDS_CACHE_KEY_TPL
)
from openedx.core.djangoapps.catalog.cache import PROGRAM_CACHE_KEY_TPL, SITE_PROGRAM_UUIDS_CACHE_KEY_TPL
from openedx.core.djangoapps.catalog.models import CatalogIntegration
from openedx.core.djangoapps.catalog.utils import create_catalog_api_client
......
"""
Sync course runs from catalog service.
"""
from collections import namedtuple
import logging
from collections import namedtuple
from django.core.management.base import BaseCommand
from opaque_keys.edx.keys import CourseKey
......
......@@ -4,10 +4,7 @@ import httpretty
from django.core.cache import cache
from django.core.management import call_command
from openedx.core.djangoapps.catalog.cache import (
PROGRAM_CACHE_KEY_TPL,
SITE_PROGRAM_UUIDS_CACHE_KEY_TPL
)
from openedx.core.djangoapps.catalog.cache import PROGRAM_CACHE_KEY_TPL, SITE_PROGRAM_UUIDS_CACHE_KEY_TPL
from openedx.core.djangoapps.catalog.tests.factories import ProgramFactory
from openedx.core.djangoapps.catalog.tests.mixins import CatalogIntegrationMixin
from openedx.core.djangoapps.site_configuration.tests.mixins import SiteMixin
......
......@@ -3,11 +3,10 @@ Tests for the sync course runs management command.
"""
import ddt
import mock
from django.core.management import call_command
from openedx.core.djangoapps.catalog.tests.factories import CourseRunFactory
from openedx.core.djangoapps.catalog.management.commands.sync_course_runs import Command as sync_command
from openedx.core.djangoapps.catalog.tests.factories import CourseRunFactory
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
......
"""Factories for generating fake catalog data."""
import uuid
# pylint: disable=missing-docstring, invalid-name
from functools import partial
import factory
import uuid
from faker import Faker
fake = Faker()
VERIFIED_MODE = 'verified'
......
......@@ -7,16 +7,20 @@ import mock
from django.contrib.auth import get_user_model
from django.core.cache import cache
from django.test import TestCase, override_settings
from student.tests.factories import UserFactory
from openedx.core.djangoapps.catalog.cache import PROGRAM_CACHE_KEY_TPL, SITE_PROGRAM_UUIDS_CACHE_KEY_TPL
from openedx.core.djangoapps.catalog.models import CatalogIntegration
from openedx.core.djangoapps.catalog.tests.factories import CourseFactory, CourseRunFactory, ProgramFactory, ProgramTypeFactory
from openedx.core.djangoapps.catalog.tests.factories import (
CourseFactory,
CourseRunFactory,
ProgramFactory,
ProgramTypeFactory
)
from openedx.core.djangoapps.catalog.tests.mixins import CatalogIntegrationMixin
from openedx.core.djangoapps.catalog.utils import (
get_course_run_details,
get_course_runs,
get_course_runs_for_course,
get_course_run_details,
get_currency_data,
get_program_types,
get_programs,
......@@ -24,6 +28,7 @@ from openedx.core.djangoapps.catalog.utils import (
)
from openedx.core.djangoapps.site_configuration.tests.factories import SiteFactory
from openedx.core.djangolib.testing.utils import CacheIsolationTestCase, skip_unless_lms
from student.tests.factories import UserFactory
UTILS_MODULE = 'openedx.core.djangoapps.catalog.utils'
User = get_user_model() # pylint: disable=invalid-name
......
......@@ -7,10 +7,7 @@ from django.core.cache import cache
from django.core.exceptions import ObjectDoesNotExist
from edx_rest_api_client.client import EdxRestApiClient
from openedx.core.djangoapps.catalog.cache import (
PROGRAM_CACHE_KEY_TPL,
SITE_PROGRAM_UUIDS_CACHE_KEY_TPL
)
from openedx.core.djangoapps.catalog.cache import PROGRAM_CACHE_KEY_TPL, SITE_PROGRAM_UUIDS_CACHE_KEY_TPL
from openedx.core.djangoapps.catalog.models import CatalogIntegration
from openedx.core.lib.edx_api_utils import get_edx_api_data
from openedx.core.lib.token_utils import JwtBuilder
......
......@@ -2,6 +2,7 @@
Dummy factories for tests
"""
from factory.django import DjangoModelFactory
from openedx.core.djangoapps.ccxcon.models import CCXCon
......
......@@ -3,24 +3,19 @@ Unit tests for the API module
"""
import datetime
import urlparse
import mock
import pytz
import urlparse
from nose.plugins.attrib import attr
from opaque_keys.edx.keys import CourseKey
from openedx.core.djangoapps.ccxcon import api as ccxconapi
from student.tests.factories import AdminFactory
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.tests.django_utils import (
SharedModuleStoreTestCase,
TEST_DATA_SPLIT_MODULESTORE
)
from xmodule.modulestore.tests.factories import (
CourseFactory,
ItemFactory,
)
from xmodule.modulestore.tests.django_utils import TEST_DATA_SPLIT_MODULESTORE, SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
from openedx.core.djangoapps.ccxcon import api as ccxconapi
from .factories import CcxConFactory
......
......@@ -3,11 +3,11 @@ Test for contentstore signals receiver
"""
import mock
from nose.plugins.attrib import attr
from django.test import TestCase
from nose.plugins.attrib import attr
from opaque_keys.edx.keys import CourseKey
from xmodule.modulestore.django import modulestore, SignalHandler
from xmodule.modulestore.django import SignalHandler, modulestore
@attr(shard=2)
......
......@@ -3,11 +3,10 @@ Tests for the CCXCon celery tasks
"""
import mock
from nose.plugins.attrib import attr
from django.test import TestCase
from nose.plugins.attrib import attr
from opaque_keys.edx.keys import CourseKey
from openedx.core.djangoapps.ccxcon import api, tasks
......
......@@ -9,7 +9,6 @@ from certificates.models import CertificateWhitelist
from openedx.core.djangoapps.certificates.config import waffle
from student.models import CourseEnrollment
SWITCHES = waffle.waffle()
......
import itertools
from contextlib import contextmanager
from datetime import datetime, timedelta
import itertools
import ddt
import pytz
......
""" Commerce API Service. """
from django.conf import settings
from edx_rest_api_client.client import EdxRestApiClient
from eventtracking import tracker
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from openedx.core.lib.token_utils import JwtBuilder
......
"""
Django Admin for Block Structures.
"""
from config_models.admin import ConfigurationModelAdmin
from django.contrib import admin
from config_models.admin import ConfigurationModelAdmin
from .config.models import BlockStructureConfiguration
......
......@@ -2,6 +2,7 @@
Higher order functions built on the BlockStructureManager to interact with a django cache.
"""
from django.core.cache import cache
from xmodule.modulestore.django import modulestore
from .manager import BlockStructureManager
......
......@@ -12,11 +12,10 @@ from copy import deepcopy
from functools import partial
from logging import getLogger
from openedx.core.lib.graph_traversals import traverse_topologically, traverse_post_order
from openedx.core.lib.graph_traversals import traverse_post_order, traverse_topologically
from .exceptions import TransformerException
logger = getLogger(__name__) # pylint: disable=invalid-name
......
"""
Models for configuration of Block Structures.
"""
from django.db.models import IntegerField
from config_models.models import ConfigurationModel
from django.db.models import IntegerField
class BlockStructureConfiguration(ConfigurationModel):
......
"""
Module for factory class for BlockStructure objects.
"""
from .block_structure import BlockStructureModulestoreData, BlockStructureBlockData
from .block_structure import BlockStructureBlockData, BlockStructureModulestoreData
class BlockStructureFactory(object):
......
......@@ -4,18 +4,17 @@ Command to load course blocks.
import logging
from django.core.management.base import BaseCommand
from xmodule.modulestore.django import modulestore
import openedx.core.djangoapps.content.block_structure.api as api
from openedx.core.djangoapps.content.block_structure.config import STORAGE_BACKING_FOR_CACHE, waffle
import openedx.core.djangoapps.content.block_structure.tasks as tasks
import openedx.core.djangoapps.content.block_structure.store as store
import openedx.core.djangoapps.content.block_structure.tasks as tasks
from openedx.core.djangoapps.content.block_structure.config import STORAGE_BACKING_FOR_CACHE, waffle
from openedx.core.lib.command_utils import (
get_mutually_exclusive_required_option,
validate_dependent_option,
parse_course_keys,
validate_dependent_option
)
from xmodule.modulestore.django import modulestore
log = logging.getLogger(__name__)
......
"""
Tests for generate_course_blocks management command.
"""
import itertools
import ddt
from django.core.management.base import CommandError
import itertools
from mock import patch
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
from .. import generate_course_blocks
from openedx.core.djangoapps.content.block_structure.tests.helpers import (
is_course_in_block_structure_cache,
is_course_in_block_structure_storage,
is_course_in_block_structure_storage
)
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
from .. import generate_course_blocks
@ddt.ddt
......
......@@ -5,7 +5,7 @@ BlockStructures.
from contextlib import contextmanager
from . import config
from .exceptions import UsageKeyNotInBlockStructure, TransformerDataIncompatible, BlockStructureNotFound
from .exceptions import BlockStructureNotFound, TransformerDataIncompatible, UsageKeyNotInBlockStructure
from .factory import BlockStructureFactory
from .store import BlockStructureStore
from .transformers import BlockStructureTransformers
......
......@@ -4,20 +4,20 @@ Models used by the block structure framework.
from contextlib import contextmanager
from datetime import datetime
from logging import getLogger
from django.conf import settings
from django.core.exceptions import SuspiciousOperation
from django.core.files.base import ContentFile
from django.db import models, transaction
from logging import getLogger
from model_utils.models import TimeStampedModel
from openedx.core.djangoapps.xmodule_django.models import UsageKeyWithRunField
from openedx.core.storage import get_storage
from . import config
from .exceptions import BlockStructureNotFound
log = getLogger(__name__)
......
......@@ -3,11 +3,10 @@ Signal handlers for invalidating cached data.
"""
from django.conf import settings
from django.dispatch.dispatcher import receiver
from opaque_keys.edx.locator import LibraryLocator
from xmodule.modulestore.django import SignalHandler
from opaque_keys.edx.locator import LibraryLocator
from . import config
from .api import clear_course_from_cache
from .tasks import update_course_in_cache_v2
......
......@@ -13,7 +13,6 @@ from .factory import BlockStructureFactory
from .models import BlockStructureModel
from .transformer_registry import TransformerRegistry
logger = getLogger(__name__) # pylint: disable=C0103
......
......@@ -3,17 +3,16 @@ Asynchronous tasks related to the Course Blocks sub-application.
"""
import logging
from capa.responsetypes import LoncapaProblemError
from celery.task import task
from django.conf import settings
from lxml.etree import XMLSyntaxError
from edxval.api import ValInternalError
from lxml.etree import XMLSyntaxError
from opaque_keys.edx.keys import CourseKey
from xmodule.modulestore.exceptions import ItemNotFoundError
from capa.responsetypes import LoncapaProblemError
from openedx.core.djangoapps.content.block_structure import api
from openedx.core.djangoapps.content.block_structure.config import STORAGE_BACKING_FOR_CACHE, waffle
from xmodule.modulestore.exceptions import ItemNotFoundError
log = logging.getLogger('edx.celery.task')
......
......@@ -2,11 +2,12 @@
Common utilities for tests in block_structure module
"""
from contextlib import contextmanager
from mock import patch
from xmodule.modulestore.exceptions import ItemNotFoundError
from uuid import uuid4
from opaque_keys.edx.locator import CourseLocator, BlockUsageLocator
from mock import patch
from opaque_keys.edx.locator import BlockUsageLocator, CourseLocator
from xmodule.modulestore.exceptions import ItemNotFoundError
from ..api import get_cache
from ..block_structure import BlockStructureBlockData
......
"""
Tests for block_structure.py
"""
import itertools
# pylint: disable=protected-access
from collections import namedtuple
from copy import deepcopy
from unittest import TestCase
import ddt
import itertools
from nose.plugins.attrib import attr
from unittest import TestCase
from openedx.core.lib.graph_traversals import traverse_post_order
from ..block_structure import BlockStructure, BlockStructureModulestoreData
from ..exceptions import TransformerException
from .helpers import MockXBlock, MockTransformer, ChildrenMapTestMixin
from .helpers import ChildrenMapTestMixin, MockTransformer, MockXBlock
@attr(shard=2)
......
......@@ -3,14 +3,13 @@ Tests for block_structure_factory.py
"""
from django.test import TestCase
from nose.plugins.attrib import attr
from xmodule.modulestore.exceptions import ItemNotFoundError
from ..store import BlockStructureStore
from ..exceptions import BlockStructureNotFound
from ..factory import BlockStructureFactory
from .helpers import (
MockCache, MockModulestoreFactory, ChildrenMapTestMixin
)
from ..store import BlockStructureStore
from .helpers import ChildrenMapTestMixin, MockCache, MockModulestoreFactory
@attr(shard=2)
......
......@@ -7,13 +7,16 @@ from nose.plugins.attrib import attr
from ..block_structure import BlockStructureBlockData
from ..config import RAISE_ERROR_WHEN_NOT_FOUND, STORAGE_BACKING_FOR_CACHE, waffle
from ..exceptions import UsageKeyNotInBlockStructure, BlockStructureNotFound
from ..exceptions import BlockStructureNotFound, UsageKeyNotInBlockStructure
from ..manager import BlockStructureManager
from ..transformers import BlockStructureTransformers
from .helpers import (
MockModulestoreFactory, MockCache, MockTransformer,
ChildrenMapTestMixin, UsageKeyFactoryMixin,
mock_registered_transformers,
ChildrenMapTestMixin,
MockCache,
MockModulestoreFactory,
MockTransformer,
UsageKeyFactoryMixin,
mock_registered_transformers
)
......
"""
Unit tests for Block Structure models.
"""
from itertools import product
from uuid import uuid4
# pylint: disable=protected-access
import ddt
from django.core.exceptions import SuspiciousOperation
from django.test import TestCase
from django.utils.timezone import now
from itertools import product
from mock import patch, Mock
from uuid import uuid4
from opaque_keys.edx.locator import CourseLocator, BlockUsageLocator
from mock import Mock, patch
from opaque_keys.edx.locator import BlockUsageLocator, CourseLocator
from ..config import PRUNE_OLD_VERSIONS, waffle
from ..exceptions import BlockStructureNotFound
......
......@@ -3,8 +3,8 @@ Unit tests for the Course Blocks signals
"""
import ddt
from mock import patch
from opaque_keys.edx.locator import CourseLocator, LibraryLocator
from opaque_keys.edx.locator import LibraryLocator, CourseLocator
from xmodule.modulestore.exceptions import ItemNotFoundError
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
......
......@@ -10,7 +10,7 @@ from ..config import STORAGE_BACKING_FOR_CACHE, waffle
from ..config.models import BlockStructureConfiguration
from ..exceptions import BlockStructureNotFound
from ..store import BlockStructureStore
from .helpers import ChildrenMapTestMixin, UsageKeyFactoryMixin, MockCache, MockTransformer
from .helpers import ChildrenMapTestMixin, MockCache, MockTransformer, UsageKeyFactoryMixin
@attr(shard=2)
......
......@@ -2,12 +2,13 @@
Tests for transformer_registry.py
"""
from unittest import TestCase
import ddt
from nose.plugins.attrib import attr
from unittest import TestCase
from ..transformer_registry import TransformerRegistry
from .helpers import MockTransformer, mock_registered_transformers, clear_registered_transformers_cache
from .helpers import MockTransformer, clear_registered_transformers_cache, mock_registered_transformers
class TestTransformer1(MockTransformer):
......
"""
Tests for transformers.py
"""
from unittest import TestCase
from mock import MagicMock, patch
from nose.plugins.attrib import attr
from unittest import TestCase
from ..block_structure import BlockStructureModulestoreData
from ..exceptions import TransformerException, TransformerDataIncompatible
from ..exceptions import TransformerDataIncompatible, TransformerException
from ..transformers import BlockStructureTransformers
from .helpers import (
ChildrenMapTestMixin, MockTransformer, MockFilteringTransformer, mock_registered_transformers
)
from .helpers import ChildrenMapTestMixin, MockFilteringTransformer, MockTransformer, mock_registered_transformers
@attr(shard=2)
......
......@@ -4,11 +4,10 @@ Module for a collection of BlockStructureTransformers.
import functools
from logging import getLogger
from .exceptions import TransformerException, TransformerDataIncompatible
from .exceptions import TransformerDataIncompatible, TransformerException
from .transformer import FilteringTransformerMixin
from .transformer_registry import TransformerRegistry
logger = getLogger(__name__) # pylint: disable=C0103
......
......@@ -3,9 +3,9 @@ Django admin page for CourseOverviews, the basic metadata about a course that
is used in user dashboard queries and other places where you need info like
name, and start dates, but don't actually need to crawl into course content.
"""
from config_models.admin import ConfigurationModelAdmin
from django.contrib import admin
from config_models.admin import ConfigurationModelAdmin
from .models import CourseOverview, CourseOverviewImageConfig, CourseOverviewImageSet
......
......@@ -5,7 +5,6 @@ Command to load course overviews.
import logging
from django.core.management.base import BaseCommand, CommandError
from opaque_keys import InvalidKeyError
from openedx.core.djangoapps.content.course_overviews.tasks import (
......@@ -15,7 +14,6 @@ from openedx.core.djangoapps.content.course_overviews.tasks import (
enqueue_async_course_overview_update_tasks
)
log = logging.getLogger(__name__)
......
......@@ -7,7 +7,6 @@ from nose.plugins.attrib import attr
from openedx.core.djangoapps.content.course_overviews.management.commands import generate_course_overview
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
......
......@@ -5,26 +5,25 @@ import json
import logging
from urlparse import urlparse, urlunparse
from ccx_keys.locator import CCXLocator
from config_models.models import ConfigurationModel
from django.conf import settings
from django.db import models, transaction
from django.db.models.fields import BooleanField, DateTimeField, DecimalField, TextField, FloatField, IntegerField
from django.db.models.fields import BooleanField, DateTimeField, DecimalField, FloatField, IntegerField, TextField
from django.db.utils import IntegrityError
from django.template import defaultfilters
from ccx_keys.locator import CCXLocator
from model_utils.models import TimeStampedModel
from config_models.models import ConfigurationModel
from lms.djangoapps import django_comment_client
from openedx.core.djangoapps.catalog.models import CatalogIntegration
from openedx.core.djangoapps.lang_pref.api import get_closest_released_language
from openedx.core.djangoapps.models.course_details import CourseDetails
from openedx.core.djangoapps.xmodule_django.models import CourseKeyField, UsageKeyField
from static_replace.models import AssetBaseUrlConfig
from xmodule import course_metadata_utils, block_metadata_utils
from xmodule.course_module import CourseDescriptor, DEFAULT_START_DATE
from xmodule import block_metadata_utils, course_metadata_utils
from xmodule.course_module import DEFAULT_START_DATE, CourseDescriptor
from xmodule.error_module import ErrorDescriptor
from xmodule.modulestore.django import modulestore
from openedx.core.djangoapps.xmodule_django.models import CourseKeyField, UsageKeyField
log = logging.getLogger(__name__)
......
......@@ -5,10 +5,11 @@ import logging
from django.dispatch.dispatcher import receiver
from .models import CourseOverview
from openedx.core.djangoapps.signals.signals import COURSE_PACING_CHANGED, COURSE_START_DATE_CHANGED
from xmodule.modulestore.django import SignalHandler
from .models import CourseOverview
LOG = logging.getLogger(__name__)
......
......@@ -3,12 +3,10 @@ import logging
from celery import task
from celery_utils.persist_on_failure import LoggedPersistOnFailureTask
from django.conf import settings
from opaque_keys.edx.keys import CourseKey
from xmodule.modulestore.django import modulestore
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
from xmodule.modulestore.django import modulestore
log = logging.getLogger(__name__)
......
......@@ -2,9 +2,9 @@ import json
import factory
from factory.django import DjangoModelFactory
from opaque_keys.edx.locator import CourseLocator
from ..models import CourseOverview
from opaque_keys.edx.locator import CourseLocator
class CourseOverviewFactory(DjangoModelFactory):
......
"""
Tests for course_overviews app.
"""
from cStringIO import StringIO
import datetime
import ddt
import itertools
import math
from cStringIO import StringIO
import ddt
import mock
from nose.plugins.attrib import attr
import pytz
from django.conf import settings
from django.db.utils import IntegrityError
from django.test.utils import override_settings
from django.utils import timezone
from nose.plugins.attrib import attr
from PIL import Image
from lms.djangoapps.certificates.api import get_active_web_certificate
......@@ -23,13 +23,13 @@ from openedx.core.djangoapps.models.course_details import CourseDetails
from openedx.core.lib.courses import course_image_url
from static_replace.models import AssetBaseUrlConfig
from xmodule.assetstore.assetmgr import AssetManager
from xmodule.contentstore.django import contentstore
from xmodule.contentstore.content import StaticContent
from xmodule.contentstore.django import contentstore
from xmodule.course_metadata_utils import DEFAULT_START_DATE
from xmodule.course_module import (
CATALOG_VISIBILITY_CATALOG_AND_ABOUT,
CATALOG_VISIBILITY_ABOUT,
CATALOG_VISIBILITY_NONE,
CATALOG_VISIBILITY_CATALOG_AND_ABOUT,
CATALOG_VISIBILITY_NONE
)
from xmodule.error_module import ErrorDescriptor
from xmodule.modulestore import ModuleStoreEnum
......@@ -37,7 +37,7 @@ from xmodule.modulestore.django import modulestore
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory, check_mongo_calls_range
from ..models import CourseOverview, CourseOverviewImageSet, CourseOverviewImageConfig
from ..models import CourseOverview, CourseOverviewImageConfig, CourseOverviewImageSet
from .factories import CourseOverviewFactory
......
import datetime
import ddt
from mock import patch
from nose.plugins.attrib import attr
......
......@@ -6,13 +6,15 @@ of the tricky interactions between DRF and the code.
Most of that information is available by accessing the course objects directly.
"""
from collections import OrderedDict
from openedx.core.lib.exceptions import CourseNotFoundError
from .serializers import GradingPolicySerializer, CourseStructureSerializer
from .errors import CourseStructureNotAvailableError
from openedx.core.djangoapps.content.course_structures import models, tasks
from openedx.core.lib.exceptions import CourseNotFoundError
from util.cache import cache
from xmodule.modulestore.django import modulestore
from .errors import CourseStructureNotAvailableError
from .serializers import CourseStructureSerializer, GradingPolicySerializer
def _retrieve_course(course_key):
"""Retrieves the course for the given course key.
......
"""
Course Structure api.py tests
"""
from .api import course_structure
import mock
from django.core import cache
from openedx.core.djangoapps.content.course_structures.signals import listen_for_course_publish
from xmodule.modulestore.django import SignalHandler
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
import mock
from django.core import cache
from .api import course_structure
class CourseStructureApiTests(ModuleStoreTestCase):
......
......@@ -3,13 +3,12 @@ Django ORM model specifications for the Course Structures sub-application
"""
import json
import logging
from collections import OrderedDict
from model_utils.models import TimeStampedModel
from util.models import CompressedTextField
from openedx.core.djangoapps.xmodule_django.models import CourseKeyField, UsageKey
from util.models import CompressedTextField
logger = logging.getLogger(__name__) # pylint: disable=invalid-name
......
......@@ -6,8 +6,8 @@ import logging
from celery.task import task
from opaque_keys.edx.keys import CourseKey
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.django import modulestore
log = logging.getLogger('edx.celery.task')
......
......@@ -2,15 +2,16 @@
Course Structure Content sub-application test cases
"""
import json
from nose.plugins.attrib import attr
from xmodule.modulestore.django import SignalHandler
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
from openedx.core.djangoapps.content.course_structures.models import CourseStructure
from openedx.core.djangoapps.content.course_structures.signals import listen_for_course_publish
from openedx.core.djangoapps.content.course_structures.tasks import _generate_course_structure, update_course_structure
from openedx.core.djangoapps.xmodule_django.models import UsageKey
from xmodule.modulestore.django import SignalHandler
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
class SignalDisconnectTestMixin(object):
......
......@@ -2,29 +2,37 @@
Middleware to serve assets.
"""
import logging
import datetime
log = logging.getLogger(__name__)
try:
import newrelic.agent
except ImportError:
newrelic = None # pylint: disable=invalid-name
from django.http import (
HttpResponse, HttpResponseNotModified, HttpResponseForbidden,
HttpResponseBadRequest, HttpResponseNotFound, HttpResponsePermanentRedirect)
from student.models import CourseEnrollment
import logging
from xmodule.assetstore.assetmgr import AssetManager
from xmodule.contentstore.content import StaticContent, XASSET_LOCATION_TAG
from xmodule.modulestore import InvalidLocationError
from django.http import (
HttpResponse,
HttpResponseBadRequest,
HttpResponseForbidden,
HttpResponseNotFound,
HttpResponseNotModified,
HttpResponsePermanentRedirect
)
from opaque_keys import InvalidKeyError
from opaque_keys.edx.locator import AssetLocator
from openedx.core.djangoapps.header_control import force_header_for_response
from .caching import get_cached_content, set_cached_content
from xmodule.modulestore.exceptions import ItemNotFoundError
from student.models import CourseEnrollment
from xmodule.assetstore.assetmgr import AssetManager
from xmodule.contentstore.content import XASSET_LOCATION_TAG, StaticContent
from xmodule.exceptions import NotFoundError
from xmodule.modulestore import InvalidLocationError
from xmodule.modulestore.exceptions import ItemNotFoundError
from .caching import get_cached_content, set_cached_content
from .models import CdnUserAgentsConfig, CourseAssetCacheTtlConfig
log = logging.getLogger(__name__)
try:
import newrelic.agent
except ImportError:
newrelic = None # pylint: disable=invalid-name
from .models import CourseAssetCacheTtlConfig, CdnUserAgentsConfig
# TODO: Soon as we have a reasonable way to serialize/deserialize AssetKeys, we need
# to change this file so instead of using course_id_partial, we're just using asset keys
......
......@@ -2,32 +2,30 @@
Tests for StaticContentServer
"""
import copy
import datetime
import ddt
import logging
import unittest
from uuid import uuid4
import ddt
from django.conf import settings
from django.test import RequestFactory
from django.test.client import Client
from django.test.utils import override_settings
from mock import patch
from opaque_keys import InvalidKeyError
from student.models import CourseEnrollment
from student.tests.factories import AdminFactory, UserFactory
from xmodule.assetstore.assetmgr import AssetManager
from xmodule.contentstore.content import VERSIONED_ASSETS_PREFIX, StaticContent
from xmodule.contentstore.django import contentstore
from xmodule.contentstore.content import StaticContent, VERSIONED_ASSETS_PREFIX
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.exceptions import ItemNotFoundError
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.xml_importer import import_course_from_xml
from xmodule.assetstore.assetmgr import AssetManager
from opaque_keys import InvalidKeyError
from xmodule.modulestore.exceptions import ItemNotFoundError
from student.models import CourseEnrollment
from student.tests.factories import UserFactory, AdminFactory
from ..middleware import parse_range_header, HTTP_DATE_FORMAT, StaticContentServer
from ..middleware import HTTP_DATE_FORMAT, StaticContentServer, parse_range_header
log = logging.getLogger(__name__)
......
......@@ -55,7 +55,7 @@ from .helpers import is_cross_domain_request_allowed, skip_cross_domain_referer_
if django.VERSION < (1, 9):
from birdcage.v1_11.csrf import CsrfViewMiddleware
else:
from django.middleware.csrf import CsrfViewMiddleware
from django.middleware.csrf import CsrfViewMiddleware # pylint: disable=ungrouped-imports
log = logging.getLogger(__name__)
......
"""Tests for the CORS CSRF version of Django Rest Framework's SessionAuthentication."""
from mock import patch
from django.conf import settings
from django.test import TestCase
from django.test.utils import override_settings
from django.test.client import RequestFactory
from django.conf import settings
from django.test.utils import override_settings
from mock import patch
from rest_framework.exceptions import PermissionDenied
from ..authentication import SessionAuthenticationCrossDomainCsrf
......
"""Tests for cross-domain CSRF decorators. """
import json
import mock
from django.http import HttpResponse
from django.test import TestCase
......
......@@ -2,23 +2,22 @@
Tests for the CORS CSRF middleware
"""
from mock import patch, Mock
import ddt
import django
from django.core.exceptions import ImproperlyConfigured, MiddlewareNotUsed
from django.http import HttpResponse
from django.test import TestCase
from django.test.utils import override_settings
from django.core.exceptions import MiddlewareNotUsed, ImproperlyConfigured
from django.http import HttpResponse
from mock import Mock, patch
from ..middleware import CorsCSRFMiddleware, CsrfCrossDomainCookieMiddleware
# TODO: Remove Django 1.11 upgrade shim
# SHIM: Remove birdcage references post-1.11 upgrade as it is only in place to help during that deployment
if django.VERSION < (1, 9):
from birdcage.v1_11.csrf import CsrfViewMiddleware
else:
from django.middleware.csrf import CsrfViewMiddleware
from ..middleware import CorsCSRFMiddleware, CsrfCrossDomainCookieMiddleware
from django.middleware.csrf import CsrfViewMiddleware # pylint: disable=ungrouped-imports
SENTINEL = object()
......
......@@ -3,13 +3,12 @@
import json
import unittest
import ddt
from config_models.models import cache
from django.conf import settings
from django.core.urlresolvers import NoReverseMatch, reverse
from django.test import TestCase
import ddt
from config_models.models import cache
# cors_csrf is not in CMS' INSTALLED_APPS so these imports will error during test collection
if settings.ROOT_URLCONF == 'lms.urls':
from ..models import XDomainProxyConfiguration
......
......@@ -6,8 +6,6 @@ forums, and to the cohort admin views.
import logging
import random
import request_cache
from courseware import courses
from django.contrib.auth.models import User
from django.core.exceptions import ValidationError
from django.core.validators import validate_email
......@@ -17,6 +15,9 @@ from django.dispatch import receiver
from django.http import Http404
from django.utils.translation import ugettext as _
from eventtracking import tracker
import request_cache
from courseware import courses
from request_cache.middleware import request_cached
from student.models import get_user_by_username_or_email
......
......@@ -5,7 +5,7 @@ Illustration: https://gist.github.com/efischer19/d62f8ee42b7fbfbc6c9a
from django.core.management.base import BaseCommand
from django.db import IntegrityError
from openedx.core.djangoapps.course_groups.models import CourseUserGroup, CohortMembership
from openedx.core.djangoapps.course_groups.models import CohortMembership, CourseUserGroup
class Command(BaseCommand):
......
......@@ -5,10 +5,10 @@ from django.core.management import call_command
from django.test.client import RequestFactory
from nose.plugins.attrib import attr
from openedx.core.djangoapps.course_groups.views import cohort_handler
from openedx.core.djangoapps.course_groups.cohorts import get_cohort_by_name
from openedx.core.djangoapps.course_groups.tests.helpers import config_course_cohorts
from openedx.core.djangoapps.course_groups.models import CohortMembership
from openedx.core.djangoapps.course_groups.tests.helpers import config_course_cohorts
from openedx.core.djangoapps.course_groups.views import cohort_handler
from student.tests.factories import UserFactory
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
......
......@@ -10,6 +10,7 @@ from django.core.exceptions import ValidationError
from django.db import models, transaction
from django.db.models.signals import pre_delete
from django.dispatch import receiver
from openedx.core.djangoapps.xmodule_django.models import CourseKeyField
from util.db import outer_atomic
......
......@@ -12,7 +12,6 @@ from xmodule.partitions.partitions import NoSuchUserPartitionGroupError
from .cohorts import get_cohort, get_group_info_for_cohort
log = logging.getLogger(__name__)
......
......@@ -4,11 +4,12 @@ Helper methods for testing cohorts.
import json
from django_comment_common.models import CourseDiscussionSettings
from django_comment_common.utils import set_course_discussion_settings
from factory import Sequence, post_generation
from factory.django import DjangoModelFactory
from opaque_keys.edx.locator import CourseLocator
from django_comment_common.models import CourseDiscussionSettings
from django_comment_common.utils import set_course_discussion_settings
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore
......
"""
Tests for cohorts
"""
import before_after
# pylint: disable=no-member
import ddt
from mock import call, patch
from nose.plugins.attrib import attr
import before_after
from django.contrib.auth.models import User
from django.db import IntegrityError
from django.http import Http404
from django.test import TestCase
from mock import call, patch
from nose.plugins.attrib import attr
from opaque_keys.edx.locator import CourseLocator
from student.models import CourseEnrollment
from student.tests.factories import UserFactory
from xmodule.modulestore.django import modulestore
......
......@@ -7,18 +7,18 @@ from mock import patch
from nose.plugins.attrib import attr
from courseware.tests.test_masquerade import StaffMasqueradeTestCase
from openedx.core.djangoapps.user_api.partition_schemes import RandomUserPartitionScheme
from openedx.core.djangolib.testing.utils import skip_unless_lms
from student.tests.factories import UserFactory
from xmodule.partitions.partitions import Group, UserPartition, UserPartitionError
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase, TEST_DATA_MIXED_MODULESTORE
from xmodule.modulestore.tests.django_utils import TEST_DATA_MIXED_MODULESTORE, ModuleStoreTestCase
from xmodule.modulestore.tests.factories import ToyCourseFactory
from xmodule.partitions.partitions import Group, UserPartition, UserPartitionError
from openedx.core.djangoapps.user_api.partition_schemes import RandomUserPartitionScheme
from openedx.core.djangolib.testing.utils import skip_unless_lms
from ..partition_scheme import CohortPartitionScheme, get_cohorted_user_partition
from ..cohorts import add_user_to_cohort, get_course_cohorts, remove_user_from_cohort
from ..models import CourseUserGroupPartitionGroup
from ..partition_scheme import CohortPartitionScheme, get_cohorted_user_partition
from ..views import link_cohort_to_partition_group, unlink_cohort_partition_group
from ..cohorts import add_user_to_cohort, remove_user_from_cohort, get_course_cohorts
from .helpers import CohortFactory, config_course_cohorts
......
......@@ -6,14 +6,14 @@ Tests for course group views
import json
from collections import namedtuple
from nose.plugins.attrib import attr
from django.contrib.auth.models import User
from django.http import Http404
from django.test.client import RequestFactory
from nose.plugins.attrib import attr
from opaque_keys.edx.locator import CourseLocator
from django_comment_common.models import CourseDiscussionSettings
from django_comment_common.utils import get_course_discussion_settings
from opaque_keys.edx.locator import CourseLocator
from student.models import CourseEnrollment
from student.tests.factories import UserFactory
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
......
......@@ -2,7 +2,7 @@
This file contains a management command for exporting the modulestore to
neo4j, a graph database.
"""
from __future__ import unicode_literals, print_function
from __future__ import print_function, unicode_literals
import logging
......
......@@ -10,26 +10,19 @@ import ddt
import mock
from django.core.management import call_command
from django.utils import six
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
from openedx.core.djangoapps.coursegraph.management.commands.dump_to_neo4j import (
ModuleStoreSerializer
)
from openedx.core.djangoapps.coursegraph.management.commands.tests.utils import (
MockGraph,
MockNodeSelector,
)
from openedx.core.djangoapps.content.course_structures.signals import listen_for_course_publish
from openedx.core.djangoapps.coursegraph.management.commands.dump_to_neo4j import ModuleStoreSerializer
from openedx.core.djangoapps.coursegraph.management.commands.tests.utils import MockGraph, MockNodeSelector
from openedx.core.djangoapps.coursegraph.tasks import (
serialize_item,
serialize_course,
coerce_types,
serialize_course,
serialize_item,
should_dump_course,
strip_branch_and_version,
)
from openedx.core.djangoapps.content.course_structures.signals import (
listen_for_course_publish
strip_branch_and_version
)
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
class TestDumpToNeo4jCommandBase(SharedModuleStoreTestCase):
......
......@@ -2,7 +2,7 @@
This file contains a management command for exporting the modulestore to
neo4j, a graph database.
"""
from __future__ import unicode_literals, print_function
from __future__ import print_function, unicode_literals
import logging
......@@ -10,10 +10,11 @@ from celery import task
from django.conf import settings
from django.utils import six, timezone
from opaque_keys.edx.keys import CourseKey
from py2neo import Graph, Node, Relationship, authenticate, NodeSelector
from py2neo.compat import integer, string, unicode as neo4j_unicode
from request_cache.middleware import RequestCache
from py2neo import Graph, Node, NodeSelector, Relationship, authenticate
from py2neo.compat import unicode as neo4j_unicode
from py2neo.compat import integer, string
from request_cache.middleware import RequestCache
log = logging.getLogger(__name__)
celery_log = logging.getLogger('edx.celery.task')
......
......@@ -3,8 +3,9 @@
Tests that the request came from a crawler or not.
"""
import ddt
from django.test import TestCase
from django.http import HttpRequest
from django.test import TestCase
from ..models import CrawlersConfig
......
......@@ -4,11 +4,7 @@ from functools import partial
import factory
from openedx.core.djangoapps.catalog.tests.factories import (
generate_instances,
generate_course_run_key,
DictFactoryBase,
)
from openedx.core.djangoapps.catalog.tests.factories import DictFactoryBase, generate_course_run_key, generate_instances
class ProgramCredential(DictFactoryBase):
......
"""Tests covering Credentials utilities."""
import uuid
from edx_oauth2_provider.tests.factories import ClientFactory
import mock
from edx_oauth2_provider.tests.factories import ClientFactory
from nose.plugins.attrib import attr
from provider.constants import CONFIDENTIAL
from openedx.core.djangoapps.credentials.models import CredentialsApiConfig
from openedx.core.djangoapps.credentials.tests import factories
from openedx.core.djangoapps.credentials.tests.mixins import CredentialsApiConfigMixin
from openedx.core.djangoapps.credentials.utils import get_credentials
from openedx.core.djangoapps.credentials.tests import factories
from openedx.core.djangolib.testing.utils import CacheIsolationTestCase, skip_unless_lms
from student.tests.factories import UserFactory
UTILS_MODULE = 'openedx.core.djangoapps.credentials.utils'
......
......@@ -7,13 +7,16 @@ import logging
from opaque_keys.edx.keys import CourseKey
from course_modes.models import CourseMode
from openedx.core.djangoapps.credit.email_utils import send_credit_notifications
from openedx.core.djangoapps.credit.exceptions import InvalidCreditRequirements, InvalidCreditCourse
from openedx.core.djangoapps.credit.exceptions import InvalidCreditCourse, InvalidCreditRequirements
from openedx.core.djangoapps.credit.models import (
CreditCourse, CreditRequirement, CreditRequirementStatus, CreditEligibility, CreditRequest
CreditCourse,
CreditEligibility,
CreditRequest,
CreditRequirement,
CreditRequirementStatus
)
from course_modes.models import CourseMode
from student.models import CourseEnrollment
# TODO: Cleanup this mess! ECOM-2908
......
......@@ -8,31 +8,26 @@ import uuid
import pytz
from django.db import transaction
from edx_proctoring.api import get_last_exam_completion_date
from openedx.core.djangoapps.credit.exceptions import (
UserIsNotEligible,
CreditProviderNotConfigured,
RequestAlreadyCompleted,
CreditRequestNotFound,
InvalidCreditStatus,
RequestAlreadyCompleted,
UserIsNotEligible
)
from openedx.core.djangoapps.credit.models import (
CreditEligibility,
CreditProvider,
CreditRequirementStatus,
CreditRequest,
CreditEligibility,
)
from student.models import (
User,
CourseEnrollment,
CreditRequirementStatus
)
from openedx.core.djangoapps.credit.signature import signature, get_shared_secret_key
from openedx.core.djangoapps.credit.signature import get_shared_secret_key, signature
from student.models import CourseEnrollment, User
from util.date_utils import to_timestamp
from util.json_request import JsonResponse
# TODO: Cleanup this mess! ECOM-2908
log = logging.getLogger(__name__)
......
......@@ -17,10 +17,10 @@ from django.core.cache import cache
from django.core.mail import EmailMessage, SafeMIMEText
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext as _
from eventtracking import tracker
from edxmako.shortcuts import render_to_string
from edxmako.template import Template
from eventtracking import tracker
from openedx.core.djangoapps.commerce.utils import ecommerce_api_client
from openedx.core.djangoapps.credit.models import CreditConfig, CreditProvider
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
......
......@@ -5,7 +5,6 @@ from django.utils.translation import ugettext_lazy as _
from rest_framework import status
from rest_framework.exceptions import APIException
# TODO: Cleanup this mess! ECOM-2908
......
......@@ -4,8 +4,10 @@ credit_historicalcreditrequirementstatus tables.
"""
import logging
from openedx.core.djangoapps.credit.models import CreditRequest, CreditRequirementStatus
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__)
......
......@@ -3,12 +3,12 @@ import datetime
import json
import uuid # pylint:disable=unused-import
from django.contrib.auth.models import User
import factory
from factory.fuzzy import FuzzyText
import pytz
from django.contrib.auth.models import User
from factory.fuzzy import FuzzyText
from openedx.core.djangoapps.credit.models import CreditProvider, CreditEligibility, CreditCourse, CreditRequest
from openedx.core.djangoapps.credit.models import CreditCourse, CreditEligibility, CreditProvider, CreditRequest
from util.date_utils import to_timestamp
......
......@@ -4,10 +4,10 @@
from __future__ import unicode_literals
from django.test import TestCase
from nose.plugins.attrib import attr
from openedx.core.djangoapps.credit import serializers
from openedx.core.djangoapps.credit.tests.factories import CreditProviderFactory, CreditEligibilityFactory
from openedx.core.djangoapps.credit.tests.factories import CreditEligibilityFactory, CreditProviderFactory
from student.tests.factories import UserFactory
......
......@@ -4,16 +4,14 @@ Tests for the Credit xBlock service
import ddt
from nose.plugins.attrib import attr
from course_modes.models import CourseMode
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
from openedx.core.djangoapps.credit.services import CreditService
from openedx.core.djangoapps.credit.models import CreditCourse
from course_modes.models import CourseMode
from openedx.core.djangoapps.credit.api.eligibility import set_credit_requirements
from openedx.core.djangoapps.credit.models import CreditCourse
from openedx.core.djangoapps.credit.services import CreditService
from student.models import CourseEnrollment, UserProfile
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
@attr(shard=2)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment