Commit f4b0a76c by Andy Armstrong Committed by GitHub

Merge pull request #15204 from edx/andya/clean-imports-2

Reorder imports using isort (except lms and cms)
parents e9cdc133 93235d11
......@@ -2,6 +2,7 @@
Model Managers for Course Actions
"""
import traceback
from django.db import models, transaction
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
from openedx.core.djangoapps.xmodule_django.models import CourseKeyField
......
......@@ -11,8 +11,9 @@ file and check it in at the same time as your model changes. To do that,
"""
from django.contrib.auth.models import User
from django.db import models
from openedx.core.djangoapps.xmodule_django.models import CourseKeyField
from course_action_state.managers import CourseActionStateManager, CourseRerunUIStateManager
from openedx.core.djangoapps.xmodule_django.models import CourseKeyField
class CourseActionState(models.Model):
......
......@@ -2,13 +2,14 @@
"""
Tests for basic common operations related to Course Action State managers
"""
from ddt import ddt, data
from django.test import TestCase
from collections import namedtuple
from ddt import data, ddt
from django.test import TestCase
from opaque_keys.edx.locations import CourseLocator
from course_action_state.models import CourseRerunState
from course_action_state.managers import CourseActionStateItemNotFoundError
from course_action_state.managers import CourseActionStateItemNotFoundError
from course_action_state.models import CourseRerunState
# Sequence of Action models to be tested with ddt.
COURSE_ACTION_STATES = (CourseRerunState, )
......
......@@ -4,8 +4,9 @@ Tests specific to the CourseRerunState Model and Manager.
from django.test import TestCase
from opaque_keys.edx.locations import CourseLocator
from course_action_state.models import CourseRerunState
from course_action_state.managers import CourseRerunUIStateManager
from course_action_state.models import CourseRerunState
from student.tests.factories import UserFactory
......
......@@ -2,11 +2,7 @@
from django.utils.translation import ugettext_lazy as _
from course_modes.models import CourseMode
from student.helpers import (
VERIFY_STATUS_NEED_TO_VERIFY,
VERIFY_STATUS_SUBMITTED,
VERIFY_STATUS_APPROVED
)
from student.helpers import VERIFY_STATUS_APPROVED, VERIFY_STATUS_NEED_TO_VERIFY, VERIFY_STATUS_SUBMITTED
DISPLAY_VERIFIED = "verified"
DISPLAY_HONOR = "honor"
......
......@@ -2,6 +2,7 @@
from __future__ import unicode_literals
from django.db import migrations, models
from openedx.core.djangoapps.xmodule_django.models import CourseKeyField
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from datetime import timedelta
from django.db import migrations, models
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
......
"""
Add and create new modes for running courses on this particular LMS
"""
from collections import defaultdict, namedtuple
from datetime import datetime, timedelta
import pytz
from collections import namedtuple, defaultdict
import pytz
from config_models.models import ConfigurationModel
from django.core.exceptions import ValidationError
from django.db import models
from django.db.models import Q
from django.dispatch import receiver
from django.utils.translation import ugettext_lazy as _
from openedx.core.djangoapps.xmodule_django.models import CourseKeyField
from request_cache.middleware import ns_request_cached, RequestCache
from openedx.core.djangoapps.xmodule_django.models import CourseKeyField
from request_cache.middleware import RequestCache, ns_request_cached
Mode = namedtuple('Mode',
[
......
......@@ -3,6 +3,7 @@ Signal handler for setting default course mode expiration dates
"""
from django.core.exceptions import ObjectDoesNotExist
from django.dispatch.dispatcher import receiver
from xmodule.modulestore.django import SignalHandler, modulestore
from .models import CourseMode, CourseModeExpirationConfig
......
......@@ -3,11 +3,12 @@ Factories for course mode models.
"""
import random
from course_modes.models import CourseMode
from factory.django import DjangoModelFactory
from factory import lazy_attribute
from factory.django import DjangoModelFactory
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from course_modes.models import CourseMode
# Factories are self documenting
# pylint: disable=missing-docstring
......
......@@ -5,24 +5,22 @@ import unittest
from datetime import datetime, timedelta
import ddt
from pytz import timezone, UTC
from django.conf import settings
from django.core.urlresolvers import reverse
from pytz import UTC, timezone
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from util.date_utils import get_time_display
from xmodule.modulestore.tests.factories import CourseFactory
from student.tests.factories import UserFactory
from course_modes.models import CourseMode
from course_modes.admin import CourseModeForm
from course_modes.models import CourseMode
from course_modes.tests.factories import CourseModeFactory
# Technically, we shouldn't be importing verify_student, since it's
# defined in the LMS and course_modes is in common. However, the benefits
# of putting all this configuration in one place outweigh the downsides.
# Once the course admin tool is deployed, we can remove this dependency.
from lms.djangoapps.verify_student.models import VerificationDeadline
from student.tests.factories import UserFactory
from util.date_utils import get_time_display
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
# We can only test this in the LMS because the course modes admin relies
......
......@@ -5,15 +5,15 @@ when you run "manage.py test".
Replace this with more appropriate tests for your application.
"""
from datetime import datetime, timedelta
import itertools
from datetime import datetime, timedelta
import ddt
import pytz
from django.core.exceptions import ValidationError
from django.test import TestCase
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from opaque_keys.edx.locator import CourseLocator
import pytz
from course_modes.helpers import enrollment_mode_display
from course_modes.models import CourseMode, Mode, invalidate_course_mode_cache
......
......@@ -3,15 +3,15 @@ Unit tests for the course_mode signals
"""
from datetime import datetime, timedelta
from mock import patch
import ddt
from mock import patch
from pytz import UTC
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
from course_modes.models import CourseMode
from course_modes.signals import _listen_for_course_publish
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
@ddt.ddt
......
......@@ -2,34 +2,33 @@
Tests for course_modes views.
"""
from datetime import datetime
import unittest
import decimal
import unittest
from datetime import datetime
import ddt
import httpretty
import freezegun
from mock import patch
from nose.plugins.attrib import attr
import httpretty
from django.conf import settings
from django.core.urlresolvers import reverse
from lms.djangoapps.commerce.tests import test_utils as ecomm_test_utils
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.tests.factories import CourseFactory
from mock import patch
from nose.plugins.attrib import attr
from course_modes.models import CourseMode, Mode
from course_modes.tests.factories import CourseModeFactory
from lms.djangoapps.commerce.tests import test_utils as ecomm_test_utils
from openedx.core.djangoapps.catalog.tests.mixins import CatalogIntegrationMixin
from openedx.core.djangoapps.embargo.test_utils import restrict_course
from openedx.core.djangoapps.theming.tests.test_util import with_comprehensive_theme
from openedx.features.enterprise_support.tests.mixins.enterprise import EnterpriseServiceMockMixin
from student.models import CourseEnrollment
from student.tests.factories import CourseEnrollmentFactory, UserFactory
from util import organizations_helpers as organizations_api
from util.testing import UrlResetMixin
from openedx.core.djangoapps.theming.tests.test_util import with_comprehensive_theme
from util.tests.mixins.discovery import CourseCatalogServiceMockMixin
from util import organizations_helpers as organizations_api
from openedx.core.djangoapps.catalog.tests.mixins import CatalogIntegrationMixin
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
@attr(shard=3)
......
from django.conf.urls import patterns, url
from django.conf import settings
from django.conf.urls import patterns, url
from course_modes import views
......
......@@ -12,23 +12,24 @@ from django.db import transaction
from django.http import HttpResponse, HttpResponseBadRequest
from django.shortcuts import redirect
from django.utils.decorators import method_decorator
from django.utils.translation import get_language, to_locale, ugettext as _
from django.utils.translation import ugettext as _
from django.utils.translation import get_language, to_locale
from django.views.generic.base import View
from ipware.ip import get_ip
from opaque_keys.edx.keys import CourseKey
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from xmodule.modulestore.django import modulestore
from lms.djangoapps.commerce.utils import EcommerceService
from course_modes.models import CourseMode
from courseware.access import has_access
from edxmako.shortcuts import render_to_response
from lms.djangoapps.commerce.utils import EcommerceService
from openedx.core.djangoapps.embargo import api as embargo_api
from openedx.features.enterprise_support import api as enterprise_api
from student.models import CourseEnrollment
from util.db import outer_atomic
from util import organizations_helpers as organization_api
from third_party_auth.decorators import tpa_hint_ends_existing_session
from util import organizations_helpers as organization_api
from util.db import outer_atomic
from xmodule.modulestore.django import modulestore
class ChooseModeView(View):
......
......@@ -3,6 +3,7 @@ from __future__ import unicode_literals
from django.db import migrations, models
# We used to have a uniqueness constraint on auth_user.email:
# https://github.com/edx/edx-platform/commit/c52727b0e0fb241d8211900975d3b69fe5a1bd57
#
......
......@@ -5,5 +5,4 @@ from django.contrib import admin
from .models import ForumsConfig
admin.site.register(ForumsConfig)
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
from django.conf import settings
from django.db import migrations, models
from openedx.core.djangoapps.xmodule_django.models import CourseKeyField
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
def add_default_enable(apps, schema_editor):
ForumsConfig = apps.get_model("django_comment_common", "ForumsConfig")
settings_count = ForumsConfig.objects.count()
......
import logging
from config_models.models import ConfigurationModel
from django.conf import settings
from django.db import models
from django.contrib.auth.models import User
from django.dispatch import receiver
from django.db import models
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.utils.translation import ugettext_noop
from config_models.models import ConfigurationModel
from openedx.core.djangoapps.xmodule_django.models import CourseKeyField, NoneToEmptyManager
from student.models import CourseEnrollment
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.exceptions import ItemNotFoundError
from openedx.core.djangoapps.xmodule_django.models import CourseKeyField, NoneToEmptyManager
FORUM_ROLE_ADMINISTRATOR = ugettext_noop('Administrator')
FORUM_ROLE_MODERATOR = ugettext_noop('Moderator')
......
......@@ -3,7 +3,6 @@
from django.dispatch import Signal
thread_created = Signal(providing_args=['user', 'post'])
thread_edited = Signal(providing_args=['user', 'post'])
thread_voted = Signal(providing_args=['user', 'post'])
......
from django.test import TestCase
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from django_comment_common.models import Role
from student.models import CourseEnrollment, User
......
......@@ -2,8 +2,13 @@
Common comment client utility functions.
"""
from django_comment_common.models import Role, FORUM_ROLE_ADMINISTRATOR, FORUM_ROLE_MODERATOR, \
FORUM_ROLE_COMMUNITY_TA, FORUM_ROLE_STUDENT
from django_comment_common.models import (
FORUM_ROLE_ADMINISTRATOR,
FORUM_ROLE_COMMUNITY_TA,
FORUM_ROLE_MODERATOR,
FORUM_ROLE_STUDENT,
Role
)
class ThreadContext(object):
......
......@@ -2,13 +2,12 @@ import logging
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.template import Engine
from django.template.base import TemplateDoesNotExist
from django.template.loaders.filesystem import Loader as FilesystemLoader
from django.template.loaders.app_directories import Loader as AppDirectoriesLoader
from django.template import Engine
from django.template.loaders.filesystem import Loader as FilesystemLoader
from edxmako.template import Template
from openedx.core.lib.tempdir import mkdtemp_clean
log = logging.getLogger(__name__)
......
......@@ -2,21 +2,19 @@
Set up lookup paths for mako templates.
"""
import hashlib
import contextlib
import hashlib
import os
import pkg_resources
import pkg_resources
from django.conf import settings
from mako.lookup import TemplateLookup
from mako.exceptions import TopLevelLookupException
from mako.lookup import TemplateLookup
from openedx.core.djangoapps.theming.helpers import get_template as themed_template
from openedx.core.djangoapps.theming.helpers import get_template_path_with_theme, strip_site_theme_templates_path
from . import LOOKUP
from openedx.core.djangoapps.theming.helpers import (
get_template as themed_template,
get_template_path_with_theme,
strip_site_theme_templates_path,
)
class DynamicTemplateLookup(TemplateLookup):
......
......@@ -19,14 +19,14 @@ Methods for creating RequestContext for using with Mako templates.
"""
from crum import get_current_request
from django.conf import settings
from django.template import RequestContext
from django.template.context import _builtin_context_processors
from django.utils.module_loading import import_string
from util.request import safe_get_host
from crum import get_current_request
import request_cache
from util.request import safe_get_host
def get_template_context_processors():
......
......@@ -15,15 +15,15 @@
import logging
from urlparse import urljoin
from django.conf import settings
from django.core.urlresolvers import reverse
from django.http import HttpResponse
from django.template import Context
from edxmako import lookup_template
from edxmako.request_context import get_template_request_context
from django.conf import settings
from django.core.urlresolvers import reverse
from openedx.core.djangoapps.theming.helpers import get_template_path, is_request_in_themed_site
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from openedx.core.djangoapps.theming.helpers import get_template_path, is_request_in_themed_site
log = logging.getLogger(__name__)
......
......@@ -2,6 +2,7 @@
Initialize the mako template lookup
"""
from django.conf import settings
from . import add_lookup, clear_lookups
......
......@@ -12,12 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import edxmako
from django.conf import settings
from mako.template import Template as MakoTemplate
import edxmako
from edxmako.request_context import get_template_request_context
from edxmako.shortcuts import marketing_link
from mako.template import Template as MakoTemplate
# TODO: We should make this a Django Template subclass that simply has the MakoTemplate inside of it? (Intead of inheriting from MakoTemplate)
......
from django.template import loader
from django.template.base import Template, Context
from django.template.base import Context, Template
from django.template.loader import get_template, select_template
......
from mock import patch, Mock
import unittest
import ddt
from request_cache.middleware import RequestCache
import ddt
from django.conf import settings
from django.core.urlresolvers import reverse
from django.http import HttpResponse
from django.test import TestCase
from django.test.utils import override_settings
from django.test.client import RequestFactory
from django.core.urlresolvers import reverse
from django.test.utils import override_settings
from mock import Mock, patch
from edxmako import LOOKUP, add_lookup
from edxmako.request_context import get_template_request_context
from edxmako import add_lookup, LOOKUP
from edxmako.shortcuts import (
marketing_link,
is_marketing_link_set,
is_any_marketing_link_set,
render_to_string,
)
from edxmako.shortcuts import is_any_marketing_link_set, is_marketing_link_set, marketing_link, render_to_string
from request_cache.middleware import RequestCache
from student.tests.factories import UserFactory
from util.testing import UrlResetMixin
......
......@@ -5,6 +5,7 @@ course level, such as available course modes.
"""
import importlib
import logging
from django.conf import settings
from django.core.cache import cache
from opaque_keys.edx.keys import CourseKey
......
......@@ -8,18 +8,24 @@ from django.contrib.auth.models import User
from opaque_keys.edx.keys import CourseKey
from enrollment.errors import (
CourseEnrollmentClosedError, CourseEnrollmentFullError,
CourseEnrollmentExistsError, UserNotFoundError, InvalidEnrollmentAttribute
CourseEnrollmentClosedError,
CourseEnrollmentExistsError,
CourseEnrollmentFullError,
InvalidEnrollmentAttribute,
UserNotFoundError
)
from enrollment.serializers import CourseEnrollmentSerializer, CourseSerializer
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
from openedx.core.lib.exceptions import CourseNotFoundError
from student.models import (
CourseEnrollment, NonExistentCourseError, EnrollmentClosedError,
CourseFullError, AlreadyEnrolledError, CourseEnrollmentAttribute
AlreadyEnrolledError,
CourseEnrollment,
CourseEnrollmentAttribute,
CourseFullError,
EnrollmentClosedError,
NonExistentCourseError
)
log = logging.getLogger(__name__)
......
......@@ -8,7 +8,6 @@ from rest_framework import serializers
from course_modes.models import CourseMode
from student.models import CourseEnrollment
log = logging.getLogger(__name__)
......
......@@ -4,7 +4,6 @@ A Fake Data API for testing purposes.
import copy
import datetime
_DEFAULT_FAKE_MODE = {
"slug": "honor",
"name": "Honor Code Certificate",
......
"""
Tests for student enrollment.
"""
from mock import patch, Mock
import unittest
import ddt
from nose.tools import raises
import unittest
from django.test.utils import override_settings
from django.conf import settings
from django.test.utils import override_settings
from mock import Mock, patch
from nose.tools import raises
from course_modes.models import CourseMode
from enrollment import api
from enrollment.errors import EnrollmentApiLoadError, EnrollmentNotFoundError, CourseModeNotFoundError
from enrollment.errors import CourseModeNotFoundError, EnrollmentApiLoadError, EnrollmentNotFoundError
from enrollment.tests import fake_data_api
from openedx.core.djangolib.testing.utils import CacheIsolationTestCase
......
......@@ -6,20 +6,22 @@ import datetime
import unittest
import ddt
from django.conf import settings
from mock import patch
from nose.tools import raises
from pytz import UTC
from django.conf import settings
from course_modes.models import CourseMode
from enrollment import data
from enrollment.errors import (
UserNotFoundError, CourseEnrollmentClosedError,
CourseEnrollmentFullError, CourseEnrollmentExistsError,
CourseEnrollmentClosedError,
CourseEnrollmentExistsError,
CourseEnrollmentFullError,
UserNotFoundError
)
from openedx.core.lib.exceptions import CourseNotFoundError
from student.tests.factories import UserFactory, CourseModeFactory
from student.models import CourseEnrollment, EnrollmentClosedError, CourseFullError, AlreadyEnrolledError
from student.models import AlreadyEnrolledError, CourseEnrollment, CourseFullError, EnrollmentClosedError
from student.tests.factories import CourseModeFactory, UserFactory
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
......
"""
Tests for user enrollment.
"""
import json
import datetime
import itertools
import json
import unittest
import datetime
import ddt
import httpretty
import pytz
from django.conf import settings
from django.core.cache import cache
from mock import patch
from nose.plugins.attrib import attr
from django.test import Client
from django.core.handlers.wsgi import WSGIRequest
from django.core.urlresolvers import reverse
from rest_framework.test import APITestCase
from rest_framework import status
from django.conf import settings
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory, check_mongo_calls_range
from django.test import Client
from django.test.utils import override_settings
import pytz
import httpretty
from mock import patch
from nose.plugins.attrib import attr
from rest_framework import status
from rest_framework.test import APITestCase
from course_modes.models import CourseMode
from enrollment.views import EnrollmentUserThrottle
from util.models import RateLimitConfiguration
from util.testing import UrlResetMixin
from openedx.features.enterprise_support.tests.mixins.enterprise import EnterpriseServiceMockMixin
from enrollment import api
from enrollment.errors import CourseEnrollmentError
from enrollment.views import EnrollmentUserThrottle
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
from openedx.core.djangoapps.embargo.models import Country, CountryAccessRule, RestrictedCourse
from openedx.core.djangoapps.embargo.test_utils import restrict_course
from openedx.core.djangoapps.user_api.models import UserOrgTag
from openedx.core.lib.django_test_client_utils import get_absolute_url
from openedx.features.enterprise_support.tests.mixins.enterprise import EnterpriseServiceMockMixin
from student.models import CourseEnrollment
from student.roles import CourseStaffRole
from student.tests.factories import AdminFactory, CourseModeFactory, UserFactory
from openedx.core.djangoapps.embargo.models import CountryAccessRule, Country, RestrictedCourse
from openedx.core.djangoapps.embargo.test_utils import restrict_course
from util.models import RateLimitConfiguration
from util.testing import UrlResetMixin
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory, check_mongo_calls_range
class EnrollmentTestMixin(object):
......
......@@ -5,12 +5,7 @@ URLs for the Enrollment API
from django.conf import settings
from django.conf.urls import patterns, url
from .views import (
EnrollmentView,
EnrollmentListView,
EnrollmentCourseDetailView
)
from .views import EnrollmentCourseDetailView, EnrollmentListView, EnrollmentView
urlpatterns = patterns(
'enrollment.views',
......
......@@ -16,23 +16,20 @@ from rest_framework.throttling import UserRateThrottle
from rest_framework.views import APIView
from course_modes.models import CourseMode
from enrollment import api
from enrollment.errors import CourseEnrollmentError, CourseEnrollmentExistsError, CourseModeNotFoundError
from openedx.core.djangoapps.cors_csrf.authentication import SessionAuthenticationCrossDomainCsrf
from openedx.core.djangoapps.cors_csrf.decorators import ensure_csrf_cookie_cross_domain
from openedx.core.djangoapps.embargo import api as embargo_api
from openedx.core.djangoapps.user_api.preferences.api import update_email_opt_in
from openedx.features.enterprise_support.api import enterprise_enabled, EnterpriseApiClient, EnterpriseApiException
from openedx.core.lib.api.authentication import (
SessionAuthenticationAllowInactiveUser, OAuth2AuthenticationAllowInactiveUser,
OAuth2AuthenticationAllowInactiveUser,
SessionAuthenticationAllowInactiveUser
)
from openedx.core.lib.api.permissions import ApiKeyHeaderPermission, ApiKeyHeaderPermissionIsAuthenticated
from openedx.core.lib.exceptions import CourseNotFoundError
from openedx.core.lib.log_utils import audit_log
from enrollment import api
from enrollment.errors import (
CourseEnrollmentError,
CourseModeNotFoundError,
CourseEnrollmentExistsError
)
from openedx.features.enterprise_support.api import EnterpriseApiClient, EnterpriseApiException, enterprise_enabled
from student.auth import user_has_role
from student.models import User
from student.roles import CourseStaffRole, GlobalStaff
......
"""
Django admin page for microsite models
"""
from django.contrib import admin
from django import forms
from django.contrib import admin
from .models import (
Microsite,
MicrositeHistory,
MicrositeOrganizationMapping,
MicrositeTemplate
)
from util.organizations_helpers import get_organizations
from .models import Microsite, MicrositeHistory, MicrositeOrganizationMapping, MicrositeTemplate
class MicrositeAdmin(admin.ModelAdmin):
""" Admin interface for the Microsite object. """
......
"""
Microsite backend that reads the configuration from the database
"""
from mako.template import Template
from util.cache import cache
from django.conf import settings
from django.dispatch import receiver
from django.db.models.signals import post_save
from django.dispatch import receiver
from mako.template import Template
from microsite_configuration.backends.base import BaseMicrositeBackend, BaseMicrositeTemplateBackend
from microsite_configuration.microsite import get_value as microsite_get_value
from microsite_configuration.models import Microsite, MicrositeOrganizationMapping, MicrositeTemplate
from util.cache import cache
from util.memcache import fasthash
from util.url import strip_port_from_host
from microsite_configuration.backends.base import (
BaseMicrositeBackend,
BaseMicrositeTemplateBackend,
)
from microsite_configuration.models import (
Microsite,
MicrositeOrganizationMapping,
MicrositeTemplate
)
from microsite_configuration.microsite import get_value as microsite_get_value
class DatabaseMicrositeBackend(BaseMicrositeBackend):
......
......@@ -3,10 +3,7 @@ Microsite backend that reads the configuration from a file
"""
from microsite_configuration.backends.base import (
BaseMicrositeBackend,
BaseMicrositeTemplateBackend,
)
from microsite_configuration.backends.base import BaseMicrositeBackend, BaseMicrositeTemplateBackend
class FilebasedMicrositeBackend(BaseMicrositeBackend):
......
......@@ -7,11 +7,11 @@ A microsite enables the following features:
3) Ability to swap out some branding elements in the website
"""
import inspect
from importlib import import_module
from django.conf import settings
from microsite_configuration.backends.base import BaseMicrositeBackend, BaseMicrositeTemplateBackend
from microsite_configuration.backends.base import BaseMicrositeBackend, BaseMicrositeTemplateBackend
__all__ = [
'is_request_in_microsite', 'get_value', 'has_override_value',
......
......@@ -8,6 +8,7 @@ A microsite enables the following features:
"""
from django.conf import settings
from microsite_configuration import microsite
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
import jsonfield.fields
import django.db.models.deletion
from django.conf import settings
import model_utils.fields
import django.utils.timezone
import jsonfield.fields
import model_utils.fields
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
......
......@@ -7,12 +7,11 @@ that would have been used in the settings.
"""
import collections
from django.contrib.sites.models import Site
from django.db import models
from django.dispatch import receiver
from django.db.models.signals import pre_save, pre_delete
from django.db.models.base import ObjectDoesNotExist
from django.contrib.sites.models import Site
from django.db.models.signals import pre_delete, pre_save
from django.dispatch import receiver
from jsonfield.fields import JSONField
from model_utils.models import TimeStampedModel
from simple_history.models import HistoricalRecords
......
......@@ -2,15 +2,10 @@
Factories module to hold microsite factories
"""
import factory
from factory.django import DjangoModelFactory
from django.contrib.sites.models import Site
from factory.django import DjangoModelFactory
from microsite_configuration.models import (
Microsite,
MicrositeOrganizationMapping,
MicrositeTemplate,
)
from microsite_configuration.models import Microsite, MicrositeOrganizationMapping, MicrositeTemplate
class SiteFactory(DjangoModelFactory):
......
......@@ -5,15 +5,9 @@ some additional coverage
import ddt
from mock import patch
from microsite_configuration.microsite import (
get_value_for_org,
get_backend,
)
from microsite_configuration.backends.base import BaseMicrositeBackend
from microsite_configuration.tests.tests import (
DatabaseMicrositeTestCase,
MICROSITE_BACKENDS,
)
from microsite_configuration.microsite import get_backend, get_value_for_org
from microsite_configuration.tests.tests import MICROSITE_BACKENDS, DatabaseMicrositeTestCase
@ddt.ddt
......
......@@ -4,14 +4,15 @@ Tests configuration templatetags and helper functions.
"""
import logging
from mock import patch
from django.test import TestCase
from django.conf import settings
from django.test import TestCase
from mock import patch
from microsite_configuration import microsite
from microsite_configuration.backends.base import BaseMicrositeBackend
from microsite_configuration.backends.database import DatabaseMicrositeBackend
from openedx.core.djangoapps.site_configuration.templatetags import configuration as configuration_tags
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from openedx.core.djangoapps.site_configuration.templatetags import configuration as configuration_tags
log = logging.getLogger(__name__)
......
"""
Holds base classes for microsite tests
"""
from django.test import TestCase
from mock import DEFAULT
from django.test import TestCase
from microsite_configuration.tests.factories import (
MicrositeFactory,
MicrositeOrganizationMappingFactory,
)
from microsite_configuration.tests.factories import MicrositeFactory, MicrositeOrganizationMappingFactory
MICROSITE_BACKENDS = (
'microsite_configuration.backends.filebased.FilebasedMicrositeBackend',
......
""" Tests for rendering functions in the mako pipeline. """
import ddt
from unittest import skipUnless
import ddt
from django.conf import settings
from django.test import TestCase
from paver.easy import call_task
from pipeline_mako import render_require_js_path_overrides, compressed_css, compressed_js
from pipeline_mako import compressed_css, compressed_js, render_require_js_path_overrides
class RequireJSPathOverridesTest(TestCase):
......
......@@ -2,10 +2,10 @@
An implementation of a RequestCache. This cache is reset at the beginning
and end of every request.
"""
from django.utils.encoding import force_text
import threading
import crum
import threading
from django.utils.encoding import force_text
class _RequestCache(threading.local):
......
......@@ -2,9 +2,9 @@
Django admin page for AssetBaseUrlConfig, which allows you to set the base URL
that gets prepended to asset URLs in order to serve them from, say, a CDN.
"""
from config_models.admin import ConfigurationModelAdmin
from django.contrib import admin
from config_models.admin import ConfigurationModelAdmin
from .models import AssetBaseUrlConfig, AssetExcludedExtensionsConfig
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
......
......@@ -2,8 +2,8 @@
Models for static_replace
"""
from django.db.models.fields import TextField
from config_models.models import ConfigurationModel
from django.db.models.fields import TextField
class AssetBaseUrlConfig(ConfigurationModel):
......
# -*- coding: utf-8 -*-
"""Tests for static_replace"""
import ddt
import re
from cStringIO import StringIO
from urlparse import parse_qsl, urlparse, urlunparse
import ddt
from django.test import override_settings
from django.utils.http import urlquote, urlencode
from urlparse import urlparse, urlunparse, parse_qsl
from django.utils.http import urlencode, urlquote
from mock import Mock, patch
from nose.tools import assert_equals, assert_false, assert_true # pylint: disable=no-name-in-module
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from PIL import Image
from cStringIO import StringIO
from nose.tools import assert_equals, assert_true, assert_false # pylint: disable=no-name-in-module
from static_replace import (
replace_static_urls,
replace_course_urls,
_url_replace_regex,
make_static_urls_absolute,
process_static_urls,
make_static_urls_absolute
replace_course_urls,
replace_static_urls
)
from mock import patch, Mock
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from xmodule.assetstore.assetmgr import AssetManager
from xmodule.contentstore.content import StaticContent
from xmodule.contentstore.django import contentstore
from xmodule.exceptions import NotFoundError
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.exceptions import ItemNotFoundError
from xmodule.modulestore.mongo import MongoModuleStore
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory, check_mongo_calls
from xmodule.modulestore.xml import XMLModuleStore
from xmodule.modulestore.exceptions import ItemNotFoundError
from xmodule.exceptions import NotFoundError
from xmodule.assetstore.assetmgr import AssetManager
DATA_DIRECTORY = 'data_dir'
COURSE_KEY = SlashSeparatedCourseKey('org', 'course', 'run')
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
from openedx.core.djangoapps.xmodule_django.models import CourseKeyField
......
......@@ -2,15 +2,14 @@
Store status messages in the database.
"""
from django.db import models
from config_models.admin import ConfigurationModelAdmin
from config_models.models import ConfigurationModel
from django.contrib import admin
from django.core.cache import cache
from django.db import models
from openedx.core.djangoapps.xmodule_django.models import CourseKeyField
from config_models.models import ConfigurationModel
from config_models.admin import ConfigurationModelAdmin
class GlobalStatusMessage(ConfigurationModel):
"""
......
# -*- coding: utf-8 -*-
""" Tests for setting and displaying the site status message. """
import ddt
import unittest
from django.test import TestCase
from django.core.cache import cache
import ddt
from django.conf import settings
from django.core.cache import cache
from django.test import TestCase
from opaque_keys.edx.locations import CourseLocator
from .models import CourseMessage, GlobalStatusMessage
from .status import get_site_status_msg
from .models import GlobalStatusMessage, CourseMessage
@ddt.ddt
......
""" Django admin pages for student app """
from config_models.admin import ConfigurationModelAdmin
from django import forms
from django.contrib.auth import get_user_model
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
......@@ -6,15 +7,23 @@ from django.utils.translation import ugettext_lazy as _
from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey
from ratelimitbackend import admin
from xmodule.modulestore.django import modulestore
from config_models.admin import ConfigurationModelAdmin
from student.models import (
UserProfile, UserTestGroup, CourseEnrollmentAllowed, DashboardConfiguration, CourseEnrollment, Registration,
PendingNameChange, CourseAccessRole, LinkedInAddToProfileConfiguration, UserAttribute, LogoutViewConfiguration,
RegistrationCookieConfiguration
CourseAccessRole,
CourseEnrollment,
CourseEnrollmentAllowed,
DashboardConfiguration,
LinkedInAddToProfileConfiguration,
LogoutViewConfiguration,
PendingNameChange,
Registration,
RegistrationCookieConfiguration,
UserAttribute,
UserProfile,
UserTestGroup
)
from student.roles import REGISTERED_ACCESS_ROLES
from xmodule.modulestore.django import modulestore
User = get_user_model() # pylint:disable=invalid-name
......
......@@ -4,14 +4,23 @@ authorization has authorization to do so, which infers authorization via role hi
(GlobalStaff is superset of auths of course instructor, ...), which consults the config
to decide whether to check course creator role, and other such functions.
"""
from django.core.exceptions import PermissionDenied
from ccx_keys.locator import CCXBlockUsageLocator, CCXLocator
from django.conf import settings
from django.core.exceptions import PermissionDenied
from opaque_keys.edx.locator import LibraryLocator
from ccx_keys.locator import CCXLocator, CCXBlockUsageLocator
from student.roles import GlobalStaff, CourseCreatorRole, CourseStaffRole, CourseInstructorRole, CourseRole, \
CourseBetaTesterRole, OrgInstructorRole, OrgStaffRole, LibraryUserRole, OrgLibraryUserRole
from student.roles import (
CourseBetaTesterRole,
CourseCreatorRole,
CourseInstructorRole,
CourseRole,
CourseStaffRole,
GlobalStaff,
LibraryUserRole,
OrgInstructorRole,
OrgLibraryUserRole,
OrgStaffRole
)
# Studio permissions:
STUDIO_EDIT_ROLES = 8
......
......@@ -8,7 +8,7 @@ import time
import six
from django.conf import settings
from django.core.urlresolvers import reverse, NoReverseMatch
from django.core.urlresolvers import NoReverseMatch, reverse
from django.dispatch import Signal
from django.utils.http import cookie_date
......
"""
Utility functions for validating forms
"""
from importlib import import_module
import re
from importlib import import_module
from django import forms
from django.forms import widgets
from django.core.exceptions import ValidationError
from django.contrib.auth.models import User
from django.conf import settings
from django.contrib.auth.forms import PasswordResetForm
from django.contrib.auth.hashers import UNUSABLE_PASSWORD_PREFIX
from django.contrib.auth.models import User
from django.contrib.auth.tokens import default_token_generator
from django.core.exceptions import ValidationError
from django.forms import widgets
from django.template import loader
from django.utils.http import int_to_base36
from django.utils.translation import ugettext_lazy as _
from django.template import loader
from django.conf import settings
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from student.models import CourseEnrollmentAllowed
from util.password_policy_validators import validate_password_strength
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
class PasswordResetFormNoActive(PasswordResetForm):
......
"""Helpers for the student app. """
from datetime import datetime
import logging
import urllib
import mimetypes
import urllib
from datetime import datetime
from django.conf import settings
from django.core.urlresolvers import reverse, NoReverseMatch
from django.core.urlresolvers import NoReverseMatch, reverse
from django.utils import http
from oauth2_provider.models import (
AccessToken as dot_access_token,
RefreshToken as dot_refresh_token
)
from provider.oauth2.models import (
AccessToken as dop_access_token,
RefreshToken as dop_refresh_token
)
from oauth2_provider.models import AccessToken as dot_access_token
from oauth2_provider.models import RefreshToken as dot_refresh_token
from provider.oauth2.models import AccessToken as dop_access_token
from provider.oauth2.models import RefreshToken as dop_refresh_token
from pytz import UTC
import third_party_auth
from lms.djangoapps.verify_student.models import VerificationDeadline, SoftwareSecurePhotoVerification
from course_modes.models import CourseMode
from lms.djangoapps.verify_student.models import SoftwareSecurePhotoVerification, VerificationDeadline
from openedx.core.djangoapps.theming.helpers import get_themes
# Enumeration of per-course verification statuses
# we display on the student dashboard.
VERIFY_STATUS_NEED_TO_VERIFY = "verify_need_to_verify"
......
......@@ -2,9 +2,10 @@
Middleware that checks user standing for the purpose of keeping users with
disabled accounts from accessing the site.
"""
from django.conf import settings
from django.http import HttpResponseForbidden
from django.utils.translation import ugettext as _
from django.conf import settings
from student.models import UserStanding
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
import django_countries.fields
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
from openedx.core.djangoapps.xmodule_django.models import CourseKeyField
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
import django.utils.timezone
from django.conf import settings
import model_utils.fields
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
......
......@@ -14,41 +14,41 @@ import hashlib
import json
import logging
import uuid
from collections import defaultdict, OrderedDict, namedtuple
from collections import OrderedDict, defaultdict, namedtuple
from datetime import datetime, timedelta
from functools import total_ordering
from importlib import import_module
from urllib import urlencode
import analytics
import dogstats_wrapper as dog_stats_api
from config_models.models import ConfigurationModel
from django.conf import settings
from django.contrib.auth.hashers import make_password
from django.contrib.auth.models import User
from django.contrib.auth.signals import user_logged_in, user_logged_out
from django.core.cache import cache
from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
from django.db import models, IntegrityError
from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist
from django.db import IntegrityError, models
from django.db.models import Count
from django.db.models.signals import pre_save, post_save
from django.dispatch import receiver, Signal
from django.db.models.signals import post_save, pre_save
from django.dispatch import Signal, receiver
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ugettext_noop
from django_countries.fields import CountryField
from eventtracking import tracker
from model_utils.models import TimeStampedModel
from opaque_keys.edx.keys import CourseKey
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from pytz import UTC
from simple_history.models import HistoricalRecords
import dogstats_wrapper as dog_stats_api
import lms.lib.comment_client as cc
import request_cache
from certificates.models import GeneratedCertificate
from course_modes.models import CourseMode
from enrollment.api import _default_course_mode
from eventtracking import tracker
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from openedx.core.djangoapps.xmodule_django.models import CourseKeyField, NoneToEmptyManager
......
......@@ -3,16 +3,15 @@ Classes used to model the roles used in the courseware. Each role is responsible
adding users, removing users, and listing members
"""
import logging
from abc import ABCMeta, abstractmethod
from collections import defaultdict
from django.contrib.auth.models import User
import logging
from openedx.core.djangoapps.xmodule_django.models import CourseKeyField
from request_cache import get_cache
from student.models import CourseAccessRole
from openedx.core.djangoapps.xmodule_django.models import CourseKeyField
log = logging.getLogger(__name__)
......
......@@ -2,12 +2,12 @@
This file contains celery tasks for sending email
"""
import logging
from django.conf import settings
from django.core import mail
from celery.task import task # pylint: disable=no-name-in-module, import-error
from celery.exceptions import MaxRetriesExceededError
from boto.exception import NoAuthHandlerFound
from celery.exceptions import MaxRetriesExceededError
from celery.task import task # pylint: disable=no-name-in-module, import-error
from django.conf import settings
from django.core import mail
log = logging.getLogger('edx.celery.task')
......
"""Provides factories for student models."""
import random
from datetime import datetime
from uuid import uuid4
from student.models import (User, UserProfile, Registration,
CourseEnrollmentAllowed, CourseEnrollment,
PendingEmailChange, UserStanding,
CourseAccessRole)
from course_modes.models import CourseMode
import factory
from django.contrib.auth.models import AnonymousUser, Group, Permission
from django.contrib.contenttypes.models import ContentType
from datetime import datetime
import factory
from factory import lazy_attribute
from factory.django import DjangoModelFactory
from uuid import uuid4
from pytz import UTC
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from pytz import UTC
from course_modes.models import CourseMode
from student.models import (
CourseAccessRole,
CourseEnrollment,
CourseEnrollmentAllowed,
PendingEmailChange,
Registration,
User,
UserProfile,
UserStanding
)
# Factories are self documenting
# pylint: disable=missing-docstring
......
"""Tests for account activation"""
from mock import patch
import unittest
from uuid import uuid4
from django.conf import settings
from django.test import TestCase, override_settings
from django.core.urlresolvers import reverse
from uuid import uuid4
from django.test import TestCase, override_settings
from mock import patch
from edxmako.shortcuts import render_to_string
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from student.models import Registration
from student.tests.factories import UserFactory
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
......
......@@ -3,9 +3,9 @@ Tests student admin.py
"""
from django.core.urlresolvers import reverse
from student.tests.factories import UserFactory
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
from student.tests.factories import UserFactory
class AdminCourseRolesPageTest(SharedModuleStoreTestCase):
......
......@@ -2,16 +2,15 @@
Tests authz.py
"""
import mock
from django.test import TestCase
from django.contrib.auth.models import User, AnonymousUser
from ccx_keys.locator import CCXLocator
from django.contrib.auth.models import AnonymousUser, User
from django.core.exceptions import PermissionDenied
from django.test import TestCase
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from student.roles import CourseInstructorRole, CourseStaffRole, CourseCreatorRole
from student.auth import add_users, has_studio_read_access, has_studio_write_access, remove_users, user_has_role
from student.roles import CourseCreatorRole, CourseInstructorRole, CourseStaffRole
from student.tests.factories import AdminFactory
from student.auth import user_has_role, add_users, remove_users, has_studio_write_access, has_studio_read_access
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from ccx_keys.locator import CCXLocator
class CreatorGroupTest(TestCase):
......
import json
import ddt
from django.conf import settings
from django.contrib.auth.models import User
from django.test import TestCase
from django.test.client import Client
from django.contrib.auth.models import User
from django.conf import settings
from django_comment_common.models import (
Role, FORUM_ROLE_ADMINISTRATOR, FORUM_ROLE_MODERATOR, FORUM_ROLE_STUDENT)
from django_comment_common.utils import seed_permissions_roles
from student.models import anonymous_id_for_user, CourseEnrollment, UserProfile
from util.testing import UrlResetMixin
from mock import Mock, patch
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from opaque_keys.edx.locator import CourseLocator
from mock import patch, Mock
import ddt
import json
from django_comment_common.models import FORUM_ROLE_ADMINISTRATOR, FORUM_ROLE_MODERATOR, FORUM_ROLE_STUDENT, Role
from django_comment_common.utils import seed_permissions_roles
from student.models import CourseEnrollment, UserProfile, anonymous_id_for_user
from util.testing import UrlResetMixin
class AutoAuthTestCase(UrlResetMixin, TestCase):
......
......@@ -10,14 +10,12 @@ from django.conf import settings
from django.core.urlresolvers import reverse
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from student.tests.factories import UserFactory, CourseEnrollmentFactory
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.django_utils import TEST_DATA_MIXED_MODULESTORE
from xmodule.modulestore.tests.factories import CourseFactory
# This import is for an lms djangoapp.
# Its testcases are only run under lms.
from bulk_email.models import CourseAuthorization, BulkEmailFlag # pylint: disable=import-error
from bulk_email.models import BulkEmailFlag, CourseAuthorization # pylint: disable=import-error
from student.tests.factories import CourseEnrollmentFactory, UserFactory
from xmodule.modulestore.tests.django_utils import TEST_DATA_MIXED_MODULESTORE, SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
......
"""Tests for display of certificates on the student dashboard. """
import unittest
import ddt
import mock
from django.conf import settings
from django.core.urlresolvers import reverse
from mock import patch
from django.test.utils import override_settings
from xmodule.modulestore import ModuleStoreEnum
from mock import patch
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
from student.tests.factories import UserFactory, CourseEnrollmentFactory
from certificates.tests.factories import GeneratedCertificateFactory # pylint: disable=import-error
from certificates.api import get_certificate_url # pylint: disable=import-error
from certificates.models import CertificateStatuses # pylint: disable=import-error
from certificates.tests.factories import GeneratedCertificateFactory # pylint: disable=import-error
from course_modes.models import CourseMode
from student.models import LinkedInAddToProfileConfiguration
from student.tests.factories import CourseEnrollmentFactory, UserFactory
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
# pylint: disable=no-member
......
"""
Test for user creation from sites with configuration overrides.
"""
from django.test import TestCase
from student.models import UserSignupSource
import mock
import json
from django.core.urlresolvers import reverse
import mock
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from django.test import TestCase
from student.models import UserSignupSource
FAKE_SITE = {
"SITE_NAME": "openedx.localhost",
......
......@@ -5,12 +5,12 @@ import six
from django.conf import settings
from django.core.urlresolvers import reverse
from django.test import RequestFactory
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
from student.cookies import get_user_info_cookie_data
from student.models import CourseEnrollment
from student.tests.factories import UserFactory
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
class CookieTests(SharedModuleStoreTestCase):
......
......@@ -4,25 +4,22 @@ by reversing group name formats.
"""
import unittest
import mock
from django.conf import settings
from django.test.client import Client
import mock
from milestones.tests.utils import MilestonesTestCaseMixin
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
from student.models import CourseEnrollment
from student.roles import GlobalStaff
from student.tests.factories import UserFactory
from student.views import get_course_enrollments
from util.milestones_helpers import get_pre_requisite_courses_not_completed, set_prerequisite_courses
from xmodule.error_module import ErrorDescriptor
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
from util.milestones_helpers import (
get_pre_requisite_courses_not_completed,
set_prerequisite_courses,
)
from milestones.tests.utils import MilestonesTestCaseMixin
class TestCourseListing(ModuleStoreTestCase, MilestonesTestCaseMixin):
......
"""Tests for account creation"""
from datetime import datetime
import json
import unittest
from datetime import datetime
import ddt
from mock import patch
import mock
import pytz
from django.conf import settings
from django.contrib.auth.models import User, AnonymousUser
from django.contrib.auth.models import AnonymousUser, User
from django.core.urlresolvers import reverse
from django.test import TestCase, TransactionTestCase
from django.test.client import RequestFactory
from django.test.utils import override_settings
from django.utils.importlib import import_module
import mock
import pytz
from mock import patch
from openedx.core.djangoapps.user_api.preferences.api import get_user_preference
from openedx.core.djangoapps.lang_pref import LANGUAGE_KEY
from openedx.core.djangoapps.site_configuration.tests.mixins import SiteMixin
import student
from django_comment_common.models import ForumsConfig
from notification_prefs import NOTIFICATION_PREF_KEY
from openedx.core.djangoapps.external_auth.models import ExternalAuthMap
import student
from openedx.core.djangoapps.lang_pref import LANGUAGE_KEY
from openedx.core.djangoapps.site_configuration.tests.mixins import SiteMixin
from openedx.core.djangoapps.user_api.preferences.api import get_user_preference
from student.models import UserAttribute
from student.views import REGISTRATION_AFFILIATE_ID, REGISTRATION_UTM_PARAMETERS, REGISTRATION_UTM_CREATED_AT
from django_comment_common.models import ForumsConfig
from student.views import REGISTRATION_AFFILIATE_ID, REGISTRATION_UTM_CREATED_AT, REGISTRATION_UTM_PARAMETERS
TEST_CS_URL = 'https://comments.service.test:123/'
......
"""
Tests for credit courses on the student dashboard.
"""
import unittest
import datetime
import unittest
import ddt
from mock import patch
import pytz
from django.conf import settings
from django.core.urlresolvers import reverse
from django.test.utils import override_settings
from mock import patch
from openedx.core.djangoapps.credit import api as credit_api
from openedx.core.djangoapps.credit.models import CreditCourse, CreditEligibility, CreditProvider
from student.models import CourseEnrollmentAttribute
from student.tests.factories import CourseEnrollmentFactory, UserFactory
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
from student.models import CourseEnrollmentAttribute
from student.tests.factories import UserFactory, CourseEnrollmentFactory
from openedx.core.djangoapps.credit.models import CreditCourse, CreditProvider, CreditEligibility
from openedx.core.djangoapps.credit import api as credit_api
TEST_CREDIT_PROVIDER_SECRET_KEY = "931433d583c84ca7ba41784bad3232e6"
......
import json
import unittest
import mock
from student.tests.factories import UserFactory, RegistrationFactory, PendingEmailChangeFactory
from student.views import (
reactivation_email_for_user, do_email_change_request, confirm_email_change,
validate_new_email, SETTING_CHANGE_INITIATED, generate_activation_email_context
)
from student.models import UserProfile, PendingEmailChange, Registration
from third_party_auth.views import inactive_user_view
from django.core.urlresolvers import reverse
from django.core import mail
import mock
from django.conf import settings
from django.contrib.auth.models import User
from django.core import mail
from django.core.urlresolvers import reverse
from django.db import transaction
from django.http import HttpResponse
from django.test import TestCase, TransactionTestCase
from django.test.client import RequestFactory
from mock import Mock, patch
from django.http import HttpResponse
from django.conf import settings
from edxmako.shortcuts import render_to_string
from util.request import safe_get_host
from util.testing import EventTestMixin
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from openedx.core.djangoapps.theming.tests.test_util import with_comprehensive_theme
from student.models import PendingEmailChange, Registration, UserProfile
from student.tests.factories import PendingEmailChangeFactory, RegistrationFactory, UserFactory
from student.views import (
SETTING_CHANGE_INITIATED,
confirm_email_change,
do_email_change_request,
generate_activation_email_context,
reactivation_email_for_user,
validate_new_email
)
from third_party_auth.views import inactive_user_view
from util.request import safe_get_host
from util.testing import EventTestMixin
class TestException(Exception):
......
"""
Tests for student enrollment.
"""
import ddt
import unittest
from mock import patch
from nose.plugins.attrib import attr
import ddt
from django.conf import settings
from django.core.urlresolvers import reverse
from mock import patch
from nose.plugins.attrib import attr
from course_modes.models import CourseMode
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
from util.testing import UrlResetMixin
from openedx.core.djangoapps.embargo.test_utils import restrict_course
from student.tests.factories import UserFactory, CourseModeFactory
from student.models import CourseEnrollment, CourseFullError
from student.roles import (
CourseInstructorRole,
CourseStaffRole,
)
from student.roles import CourseInstructorRole, CourseStaffRole
from student.tests.factories import CourseModeFactory, UserFactory
from util.testing import UrlResetMixin
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
@attr(shard=3)
......
......@@ -2,15 +2,14 @@
"""
Test that various events are fired for models in the student app.
"""
import mock
from django.db.utils import IntegrityError
from django.test import TestCase
from django_countries.fields import Country
from student.models import PasswordHistory
from student.tests.factories import UserFactory
from student.tests.tests import UserSettingsEventTestMixin
import mock
from django.db.utils import IntegrityError
class TestUserProfileEvents(UserSettingsEventTestMixin, TestCase):
......
""" Test Student helpers """
import logging
import ddt
import ddt
from django.conf import settings
from django.core.urlresolvers import reverse
from django.test import TestCase
......@@ -11,7 +11,6 @@ from testfixtures import LogCapture
from student.helpers import get_next_url_for_login_page
LOGGER_NAME = "student.helpers"
......
# -*- coding: utf-8 -*-
"""Tests for LinkedIn Add to Profile configuration. """
import ddt
from urllib import urlencode, quote
from urllib import quote, urlencode
import ddt
from django.conf import settings
from django.test import TestCase
from opaque_keys.edx.locator import CourseLocator
from openedx.core.djangoapps.site_configuration.tests.test_util import with_site_configuration_context
from student.models import LinkedInAddToProfileConfiguration
......
......@@ -4,29 +4,29 @@ Tests for student activation and login
import json
import unittest
from django.test import TestCase
from django.test.client import Client
from django.test.utils import override_settings
import httpretty
from django.conf import settings
from django.contrib.auth.models import User
from django.core.cache import cache
from django.core.urlresolvers import reverse, NoReverseMatch
from django.http import HttpResponseBadRequest, HttpResponse
import httpretty
from django.core.urlresolvers import NoReverseMatch, reverse
from django.http import HttpResponse, HttpResponseBadRequest
from django.test import TestCase
from django.test.client import Client
from django.test.utils import override_settings
from mock import patch
from social.apps.django_app.default.models import UserSocialAuth
from openedx.core.djangoapps.external_auth.models import ExternalAuthMap
from openedx.core.djangolib.testing.utils import CacheIsolationTestCase
from student.tests.factories import UserFactory, RegistrationFactory, UserProfileFactory
from student.tests.factories import RegistrationFactory, UserFactory, UserProfileFactory
from student.views import login_oauth_token
from third_party_auth.tests.utils import (
ThirdPartyOAuthTestMixin,
ThirdPartyOAuthTestMixinFacebook,
ThirdPartyOAuthTestMixinGoogle
)
from xmodule.modulestore.tests.factories import CourseFactory
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
class LoginTest(CacheIsolationTestCase):
......
"""Tests for the login and registration form rendering. """
import urllib
import unittest
import urllib
import ddt
from mock import patch
from django.conf import settings
from django.core.urlresolvers import reverse
from mock import patch
from util.testing import UrlResetMixin
from xmodule.modulestore.tests.factories import CourseFactory
from third_party_auth.tests.testutil import ThirdPartyAuthTestMixin
from util.testing import UrlResetMixin
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
# This relies on third party auth being enabled in the test
# settings with the feature flag `ENABLE_THIRD_PARTY_AUTH`
......
# -*- coding: utf-8 -*-
import json
from django.test import TestCase
from django.core.urlresolvers import reverse
from django.test import TestCase
class TestLongUsernameEmail(TestCase):
......
......@@ -5,11 +5,11 @@ import hashlib
from django.contrib.auth.models import AnonymousUser
from django.core.cache import cache
from django.db.models.functions import Lower
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
from student.models import CourseEnrollment
from student.tests.factories import UserFactory, CourseEnrollmentFactory
from student.tests.factories import CourseEnrollmentFactory, UserFactory
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
class CourseEnrollmentTests(SharedModuleStoreTestCase):
......
"""Unit tests for parental controls."""
import datetime
from django.test import TestCase
from django.test.utils import override_settings
......
......@@ -2,16 +2,16 @@
"""
This test file will verify proper password history enforcement
"""
from datetime import timedelta
from django.test import TestCase
from django.test.utils import override_settings
from django.utils import timezone
from freezegun import freeze_time
from mock import patch
from student.tests.factories import UserFactory, AdminFactory
from student.models import PasswordHistory
from freezegun import freeze_time
from datetime import timedelta
from django.test.utils import override_settings
from student.tests.factories import AdminFactory, UserFactory
@patch.dict("django.conf.settings.FEATURES", {'ADVANCED_SECURITY': True})
......
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