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