Commit 6cf48dab by Tyler Hallada

Run isort on openedx/

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