Commit e8a36957 by Andy Armstrong Committed by GitHub

Merge pull request #15205 from edx/andya/clean-imports-cms

Reorder Studio imports using isort
parents f4b0a76c ebb04ca3
...@@ -5,9 +5,12 @@ and auto discover tasks in all installed django apps. ...@@ -5,9 +5,12 @@ and auto discover tasks in all installed django apps.
Taken from: http://celery.readthedocs.org/en/latest/django/first-steps-with-django.html Taken from: http://celery.readthedocs.org/en/latest/django/first-steps-with-django.html
""" """
from __future__ import absolute_import from __future__ import absolute_import
import os import os
from celery import Celery from celery import Celery
from django.conf import settings from django.conf import settings
from openedx.core.lib.celery.routers import AlternateEnvironmentRouter from openedx.core.lib.celery.routers import AlternateEnvironmentRouter
# set the default Django settings module for the 'celery' program. # set the default Django settings module for the 'celery' program.
......
...@@ -4,13 +4,14 @@ Receivers of signals sent from django-user-tasks ...@@ -4,13 +4,14 @@ Receivers of signals sent from django-user-tasks
from __future__ import absolute_import, print_function, unicode_literals from __future__ import absolute_import, print_function, unicode_literals
import logging import logging
from six.moves.urllib.parse import urljoin # pylint: disable=import-error
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.dispatch import receiver from django.dispatch import receiver
from user_tasks.models import UserTaskArtifact from user_tasks.models import UserTaskArtifact
from user_tasks.signals import user_task_stopped from user_tasks.signals import user_task_stopped
from six.moves.urllib.parse import urljoin # pylint: disable=import-error
from .tasks import send_task_complete_email from .tasks import send_task_complete_email
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)
......
...@@ -2,11 +2,10 @@ ...@@ -2,11 +2,10 @@
Celery tasks used by cms_user_tasks Celery tasks used by cms_user_tasks
""" """
from celery.task import task from boto.exception import NoAuthHandlerFound
from celery.exceptions import MaxRetriesExceededError from celery.exceptions import MaxRetriesExceededError
from celery.task import task
from celery.utils.log import get_task_logger from celery.utils.log import get_task_logger
from boto.exception import NoAuthHandlerFound
from django.conf import settings from django.conf import settings
from django.core import mail from django.core import mail
......
...@@ -4,21 +4,20 @@ Unit tests for integration of the django-user-tasks app and its REST API. ...@@ -4,21 +4,20 @@ Unit tests for integration of the django-user-tasks app and its REST API.
from __future__ import absolute_import, print_function, unicode_literals from __future__ import absolute_import, print_function, unicode_literals
from uuid import uuid4
import logging import logging
from uuid import uuid4
import mock import mock
from boto.exception import NoAuthHandlerFound from boto.exception import NoAuthHandlerFound
from rest_framework.test import APITestCase from django.conf import settings
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.core.urlresolvers import reverse
from django.test import override_settings from django.test import override_settings
from django.conf import settings from rest_framework.test import APITestCase
from django.core import mail
from user_tasks.models import UserTaskArtifact, UserTaskStatus from user_tasks.models import UserTaskArtifact, UserTaskStatus
from user_tasks.serializers import ArtifactSerializer, StatusSerializer from user_tasks.serializers import ArtifactSerializer, StatusSerializer
from .signals import user_task_stopped from .signals import user_task_stopped
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
Admin site bindings for contentstore Admin site bindings for contentstore
""" """
from config_models.admin import ConfigurationModelAdmin
from django.contrib import admin from django.contrib import admin
from config_models.admin import ConfigurationModelAdmin from contentstore.models import PushNotificationConfig, VideoUploadConfig
from contentstore.models import VideoUploadConfig, PushNotificationConfig
admin.site.register(VideoUploadConfig, ConfigurationModelAdmin) admin.site.register(VideoUploadConfig, ConfigurationModelAdmin)
admin.site.register(PushNotificationConfig, ConfigurationModelAdmin) admin.site.register(PushNotificationConfig, ConfigurationModelAdmin)
...@@ -4,12 +4,12 @@ Class for manipulating groups configuration on a course object. ...@@ -4,12 +4,12 @@ Class for manipulating groups configuration on a course object.
import json import json
import logging import logging
from util.db import generate_int_id, MYSQL_MAX_INT
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from contentstore.utils import reverse_usage_url from contentstore.utils import reverse_usage_url
from openedx.core.djangoapps.course_groups.partition_scheme import get_cohorted_user_partition from openedx.core.djangoapps.course_groups.partition_scheme import get_cohorted_user_partition
from xmodule.partitions.partitions import UserPartition, MINIMUM_STATIC_PARTITION_ID from util.db import MYSQL_MAX_INT, generate_int_id
from xmodule.partitions.partitions import MINIMUM_STATIC_PARTITION_ID, UserPartition
from xmodule.partitions.partitions_service import get_all_partitions_for_course from xmodule.partitions.partitions_service import get_all_partitions_for_course
from xmodule.split_test_module import get_split_user_partitions from xmodule.split_test_module import get_split_user_partitions
......
...@@ -12,18 +12,17 @@ Current db representation: ...@@ -12,18 +12,17 @@ Current db representation:
} }
""" """
import re
import logging import logging
import re
from django.http import HttpResponseBadRequest from django.http import HttpResponseBadRequest
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from xmodule.modulestore.exceptions import ItemNotFoundError
from xmodule.modulestore.django import modulestore
from xmodule.html_module import CourseInfoModule
from openedx.core.lib.xblock_utils import get_course_update_items
from cms.djangoapps.contentstore.push_notification import enqueue_push_course_update from cms.djangoapps.contentstore.push_notification import enqueue_push_course_update
from openedx.core.lib.xblock_utils import get_course_update_items
from xmodule.html_module import CourseInfoModule
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.exceptions import ItemNotFoundError
# # This should be in a class which inherits from XmlDescriptor # # This should be in a class which inherits from XmlDescriptor
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
......
""" Code to allow module store to interface with courseware index """ """ Code to allow module store to interface with courseware index """
from __future__ import absolute_import from __future__ import absolute_import
from abc import ABCMeta, abstractmethod
from datetime import timedelta
import logging import logging
import re import re
from six import add_metaclass from abc import ABCMeta, abstractmethod
from datetime import timedelta
from django.conf import settings from django.conf import settings
from django.utils.translation import ugettext_lazy, ugettext as _
from django.core.urlresolvers import resolve from django.core.urlresolvers import resolve
from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy
from search.search_engine_base import SearchEngine
from six import add_metaclass
from contentstore.course_group_config import GroupConfiguration from contentstore.course_group_config import GroupConfiguration
from course_modes.models import CourseMode from course_modes.models import CourseMode
from eventtracking import tracker from eventtracking import tracker
from openedx.core.lib.courses import course_image_url from openedx.core.lib.courses import course_image_url
from search.search_engine_base import SearchEngine
from xmodule.annotator_mixin import html_to_text from xmodule.annotator_mixin import html_to_text
from xmodule.modulestore import ModuleStoreEnum
from xmodule.library_tools import normalize_key_for_search from xmodule.library_tools import normalize_key_for_search
from xmodule.modulestore import ModuleStoreEnum
# REINDEX_AGE is the default amount of time that we look back for changes # REINDEX_AGE is the default amount of time that we look back for changes
# that might have happened. If we are provided with a time at which the # that might have happened. If we are provided with a time at which the
......
from django.core.files.uploadhandler import FileUploadHandler
import time import time
from django.core.files.uploadhandler import FileUploadHandler
class DebugFileUploader(FileUploadHandler): class DebugFileUploader(FileUploadHandler):
def __init__(self, request=None): def __init__(self, request=None):
......
# pylint: disable=missing-docstring # pylint: disable=missing-docstring
# pylint: disable=redefined-outer-name # pylint: disable=redefined-outer-name
from lettuce import world, step from lettuce import step, world
from nose.tools import assert_false, assert_equal, assert_regexp_matches from nose.tools import assert_equal, assert_false, assert_regexp_matches
from common import type_in_codemirror, press_the_notification_button, get_codemirror_value
from common import get_codemirror_value, press_the_notification_button, type_in_codemirror
KEY_CSS = '.key h3.title' KEY_CSS = '.key h3.title'
DISPLAY_NAME_KEY = "Course Display Name" DISPLAY_NAME_KEY = "Course Display Name"
......
...@@ -2,21 +2,21 @@ ...@@ -2,21 +2,21 @@
# pylint: disable=redefined-outer-name # pylint: disable=redefined-outer-name
import os import os
from lettuce import world, step from logging import getLogger
from nose.tools import assert_true, assert_in
from django.conf import settings
from student.roles import CourseStaffRole, CourseInstructorRole, GlobalStaff
from student.models import get_user
from django.conf import settings
from lettuce import step, world
from nose.tools import assert_in, assert_true
from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.keys import Keys
from logging import getLogger
from student.tests.factories import AdminFactory
from student import auth from student import auth
from student.models import get_user
from student.roles import CourseInstructorRole, CourseStaffRole, GlobalStaff
from student.tests.factories import AdminFactory
from terrain.browser import reset_data
logger = getLogger(__name__) logger = getLogger(__name__)
from terrain.browser import reset_data
TEST_ROOT = settings.COMMON_TEST_DATA_ROOT TEST_ROOT = settings.COMMON_TEST_DATA_ROOT
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
# argument name "step" instead of "_step" and pylint does not like that. # argument name "step" instead of "_step" and pylint does not like that.
# pylint: disable=unused-argument # pylint: disable=unused-argument
from lettuce import world, step from lettuce import step, world
from nose.tools import assert_true, assert_in, assert_equal from nose.tools import assert_equal, assert_in, assert_true
DISPLAY_NAME = "Display Name" DISPLAY_NAME = "Display Name"
......
...@@ -3,10 +3,11 @@ ...@@ -3,10 +3,11 @@
from lettuce import world from lettuce import world
from nose.tools import assert_equal, assert_in from nose.tools import assert_equal, assert_in
from terrain.steps import reload_the_page
from common import type_in_codemirror
from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.keys import Keys
from common import type_in_codemirror
from terrain.steps import reload_the_page
@world.absorb @world.absorb
def create_component_instance(step, category, component_type=None, is_advanced=False, advanced_component=None): def create_component_instance(step, category, component_type=None, is_advanced=False, advanced_component=None):
......
# pylint: disable=missing-docstring # pylint: disable=missing-docstring
# pylint: disable=redefined-outer-name # pylint: disable=redefined-outer-name
from lettuce import world, step
from selenium.webdriver.common.keys import Keys
from cms.djangoapps.contentstore.features.common import type_in_codemirror
from django.conf import settings from django.conf import settings
from lettuce import step, world
from nose.tools import assert_false, assert_true
from selenium.webdriver.common.keys import Keys
from nose.tools import assert_true, assert_false from cms.djangoapps.contentstore.features.common import type_in_codemirror
TEST_ROOT = settings.COMMON_TEST_DATA_ROOT TEST_ROOT = settings.COMMON_TEST_DATA_ROOT
......
# pylint: disable=missing-docstring # pylint: disable=missing-docstring
from cms.djangoapps.contentstore.features.common import type_in_codemirror, get_codemirror_value from lettuce import step, world
from lettuce import world, step
from nose.tools import assert_in from nose.tools import assert_in
from cms.djangoapps.contentstore.features.common import get_codemirror_value, type_in_codemirror
@step(u'I go to the course updates page') @step(u'I go to the course updates page')
def go_to_updates(_step): def go_to_updates(_step):
......
...@@ -3,8 +3,9 @@ ...@@ -3,8 +3,9 @@
# pylint: disable=unused-argument # pylint: disable=unused-argument
import os import os
from lettuce import world, step
from django.conf import settings from django.conf import settings
from lettuce import step, world
def import_file(filename): def import_file(filename):
......
...@@ -2,9 +2,11 @@ ...@@ -2,9 +2,11 @@
# pylint: disable=redefined-outer-name # pylint: disable=redefined-outer-name
# pylint: disable=unused-argument # pylint: disable=unused-argument
from lettuce import world, step from lettuce import step, world
from common import * from common import *
############### ACTIONS #################### ############### ACTIONS ####################
......
# disable missing docstring # disable missing docstring
# pylint: disable=missing-docstring # pylint: disable=missing-docstring
from lettuce import world, step from lettuce import step, world
@step('I have created a Discussion Tag$') @step('I have created a Discussion Tag$')
......
# pylint: disable=missing-docstring # pylint: disable=missing-docstring
# pylint: disable=redefined-outer-name # pylint: disable=redefined-outer-name
from lettuce import world, step from lettuce import step, world
from common import * from nose.tools import assert_equal, assert_in, assert_not_equal
from terrain.steps import reload_the_page
from selenium.common.exceptions import InvalidElementStateException from selenium.common.exceptions import InvalidElementStateException
from common import *
from contentstore.utils import reverse_course_url from contentstore.utils import reverse_course_url
from nose.tools import assert_in, assert_equal, assert_not_equal from terrain.steps import reload_the_page
@step(u'I am viewing the grading settings') @step(u'I am viewing the grading settings')
......
...@@ -3,9 +3,10 @@ ...@@ -3,9 +3,10 @@
from collections import OrderedDict from collections import OrderedDict
from lettuce import world, step from lettuce import step, world
from nose.tools import assert_in, assert_false, assert_true, assert_equal from nose.tools import assert_equal, assert_false, assert_in, assert_true
from common import type_in_codemirror, get_codemirror_value
from common import get_codemirror_value, type_in_codemirror
CODEMIRROR_SELECTOR_PREFIX = "$('iframe').contents().find" CODEMIRROR_SELECTOR_PREFIX = "$('iframe').contents().find"
......
...@@ -2,10 +2,9 @@ ...@@ -2,10 +2,9 @@
# pylint: disable=redefined-outer-name # pylint: disable=redefined-outer-name
# pylint: disable=unused-argument # pylint: disable=unused-argument
from lettuce import world, step from lettuce import step, world
from nose.tools import assert_equal, assert_in from nose.tools import assert_equal, assert_in
CSS_FOR_TAB_ELEMENT = "li[data-tab-id='{0}'] input.toggle-checkbox" CSS_FOR_TAB_ELEMENT = "li[data-tab-id='{0}'] input.toggle-checkbox"
......
...@@ -2,10 +2,12 @@ ...@@ -2,10 +2,12 @@
# pylint: disable=missing-docstring # pylint: disable=missing-docstring
import json import json
from lettuce import world, step
from lettuce import step, world
from nose.tools import assert_equal, assert_true from nose.tools import assert_equal, assert_true
from common import type_in_codemirror, open_new_course
from advanced_settings import change_value, ADVANCED_MODULES_KEY from advanced_settings import ADVANCED_MODULES_KEY, change_value
from common import open_new_course, type_in_codemirror
from course_import import import_file from course_import import import_file
DISPLAY_NAME = "Display Name" DISPLAY_NAME = "Display Name"
......
# pylint: disable=missing-docstring # pylint: disable=missing-docstring
# pylint: disable=redefined-outer-name # pylint: disable=redefined-outer-name
from lettuce import world, step from lettuce import step, world
from nose.tools import assert_true, assert_false from nose.tools import assert_false, assert_true
@step('I fill in the registration form$') @step('I fill in the registration form$')
......
# pylint: disable=missing-docstring # pylint: disable=missing-docstring
from lettuce import world, step
from django.conf import settings from django.conf import settings
from common import upload_file from lettuce import step, world
from nose.tools import assert_equal from nose.tools import assert_equal
from common import upload_file
TEST_ROOT = settings.COMMON_TEST_DATA_ROOT TEST_ROOT = settings.COMMON_TEST_DATA_ROOT
......
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
# pylint: disable=missing-docstring # pylint: disable=missing-docstring
import os import os
from lettuce import world, step
from django.conf import settings from django.conf import settings
from lettuce import step, world
from splinter.request_handler.request_handler import RequestHandler
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.exceptions import NotFoundError
from splinter.request_handler.request_handler import RequestHandler
TEST_ROOT = settings.COMMON_TEST_DATA_ROOT TEST_ROOT = settings.COMMON_TEST_DATA_ROOT
......
# pylint: disable=missing-docstring # pylint: disable=missing-docstring
# pylint: disable=redefined-outer-name # pylint: disable=redefined-outer-name
from lettuce import world, step
from lettuce.django import django_url
from django.conf import settings
import requests
import string
import random
import os import os
import random
import string
import requests
from django.conf import settings
from django.contrib.auth.models import User from django.contrib.auth.models import User
from student.models import CourseEnrollment from lettuce import step, world
from lettuce.django import django_url
from nose.tools import assert_equal, assert_not_equal from nose.tools import assert_equal, assert_not_equal
from student.models import CourseEnrollment
TEST_ROOT = settings.COMMON_TEST_DATA_ROOT TEST_ROOT = settings.COMMON_TEST_DATA_ROOT
ASSET_NAMES_CSS = 'td.name-col > span.title > a.filename' ASSET_NAMES_CSS = 'td.name-col > span.title > a.filename'
......
# pylint: disable=missing-docstring # pylint: disable=missing-docstring
from lettuce import world, step from lettuce import step, world
SELECTORS = { SELECTORS = {
'spinner': '.video-wrapper .spinner', 'spinner': '.video-wrapper .spinner',
......
...@@ -7,8 +7,8 @@ from collections import namedtuple ...@@ -7,8 +7,8 @@ from collections import namedtuple
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
from xmodule.modulestore.django import modulestore
from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore
Result = namedtuple("Result", ["course_key", "cert_name_short", "cert_name_long", "should_clean"]) Result = namedtuple("Result", ["course_key", "cert_name_short", "cert_name_long", "should_clean"])
......
...@@ -5,8 +5,8 @@ or with filename which starts with "._") for all courses ...@@ -5,8 +5,8 @@ or with filename which starts with "._") for all courses
import logging import logging
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
from xmodule.contentstore.django import contentstore
from xmodule.contentstore.django import contentstore
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
......
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
Script for cloning a course Script for cloning a course
""" """
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
from xmodule.modulestore.django import modulestore
from student.roles import CourseInstructorRole, CourseStaffRole
from opaque_keys.edx.keys import CourseKey
from opaque_keys import InvalidKeyError from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey
from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys.edx.locations import SlashSeparatedCourseKey
from student.roles import CourseInstructorRole, CourseStaffRole
from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore
# #
......
""" """
Django management command to create a course in a specific modulestore Django management command to create a course in a specific modulestore
""" """
from django.core.management.base import BaseCommand, CommandError
from django.contrib.auth.models import User from django.contrib.auth.models import User
from xmodule.modulestore import ModuleStoreEnum from django.core.management.base import BaseCommand, CommandError
from contentstore.views.course import create_new_course_in_store
from contentstore.management.commands.utils import user_from_str from contentstore.management.commands.utils import user_from_str
from contentstore.views.course import create_new_course_in_store
from xmodule.modulestore import ModuleStoreEnum
class Command(BaseCommand): class Command(BaseCommand):
......
...@@ -8,13 +8,15 @@ ...@@ -8,13 +8,15 @@
none none
""" """
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
from .prompt import query_yes_no
from contentstore.utils import delete_course_and_groups
from opaque_keys.edx.keys import CourseKey
from opaque_keys import InvalidKeyError from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey
from contentstore.utils import delete_course_and_groups
from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from .prompt import query_yes_no
class Command(BaseCommand): class Command(BaseCommand):
""" """
......
"""Script for deleting orphans""" """Script for deleting orphans"""
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
from contentstore.views.item import _delete_orphans
from opaque_keys.edx.keys import CourseKey
from opaque_keys import InvalidKeyError from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey
from contentstore.views.item import _delete_orphans
from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore import ModuleStoreEnum
......
...@@ -8,14 +8,14 @@ ...@@ -8,14 +8,14 @@
# #
from optparse import make_option from optparse import make_option
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
from .prompt import query_yes_no from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from contentstore.views import tabs
from courseware.courses import get_course_by_id from courseware.courses import get_course_by_id
from contentstore.views import tabs from .prompt import query_yes_no
from opaque_keys import InvalidKeyError
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from opaque_keys.edx.keys import CourseKey
def print_course(course): def print_course(course):
......
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from xmodule.contentstore.utils import empty_asset_trashcan from xmodule.contentstore.utils import empty_asset_trashcan
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from opaque_keys.edx.keys import CourseKey
from .prompt import query_yes_no from .prompt import query_yes_no
from opaque_keys import InvalidKeyError
from opaque_keys.edx.locations import SlashSeparatedCourseKey
class Command(BaseCommand): class Command(BaseCommand):
......
...@@ -4,13 +4,14 @@ Script for exporting courseware from Mongo to a tar.gz file ...@@ -4,13 +4,14 @@ Script for exporting courseware from Mongo to a tar.gz file
import os import os
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
from xmodule.modulestore.xml_exporter import export_course_to_xml
from xmodule.modulestore.django import modulestore
from opaque_keys.edx.keys import CourseKey
from xmodule.contentstore.django import contentstore
from opaque_keys import InvalidKeyError from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey
from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys.edx.locations import SlashSeparatedCourseKey
from xmodule.contentstore.django import contentstore
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.xml_exporter import export_course_to_xml
class Command(BaseCommand): class Command(BaseCommand):
""" """
......
...@@ -2,9 +2,10 @@ ...@@ -2,9 +2,10 @@
Script for exporting all courseware from Mongo to a directory and listing the courses which failed to export Script for exporting all courseware from Mongo to a directory and listing the courses which failed to export
""" """
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
from xmodule.modulestore.xml_exporter import export_course_to_xml
from xmodule.modulestore.django import modulestore
from xmodule.contentstore.django import contentstore from xmodule.contentstore.django import contentstore
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.xml_exporter import export_course_to_xml
class Command(BaseCommand): class Command(BaseCommand):
......
...@@ -19,17 +19,16 @@ import os ...@@ -19,17 +19,16 @@ import os
import re import re
import shutil import shutil
import tarfile import tarfile
from tempfile import mktemp, mkdtemp from tempfile import mkdtemp, mktemp
from textwrap import dedent from textwrap import dedent
from path import Path as path
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey
from path import Path as path
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from xmodule.modulestore.xml_exporter import export_course_to_xml from xmodule.modulestore.xml_exporter import export_course_to_xml
from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey
class Command(BaseCommand): class Command(BaseCommand):
......
...@@ -3,8 +3,10 @@ Script for fixing the item not found errors in a course ...@@ -3,8 +3,10 @@ Script for fixing the item not found errors in a course
""" """
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
from opaque_keys.edx.keys import CourseKey from opaque_keys.edx.keys import CourseKey
from xmodule.modulestore.django import modulestore
from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore
# To run from command line: ./manage.py cms fix_not_found course-v1:org+course+run # To run from command line: ./manage.py cms fix_not_found course-v1:org+course+run
......
...@@ -2,13 +2,16 @@ ...@@ -2,13 +2,16 @@
Script for force publishing a course Script for force publishing a course
""" """
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore
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 xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore
from .prompt import query_yes_no from .prompt import query_yes_no
from .utils import get_course_versions from .utils import get_course_versions
# To run from command line: ./manage.py cms force_publish course-v1:org+course+run # To run from command line: ./manage.py cms force_publish course-v1:org+course+run
......
...@@ -18,12 +18,12 @@ from optparse import make_option ...@@ -18,12 +18,12 @@ from optparse import make_option
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey
from opaque_keys.edx.locations import SlashSeparatedCourseKey
import contentstore.git_export_utils as git_export_utils import contentstore.git_export_utils as git_export_utils
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from opaque_keys import InvalidKeyError
from contentstore.git_export_utils import GitExportError from contentstore.git_export_utils import GitExportError
from opaque_keys.edx.keys import CourseKey
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
......
...@@ -4,12 +4,12 @@ Script for importing courseware from XML format ...@@ -4,12 +4,12 @@ Script for importing courseware from XML format
from optparse import make_option from optparse import make_option
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
from django_comment_common.utils import (seed_permissions_roles,
are_permissions_roles_seeded) from django_comment_common.utils import are_permissions_roles_seeded, seed_permissions_roles
from xmodule.modulestore.xml_importer import import_course_from_xml from xmodule.contentstore.django import contentstore
from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from xmodule.contentstore.django import contentstore from xmodule.modulestore.xml_importer import import_course_from_xml
class Command(BaseCommand): class Command(BaseCommand):
......
...@@ -2,14 +2,15 @@ ...@@ -2,14 +2,15 @@
Django management command to migrate a course from the old Mongo modulestore Django management command to migrate a course from the old Mongo modulestore
to the new split-Mongo modulestore. to the new split-Mongo modulestore.
""" """
from django.core.management.base import BaseCommand, CommandError
from django.contrib.auth.models import User from django.contrib.auth.models import User
from xmodule.modulestore.django import modulestore from django.core.management.base import BaseCommand, CommandError
from xmodule.modulestore.split_migrator import SplitMigrator
from opaque_keys.edx.keys import CourseKey
from opaque_keys import InvalidKeyError from opaque_keys import InvalidKeyError
from xmodule.modulestore import ModuleStoreEnum from opaque_keys.edx.keys import CourseKey
from contentstore.management.commands.utils import user_from_str from contentstore.management.commands.utils import user_from_str
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.split_migrator import SplitMigrator
class Command(BaseCommand): class Command(BaseCommand):
......
...@@ -3,13 +3,14 @@ Script for granting existing course instructors course creator privileges. ...@@ -3,13 +3,14 @@ Script for granting existing course instructors course creator privileges.
This script is only intended to be run once on a given environment. This script is only intended to be run once on a given environment.
""" """
from course_creators.views import add_user_with_status_granted, add_user_with_status_unrequested
from django.core.management.base import BaseCommand
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.core.management.base import BaseCommand
from django.db.utils import IntegrityError from django.db.utils import IntegrityError
from course_creators.views import add_user_with_status_granted, add_user_with_status_unrequested
from student.roles import CourseInstructorRole, CourseStaffRole from student.roles import CourseInstructorRole, CourseStaffRole
#------------ to run: ./manage.py cms populate_creators --settings=dev #------------ to run: ./manage.py cms populate_creators --settings=dev
......
""" Management command to update courses' search index """ """ Management command to update courses' search index """
import logging import logging
from django.core.management import BaseCommand, CommandError
from optparse import make_option from optparse import make_option
from textwrap import dedent from textwrap import dedent
from contentstore.courseware_index import CoursewareSearchIndexer from django.core.management import BaseCommand, CommandError
from search.search_engine_base import SearchEngine
from elasticsearch import exceptions from elasticsearch import exceptions
from opaque_keys.edx.keys import CourseKey
from opaque_keys import InvalidKeyError from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey
from opaque_keys.edx.locator import CourseLocator from opaque_keys.edx.locator import CourseLocator
from search.search_engine_base import SearchEngine
from .prompt import query_yes_no from contentstore.courseware_index import CoursewareSearchIndexer
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from .prompt import query_yes_no
class Command(BaseCommand): class Command(BaseCommand):
""" """
......
""" Management command to update libraries' search index """ """ Management command to update libraries' search index """
from django.core.management import BaseCommand, CommandError
from optparse import make_option from optparse import make_option
from textwrap import dedent from textwrap import dedent
from contentstore.courseware_index import LibrarySearchIndexer from django.core.management import BaseCommand, CommandError
from opaque_keys.edx.keys import CourseKey
from opaque_keys import InvalidKeyError from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey
from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys.edx.locations import SlashSeparatedCourseKey
from opaque_keys.edx.locator import LibraryLocator from opaque_keys.edx.locator import LibraryLocator
from .prompt import query_yes_no from contentstore.courseware_index import LibrarySearchIndexer
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from .prompt import query_yes_no
class Command(BaseCommand): class Command(BaseCommand):
""" """
......
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
from xmodule.contentstore.utils import restore_asset_from_trashcan from xmodule.contentstore.utils import restore_asset_from_trashcan
......
...@@ -3,6 +3,7 @@ Common methods for cms commands to use ...@@ -3,6 +3,7 @@ Common methods for cms commands to use
""" """
from django.contrib.auth.models import User from django.contrib.auth.models import User
from opaque_keys.edx.keys import CourseKey from opaque_keys.edx.keys import CourseKey
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
Verify the structure of courseware as to it's suitability for import Verify the structure of courseware as to it's suitability for import
""" """
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
from xmodule.modulestore.xml_importer import perform_xlint from xmodule.modulestore.xml_importer import perform_xlint
......
# -*- 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,9 +2,8 @@ ...@@ -2,9 +2,8 @@
Models for contentstore Models for contentstore
""" """
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 VideoUploadConfig(ConfigurationModel): class VideoUploadConfig(ConfigurationModel):
......
...@@ -5,24 +5,20 @@ Code related to the handling of Proctored Exams in Studio ...@@ -5,24 +5,20 @@ Code related to the handling of Proctored Exams in Studio
import logging import logging
from django.conf import settings from django.conf import settings
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.exceptions import ItemNotFoundError
from contentstore.views.helpers import is_item_in_course_tree
from edx_proctoring.api import ( from edx_proctoring.api import (
get_exam_by_content_id,
update_exam,
create_exam, create_exam,
get_all_exams_for_course,
update_review_policy,
create_exam_review_policy, create_exam_review_policy,
get_all_exams_for_course,
get_exam_by_content_id,
remove_review_policy, remove_review_policy,
update_exam,
update_review_policy
) )
from edx_proctoring.exceptions import ( from edx_proctoring.exceptions import ProctoredExamNotFoundException, ProctoredExamReviewPolicyNotFoundException
ProctoredExamNotFoundException,
ProctoredExamReviewPolicyNotFoundException from contentstore.views.helpers import is_item_in_course_tree
) from xmodule.modulestore.django import modulestore
from xmodule.modulestore.exceptions import ItemNotFoundError
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
......
...@@ -2,16 +2,17 @@ ...@@ -2,16 +2,17 @@
Helper methods for push notifications from Studio. Helper methods for push notifications from Studio.
""" """
from logging import exception as log_exception
from uuid import uuid4 from uuid import uuid4
from django.conf import settings from django.conf import settings
from logging import exception as log_exception
from contentstore.tasks import push_course_update_task
from contentstore.models import PushNotificationConfig from contentstore.models import PushNotificationConfig
from xmodule.modulestore.django import modulestore from contentstore.tasks import push_course_update_task
from parse_rest.installation import Push
from parse_rest.connection import register from parse_rest.connection import register
from parse_rest.core import ParseError from parse_rest.core import ParseError
from parse_rest.installation import Push
from xmodule.modulestore.django import modulestore
def push_notification_enabled(): def push_notification_enabled():
......
...@@ -2,17 +2,16 @@ ...@@ -2,17 +2,16 @@
import logging import logging
from datetime import datetime from datetime import datetime
from pytz import UTC
from django.dispatch import receiver from django.dispatch import receiver
from pytz import UTC
from xmodule.modulestore.django import modulestore, SignalHandler
from contentstore.courseware_index import CoursewareSearchIndexer, LibrarySearchIndexer from contentstore.courseware_index import CoursewareSearchIndexer, LibrarySearchIndexer
from contentstore.proctoring import register_special_exams from contentstore.proctoring import register_special_exams
from openedx.core.djangoapps.credit.signals import on_course_publish from openedx.core.djangoapps.credit.signals import on_course_publish
from openedx.core.lib.gating import api as gating_api from openedx.core.lib.gating import api as gating_api
from util.module_utils import yield_dynamic_descriptor_descendants from util.module_utils import yield_dynamic_descriptor_descendants
from xmodule.modulestore.django import SignalHandler, modulestore
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
......
...@@ -5,7 +5,6 @@ from __future__ import absolute_import ...@@ -5,7 +5,6 @@ from __future__ import absolute_import
from django.conf import settings from django.conf import settings
from django.core.files.storage import get_storage_class from django.core.files.storage import get_storage_class
from storages.backends.s3boto import S3BotoStorage from storages.backends.s3boto import S3BotoStorage
from storages.utils import setting from storages.utils import setting
......
...@@ -13,11 +13,6 @@ from tempfile import NamedTemporaryFile, mkdtemp ...@@ -13,11 +13,6 @@ from tempfile import NamedTemporaryFile, mkdtemp
from celery.task import task from celery.task import task
from celery.utils.log import get_task_logger from celery.utils.log import get_task_logger
from organizations.models import OrganizationCourse
from path import Path as path
from pytz import UTC
from six import iteritems, text_type
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.exceptions import SuspiciousOperation from django.core.exceptions import SuspiciousOperation
...@@ -25,8 +20,13 @@ from django.core.files import File ...@@ -25,8 +20,13 @@ from django.core.files import File
from django.test import RequestFactory from django.test import RequestFactory
from django.utils.text import get_valid_filename from django.utils.text import get_valid_filename
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from djcelery.common import respect_language from djcelery.common import respect_language
from opaque_keys.edx.keys import CourseKey
from opaque_keys.edx.locator import LibraryLocator
from organizations.models import OrganizationCourse
from path import Path as path
from pytz import UTC
from six import iteritems, text_type
from user_tasks.models import UserTaskArtifact, UserTaskStatus from user_tasks.models import UserTaskArtifact, UserTaskStatus
from user_tasks.tasks import UserTask from user_tasks.tasks import UserTask
...@@ -36,9 +36,7 @@ from contentstore.storage import course_import_export_storage ...@@ -36,9 +36,7 @@ from contentstore.storage import course_import_export_storage
from contentstore.utils import initialize_permissions, reverse_usage_url from contentstore.utils import initialize_permissions, reverse_usage_url
from course_action_state.models import CourseRerunState from course_action_state.models import CourseRerunState
from models.settings.course_metadata import CourseMetadata from models.settings.course_metadata import CourseMetadata
from opaque_keys.edx.keys import CourseKey from openedx.core.djangoapps.embargo.models import CountryAccessRule, RestrictedCourse
from opaque_keys.edx.locator import LibraryLocator
from openedx.core.djangoapps.embargo.models import RestrictedCourse, CountryAccessRule
from openedx.core.lib.extract_tar import safetar_extractall from openedx.core.lib.extract_tar import safetar_extractall
from student.auth import has_course_author_access from student.auth import has_course_author_access
from xmodule.contentstore.django import contentstore from xmodule.contentstore.django import contentstore
...@@ -50,7 +48,6 @@ from xmodule.modulestore.exceptions import DuplicateCourseError, ItemNotFoundErr ...@@ -50,7 +48,6 @@ from xmodule.modulestore.exceptions import DuplicateCourseError, ItemNotFoundErr
from xmodule.modulestore.xml_exporter import export_course_to_xml, export_library_to_xml from xmodule.modulestore.xml_exporter import export_course_to_xml, export_library_to_xml
from xmodule.modulestore.xml_importer import import_course_from_xml, import_library_from_xml from xmodule.modulestore.xml_importer import import_course_from_xml, import_library_from_xml
LOGGER = get_task_logger(__name__) LOGGER = get_task_logger(__name__)
FILE_READ_CHUNK = 1024 # bytes FILE_READ_CHUNK = 1024 # bytes
FULL_COURSE_REINDEX_THRESHOLD = 1 FULL_COURSE_REINDEX_THRESHOLD = 1
......
...@@ -2,21 +2,21 @@ ...@@ -2,21 +2,21 @@
Unit tests for cloning a course between the same and different module stores. Unit tests for cloning a course between the same and different module stores.
""" """
import json import json
from django.conf import settings
from django.conf import settings
from mock import Mock, patch
from opaque_keys.edx.locator import CourseLocator from opaque_keys.edx.locator import CourseLocator
from xmodule.modulestore import ModuleStoreEnum, EdxJSONEncoder
from contentstore.tests.utils import CourseTestCase
from contentstore.tasks import rerun_course from contentstore.tasks import rerun_course
from student.auth import has_course_author_access from contentstore.tests.utils import CourseTestCase
from course_action_state.models import CourseRerunState
from course_action_state.managers import CourseRerunUIStateManager from course_action_state.managers import CourseRerunUIStateManager
from mock import patch, Mock from course_action_state.models import CourseRerunState
from student.auth import has_course_author_access
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.modulestore import EdxJSONEncoder, ModuleStoreEnum
from xmodule.modulestore.tests.factories import CourseFactory from xmodule.modulestore.tests.factories import CourseFactory
TEST_DATA_DIR = settings.COMMON_TEST_DATA_ROOT TEST_DATA_DIR = settings.COMMON_TEST_DATA_ROOT
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import copy import copy
import mock
import shutil import shutil
import lxml.html
from lxml import etree
import ddt
from datetime import timedelta from datetime import timedelta
from fs.osfs import OSFS from functools import wraps
from json import loads from json import loads
from path import Path as path
from textwrap import dedent from textwrap import dedent
from uuid import uuid4
from functools import wraps
from unittest import SkipTest from unittest import SkipTest
from uuid import uuid4
import ddt
import lxml.html
import mock
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.test import TestCase from django.test import TestCase
from django.test.utils import override_settings from django.test.utils import override_settings
from edxval.api import create_video, get_videos_for_course
from fs.osfs import OSFS
from lxml import etree
from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey, UsageKey
from opaque_keys.edx.locations import AssetLocation, CourseLocator
from path import Path as path
from openedx.core.lib.tempdir import mkdtemp_clean
from common.test.utils import XssTestMixin from common.test.utils import XssTestMixin
from contentstore.tests.utils import parse_json, AjaxEnabledTestClient, CourseTestCase from contentstore.tests.utils import AjaxEnabledTestClient, CourseTestCase, get_url, parse_json
from contentstore.utils import delete_course_and_groups, reverse_course_url, reverse_url
from contentstore.views.component import ADVANCED_COMPONENT_TYPES from contentstore.views.component import ADVANCED_COMPONENT_TYPES
from course_action_state.managers import CourseActionStateItemNotFoundError
from edxval.api import create_video, get_videos_for_course from course_action_state.models import CourseRerunState, CourseRerunUIStateManager
from django_comment_common.utils import are_permissions_roles_seeded
from openedx.core.lib.tempdir import mkdtemp_clean
from student import auth
from student.models import CourseEnrollment
from student.roles import CourseCreatorRole, CourseInstructorRole
from xmodule.capa_module import CapaDescriptor
from xmodule.contentstore.content import StaticContent
from xmodule.contentstore.django import contentstore from xmodule.contentstore.django import contentstore
from xmodule.contentstore.utils import restore_asset_from_trashcan, empty_asset_trashcan from xmodule.contentstore.utils import empty_asset_trashcan, restore_asset_from_trashcan
from xmodule.course_module import CourseDescriptor, Textbook
from xmodule.exceptions import InvalidVersionError from xmodule.exceptions import InvalidVersionError
from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.exceptions import ItemNotFoundError from xmodule.modulestore.exceptions import ItemNotFoundError
from xmodule.modulestore.inheritance import own_metadata from xmodule.modulestore.inheritance import own_metadata
from opaque_keys.edx.keys import UsageKey, CourseKey
from opaque_keys.edx.locations import AssetLocation, CourseLocator
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory, LibraryFactory, check_mongo_calls from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory, LibraryFactory, check_mongo_calls
from xmodule.modulestore.xml_exporter import export_course_to_xml from xmodule.modulestore.xml_exporter import export_course_to_xml
from xmodule.modulestore.xml_importer import import_course_from_xml, perform_xlint from xmodule.modulestore.xml_importer import import_course_from_xml, perform_xlint
from xmodule.capa_module import CapaDescriptor
from xmodule.course_module import CourseDescriptor, Textbook
from xmodule.seq_module import SequenceDescriptor from xmodule.seq_module import SequenceDescriptor
from contentstore.utils import delete_course_and_groups, reverse_url, reverse_course_url
from django_comment_common.utils import are_permissions_roles_seeded
from student import auth
from student.models import CourseEnrollment
from student.roles import CourseCreatorRole, CourseInstructorRole
from opaque_keys import InvalidKeyError
from contentstore.tests.utils import get_url
from course_action_state.models import CourseRerunState, CourseRerunUIStateManager
from course_action_state.managers import CourseActionStateItemNotFoundError
from xmodule.contentstore.content import StaticContent
from xmodule.modulestore.django import modulestore
TEST_DATA_CONTENTSTORE = copy.deepcopy(settings.CONTENTSTORE) TEST_DATA_CONTENTSTORE = copy.deepcopy(settings.CONTENTSTORE)
TEST_DATA_CONTENTSTORE['DOC_STORE_CONFIG']['db'] = 'test_xcontent_%s' % uuid4().hex TEST_DATA_CONTENTSTORE['DOC_STORE_CONFIG']['db'] = 'test_xcontent_%s' % uuid4().hex
......
...@@ -3,9 +3,9 @@ Tests core caching facilities. ...@@ -3,9 +3,9 @@ Tests core caching facilities.
""" """
from django.test import TestCase from django.test import TestCase
from opaque_keys.edx.locations import Location from opaque_keys.edx.locations import Location
from openedx.core.djangoapps.contentserver.caching import get_cached_content, set_cached_content, del_cached_content
from openedx.core.djangoapps.contentserver.caching import del_cached_content, get_cached_content, set_cached_content
class Content(object): class Content(object):
......
""" """
Test view handler for rerun (and eventually create) Test view handler for rerun (and eventually create)
""" """
import ddt from datetime import datetime
from mock import patch
from django.test.client import RequestFactory import ddt
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.test.client import RequestFactory
from mock import patch
from opaque_keys.edx.keys import CourseKey from opaque_keys.edx.keys import CourseKey
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from contentstore.tests.utils import AjaxEnabledTestClient, parse_json
from xmodule.modulestore.tests.factories import CourseFactory
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore
from student.roles import CourseInstructorRole, CourseStaffRole from student.roles import CourseInstructorRole, CourseStaffRole
from student.tests.factories import UserFactory from student.tests.factories import UserFactory
from contentstore.tests.utils import AjaxEnabledTestClient, parse_json from util.organizations_helpers import add_organization, get_course_organizations
from datetime import datetime
from xmodule.course_module import CourseFields from xmodule.course_module import CourseFields
from util.organizations_helpers import ( from xmodule.modulestore import ModuleStoreEnum
add_organization, from xmodule.modulestore.django import modulestore
get_course_organizations, from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
) from xmodule.modulestore.tests.factories import CourseFactory
@ddt.ddt @ddt.ddt
......
...@@ -4,43 +4,40 @@ by reversing group name formats. ...@@ -4,43 +4,40 @@ by reversing group name formats.
""" """
import random import random
from chrono import Timer
from mock import patch, Mock
import ddt import ddt
from django.conf import settings
from ccx_keys.locator import CCXLocator from ccx_keys.locator import CCXLocator
from chrono import Timer
from django.conf import settings
from django.test import RequestFactory from django.test import RequestFactory
from django.test.client import Client from django.test.client import Client
from mock import Mock, patch
from opaque_keys.edx.locations import CourseLocator
from common.test.utils import XssTestMixin from common.test.utils import XssTestMixin
from xmodule.course_module import CourseSummary from contentstore.tests.utils import AjaxEnabledTestClient
from contentstore.utils import delete_course_and_groups
from contentstore.views.course import ( from contentstore.views.course import (
AccessListFallback,
_accessible_courses_iter, _accessible_courses_iter,
_accessible_courses_list_from_groups, _accessible_courses_list_from_groups,
AccessListFallback,
get_courses_accessible_to_user,
_accessible_courses_summary_iter, _accessible_courses_summary_iter,
get_courses_accessible_to_user
) )
from contentstore.utils import delete_course_and_groups from course_action_state.models import CourseRerunState
from contentstore.tests.utils import AjaxEnabledTestClient
from student.tests.factories import UserFactory
from student.roles import ( from student.roles import (
CourseInstructorRole, CourseInstructorRole,
CourseStaffRole, CourseStaffRole,
GlobalStaff, GlobalStaff,
OrgStaffRole,
OrgInstructorRole, OrgInstructorRole,
UserBasedRole, OrgStaffRole,
UserBasedRole
) )
from student.tests.factories import UserFactory
from xmodule.course_module import CourseSummary
from xmodule.error_module import ErrorDescriptor
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory, check_mongo_calls from xmodule.modulestore.tests.factories import CourseFactory, check_mongo_calls
from xmodule.modulestore import ModuleStoreEnum
from opaque_keys.edx.locations import CourseLocator
from xmodule.error_module import ErrorDescriptor
from course_action_state.models import CourseRerunState
TOTAL_COURSES_COUNT = 10 TOTAL_COURSES_COUNT = 10
USER_COURSES_COUNT = 1 USER_COURSES_COUNT = 1
......
""" """
Tests for Studio Course Settings. Tests for Studio Course Settings.
""" """
import copy
import datetime import datetime
import ddt
import json import json
import copy
import mock
from mock import Mock, patch
import unittest import unittest
import ddt
import mock
from django.conf import settings from django.conf import settings
from django.utils.timezone import UTC
from django.test.utils import override_settings from django.test.utils import override_settings
from django.utils.timezone import UTC
from milestones.tests.utils import MilestonesTestCaseMixin
from mock import Mock, patch
from contentstore.utils import reverse_course_url, reverse_usage_url from contentstore.utils import reverse_course_url, reverse_usage_url
from models.settings.course_grading import CourseGradingModel from models.settings.course_grading import CourseGradingModel
from models.settings.course_metadata import CourseMetadata from models.settings.course_metadata import CourseMetadata
from models.settings.encoder import CourseSettingsEncoder from models.settings.encoder import CourseSettingsEncoder
from openedx.core.djangoapps.self_paced.models import SelfPacedConfiguration
from openedx.core.djangoapps.models.course_details import CourseDetails from openedx.core.djangoapps.models.course_details import CourseDetails
from openedx.core.djangoapps.self_paced.models import SelfPacedConfiguration
from student.roles import CourseInstructorRole, CourseStaffRole from student.roles import CourseInstructorRole, CourseStaffRole
from student.tests.factories import UserFactory from student.tests.factories import UserFactory
from xblock_django.models import XBlockStudioConfigurationFlag from xblock_django.models import XBlockStudioConfigurationFlag
...@@ -27,9 +28,8 @@ from xmodule.modulestore import ModuleStoreEnum ...@@ -27,9 +28,8 @@ from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from xmodule.modulestore.tests.factories import CourseFactory from xmodule.modulestore.tests.factories import CourseFactory
from xmodule.tabs import InvalidTabsException from xmodule.tabs import InvalidTabsException
from milestones.tests.utils import MilestonesTestCaseMixin
from .utils import CourseTestCase, AjaxEnabledTestClient from .utils import AjaxEnabledTestClient, CourseTestCase
def get_url(course_id, handler_name='settings_handler'): def get_url(course_id, handler_name='settings_handler'):
......
""" """
Testing indexing of the courseware as it is changed Testing indexing of the courseware as it is changed
""" """
import ddt
import json import json
from lazy.lazy import lazy
import time import time
from datetime import datetime from datetime import datetime
from dateutil.tz import tzutc
from mock import patch
from pytz import UTC
from uuid import uuid4
from unittest import skip from unittest import skip
from uuid import uuid4
import ddt
from dateutil.tz import tzutc
from django.conf import settings from django.conf import settings
from lazy.lazy import lazy
from mock import patch
from pytz import UTC
from search.search_engine_base import SearchEngine
from contentstore.courseware_index import (
CourseAboutSearchIndexer,
CoursewareSearchIndexer,
LibrarySearchIndexer,
SearchIndexingError
)
from contentstore.signals.handlers import listen_for_course_publish, listen_for_library_update
from contentstore.tests.utils import CourseTestCase
from contentstore.utils import reverse_course_url, reverse_usage_url
from course_modes.models import CourseMode from course_modes.models import CourseMode
from openedx.core.djangoapps.models.course_details import CourseDetails from openedx.core.djangoapps.models.course_details import CourseDetails
from xmodule.library_tools import normalize_key_for_search from xmodule.library_tools import normalize_key_for_search
...@@ -25,28 +35,19 @@ from xmodule.modulestore.mixed import MixedModuleStore ...@@ -25,28 +35,19 @@ from xmodule.modulestore.mixed import MixedModuleStore
from xmodule.modulestore.tests.django_utils import ( from xmodule.modulestore.tests.django_utils import (
TEST_DATA_MONGO_MODULESTORE, TEST_DATA_MONGO_MODULESTORE,
TEST_DATA_SPLIT_MODULESTORE, TEST_DATA_SPLIT_MODULESTORE,
SharedModuleStoreTestCase) SharedModuleStoreTestCase
)
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory, LibraryFactory from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory, LibraryFactory
from xmodule.modulestore.tests.mongo_connection import MONGO_PORT_NUM, MONGO_HOST from xmodule.modulestore.tests.mongo_connection import MONGO_HOST, MONGO_PORT_NUM
from xmodule.modulestore.tests.utils import ( from xmodule.modulestore.tests.utils import (
create_modulestore_instance, LocationMixin, LocationMixin,
MixedSplitTestCase, MongoContentstoreBuilder MixedSplitTestCase,
MongoContentstoreBuilder,
create_modulestore_instance
) )
from xmodule.partitions.partitions import UserPartition
from xmodule.tests import DATA_DIR from xmodule.tests import DATA_DIR
from xmodule.x_module import XModuleMixin from xmodule.x_module import XModuleMixin
from xmodule.partitions.partitions import UserPartition
from search.search_engine_base import SearchEngine
from contentstore.courseware_index import (
CoursewareSearchIndexer,
LibrarySearchIndexer,
SearchIndexingError,
CourseAboutSearchIndexer,
)
from contentstore.signals.handlers import listen_for_course_publish, listen_for_library_update
from contentstore.utils import reverse_course_url, reverse_usage_url
from contentstore.tests.utils import CourseTestCase
COURSE_CHILD_STRUCTURE = { COURSE_CHILD_STRUCTURE = {
"course": "chapter", "course": "chapter",
......
from xmodule import templates from xmodule import templates
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase, TEST_DATA_SPLIT_MODULESTORE
from xmodule.course_module import CourseDescriptor
from xmodule.seq_module import SequenceDescriptor
from xmodule.capa_module import CapaDescriptor from xmodule.capa_module import CapaDescriptor
from xmodule.course_module import CourseDescriptor
from xmodule.html_module import HtmlDescriptor from xmodule.html_module import HtmlDescriptor
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.exceptions import DuplicateCourseError from xmodule.modulestore.exceptions import DuplicateCourseError
from xmodule.modulestore.tests.django_utils import TEST_DATA_SPLIT_MODULESTORE, ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
from xmodule.seq_module import SequenceDescriptor
class TemplateTests(ModuleStoreTestCase): class TemplateTests(ModuleStoreTestCase):
......
...@@ -11,10 +11,11 @@ from uuid import uuid4 ...@@ -11,10 +11,11 @@ from uuid import uuid4
from django.conf import settings from django.conf import settings
from django.test.utils import override_settings from django.test.utils import override_settings
from .utils import CourseTestCase
import contentstore.git_export_utils as git_export_utils import contentstore.git_export_utils as git_export_utils
from xmodule.modulestore.django import modulestore
from contentstore.utils import reverse_course_url from contentstore.utils import reverse_course_url
from xmodule.modulestore.django import modulestore
from .utils import CourseTestCase
TEST_DATA_CONTENTSTORE = copy.deepcopy(settings.CONTENTSTORE) TEST_DATA_CONTENTSTORE = copy.deepcopy(settings.CONTENTSTORE)
TEST_DATA_CONTENTSTORE['DOC_STORE_CONFIG']['db'] = 'test_xcontent_%s' % uuid4().hex TEST_DATA_CONTENTSTORE['DOC_STORE_CONFIG']['db'] = 'test_xcontent_%s' % uuid4().hex
......
""" """
Unit tests for the gating feature in Studio Unit tests for the gating feature in Studio
""" """
from contentstore.signals.handlers import handle_item_deleted
from milestones.tests.utils import MilestonesTestCaseMixin from milestones.tests.utils import MilestonesTestCaseMixin
from mock import patch from mock import patch
from contentstore.signals.handlers import handle_item_deleted
from openedx.core.lib.gating import api as gating_api from openedx.core.lib.gating import api as gating_api
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import ItemFactory, CourseFactory from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
class TestHandleItemDeleted(ModuleStoreTestCase, MilestonesTestCaseMixin): class TestHandleItemDeleted(ModuleStoreTestCase, MilestonesTestCaseMixin):
......
""" """
Tests for validate Internationalization and Module i18n service. Tests for validate Internationalization and Module i18n service.
""" """
import mock
import gettext import gettext
from unittest import skip from unittest import skip
import mock
from django.contrib.auth.models import User from django.contrib.auth.models import User
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from contentstore.tests.utils import AjaxEnabledTestClient
from xmodule.modulestore.django import ModuleI18nService
from django.utils import translation from django.utils import translation
from django.utils.translation import get_language from django.utils.translation import get_language
from xmodule.modulestore.tests.factories import ItemFactory, CourseFactory
from contentstore.tests.utils import AjaxEnabledTestClient
from contentstore.views.preview import _preview_module_system from contentstore.views.preview import _preview_module_system
from xmodule.modulestore.django import ModuleI18nService
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
class FakeTranslations(ModuleI18nService): class FakeTranslations(ModuleI18nService):
......
...@@ -4,22 +4,23 @@ ...@@ -4,22 +4,23 @@
Tests for import_course_from_xml using the mongo modulestore. Tests for import_course_from_xml using the mongo modulestore.
""" """
import copy
from uuid import uuid4
import ddt
from django.conf import settings
from django.test.client import Client from django.test.client import Client
from django.test.utils import override_settings from django.test.utils import override_settings
from django.conf import settings
import ddt
import copy
from mock import patch from mock import patch
from openedx.core.djangoapps.content.course_structures.tests import SignalDisconnectTestMixin from openedx.core.djangoapps.content.course_structures.tests import SignalDisconnectTestMixin
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.contentstore.django import contentstore
from xmodule.exceptions import NotFoundError
from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from xmodule.contentstore.django import contentstore from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import check_exact_number_of_calls, check_number_of_calls from xmodule.modulestore.tests.factories import check_exact_number_of_calls, check_number_of_calls
from xmodule.modulestore.xml_importer import import_course_from_xml from xmodule.modulestore.xml_importer import import_course_from_xml
from xmodule.exceptions import NotFoundError
from uuid import uuid4
TEST_DATA_CONTENTSTORE = copy.deepcopy(settings.CONTENTSTORE) TEST_DATA_CONTENTSTORE = copy.deepcopy(settings.CONTENTSTORE)
TEST_DATA_CONTENTSTORE['DOC_STORE_CONFIG']['db'] = 'test_xcontent_%s' % uuid4().hex TEST_DATA_CONTENTSTORE['DOC_STORE_CONFIG']['db'] = 'test_xcontent_%s' % uuid4().hex
......
""" """
Tests Draft import order. Tests Draft import order.
""" """
from xmodule.modulestore.xml_importer import import_course_from_xml from django.conf import settings
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from django.conf import settings from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.xml_importer import import_course_from_xml
TEST_DATA_DIR = settings.COMMON_TEST_DATA_ROOT TEST_DATA_DIR = settings.COMMON_TEST_DATA_ROOT
......
...@@ -2,15 +2,15 @@ ...@@ -2,15 +2,15 @@
Integration tests for importing courses containing pure XBlocks. Integration tests for importing courses containing pure XBlocks.
""" """
from django.conf import settings
from xblock.core import XBlock from xblock.core import XBlock
from xblock.fields import String from xblock.fields import String
from xmodule.modulestore.django import modulestore
from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.xml_importer import import_course_from_xml from xmodule.modulestore.django import modulestore
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.mongo.draft import as_draft from xmodule.modulestore.mongo.draft import as_draft
from django.conf import settings from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.xml_importer import import_course_from_xml
TEST_DATA_DIR = settings.COMMON_TEST_DATA_ROOT TEST_DATA_DIR = settings.COMMON_TEST_DATA_ROOT
......
""" """
Content library unit tests that require the CMS runtime. Content library unit tests that require the CMS runtime.
""" """
import ddt
from django.test.utils import override_settings from django.test.utils import override_settings
from mock import Mock, patch
from opaque_keys.edx.locator import CourseKey, LibraryLocator
from contentstore.tests.utils import AjaxEnabledTestClient, parse_json from contentstore.tests.utils import AjaxEnabledTestClient, parse_json
from contentstore.utils import reverse_url, reverse_usage_url, reverse_library_url from contentstore.utils import reverse_library_url, reverse_url, reverse_usage_url
from contentstore.views.item import _duplicate_item from contentstore.views.item import _duplicate_item
from contentstore.views.preview import _load_preview_module from contentstore.views.preview import _load_preview_module
from contentstore.views.tests.test_library import LIBRARY_REST_URL from contentstore.views.tests.test_library import LIBRARY_REST_URL
import ddt from course_creators.views import add_user_with_status_granted
from mock import patch from openedx.core.djangoapps.content.course_structures.tests import SignalDisconnectTestMixin
from student import auth
from student.auth import has_studio_read_access, has_studio_write_access from student.auth import has_studio_read_access, has_studio_write_access
from student.roles import ( from student.roles import (
CourseInstructorRole, CourseStaffRole, LibraryUserRole, CourseInstructorRole,
OrgStaffRole, OrgInstructorRole, OrgLibraryUserRole, CourseStaffRole,
LibraryUserRole,
OrgInstructorRole,
OrgLibraryUserRole,
OrgStaffRole
) )
from student.tests.factories import UserFactory
from xblock_django.user_service import DjangoXBlockUserService
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, ItemFactory from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
from mock import Mock
from opaque_keys.edx.locator import CourseKey, LibraryLocator
from openedx.core.djangoapps.content.course_structures.tests import SignalDisconnectTestMixin
from xblock_django.user_service import DjangoXBlockUserService
from xmodule.x_module import STUDIO_VIEW from xmodule.x_module import STUDIO_VIEW
from student import auth
from student.tests.factories import UserFactory
from course_creators.views import add_user_with_status_granted
class LibraryTestCase(ModuleStoreTestCase): class LibraryTestCase(ModuleStoreTestCase):
......
...@@ -2,11 +2,12 @@ ...@@ -2,11 +2,12 @@
Test finding orphans via the view and django config Test finding orphans via the view and django config
""" """
import json import json
import ddt import ddt
from opaque_keys.edx.locator import BlockUsageLocator
from contentstore.tests.utils import CourseTestCase from contentstore.tests.utils import CourseTestCase
from contentstore.utils import reverse_course_url from contentstore.utils import reverse_course_url
from opaque_keys.edx.locator import BlockUsageLocator
from student.models import CourseEnrollment from student.models import CourseEnrollment
from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.search import path_to_location from xmodule.modulestore.search import path_to_location
......
...@@ -5,11 +5,11 @@ import copy ...@@ -5,11 +5,11 @@ import copy
from django.contrib.auth.models import User from django.contrib.auth.models import User
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from contentstore.tests.utils import AjaxEnabledTestClient from contentstore.tests.utils import AjaxEnabledTestClient
from contentstore.utils import reverse_url, reverse_course_url from contentstore.utils import reverse_course_url, reverse_url
from student.roles import CourseInstructorRole, CourseStaffRole, OrgStaffRole, OrgInstructorRole
from student import auth from student import auth
from student.roles import CourseInstructorRole, CourseStaffRole, OrgInstructorRole, OrgStaffRole
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
class TestCourseAccess(ModuleStoreTestCase): class TestCourseAccess(ModuleStoreTestCase):
......
...@@ -2,19 +2,16 @@ ...@@ -2,19 +2,16 @@
Tests for the edx_proctoring integration into Studio Tests for the edx_proctoring integration into Studio
""" """
from mock import patch
import ddt
from datetime import datetime, timedelta from datetime import datetime, timedelta
import ddt
from edx_proctoring.api import get_all_exams_for_course, get_review_policy_by_exam_id
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, ItemFactory
from contentstore.signals.handlers import listen_for_course_publish from contentstore.signals.handlers import listen_for_course_publish
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from edx_proctoring.api import ( from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
get_all_exams_for_course,
get_review_policy_by_exam_id
)
@ddt.ddt @ddt.ddt
......
"""Tests for CMS's requests to logs""" """Tests for CMS's requests to logs"""
import mock import mock
from django.test import TestCase
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.test import TestCase
from contentstore.views.helpers import event as cms_user_track from contentstore.views.helpers import event as cms_user_track
......
...@@ -15,13 +15,13 @@ from opaque_keys.edx.locator import CourseLocator ...@@ -15,13 +15,13 @@ from opaque_keys.edx.locator import CourseLocator
from organizations.models import OrganizationCourse from organizations.models import OrganizationCourse
from organizations.tests.factories import OrganizationFactory from organizations.tests.factories import OrganizationFactory
from user_tasks.models import UserTaskArtifact, UserTaskStatus from user_tasks.models import UserTaskArtifact, UserTaskStatus
from xmodule.modulestore.django import modulestore
from contentstore.tasks import export_olx, rerun_course from contentstore.tasks import export_olx, rerun_course
from contentstore.tests.test_libraries import LibraryTestCase from contentstore.tests.test_libraries import LibraryTestCase
from contentstore.tests.utils import CourseTestCase from contentstore.tests.utils import CourseTestCase
from course_action_state.models import CourseRerunState from course_action_state.models import CourseRerunState
from openedx.core.djangoapps.embargo.models import RestrictedCourse, CountryAccessRule, Country from openedx.core.djangoapps.embargo.models import Country, CountryAccessRule, RestrictedCourse
from xmodule.modulestore.django import modulestore
TEST_DATA_CONTENTSTORE = copy.deepcopy(settings.CONTENTSTORE) TEST_DATA_CONTENTSTORE = copy.deepcopy(settings.CONTENTSTORE)
TEST_DATA_CONTENTSTORE['DOC_STORE_CONFIG']['db'] = 'test_xcontent_%s' % uuid4().hex TEST_DATA_CONTENTSTORE['DOC_STORE_CONFIG']['db'] = 'test_xcontent_%s' % uuid4().hex
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" Tests for transcripts_utils. """ """ Tests for transcripts_utils. """
import unittest
from uuid import uuid4
import copy import copy
import textwrap import textwrap
from mock import patch, Mock import unittest
from uuid import uuid4
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 django.utils import translation from django.utils import translation
from mock import Mock, patch
from nose.plugins.skip import SkipTest from nose.plugins.skip import SkipTest
from xmodule.modulestore.tests.factories import CourseFactory from contentstore.tests.utils import mock_requests_get
from xmodule.contentstore.content import StaticContent from xmodule.contentstore.content import StaticContent
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.exceptions import NotFoundError
from xmodule.contentstore.django import contentstore from xmodule.contentstore.django import contentstore
from xmodule.exceptions import NotFoundError
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
from xmodule.video_module import transcripts_utils from xmodule.video_module import transcripts_utils
from contentstore.tests.utils import mock_requests_get
TEST_DATA_CONTENTSTORE = copy.deepcopy(settings.CONTENTSTORE) TEST_DATA_CONTENTSTORE = copy.deepcopy(settings.CONTENTSTORE)
TEST_DATA_CONTENTSTORE['DOC_STORE_CONFIG']['db'] = 'test_xcontent_%s' % uuid4().hex TEST_DATA_CONTENTSTORE['DOC_STORE_CONFIG']['db'] = 'test_xcontent_%s' % uuid4().hex
......
...@@ -5,9 +5,8 @@ after deleting it creates same course again ...@@ -5,9 +5,8 @@ after deleting it creates same course again
from contentstore.tests.utils import AjaxEnabledTestClient from contentstore.tests.utils import AjaxEnabledTestClient
from contentstore.utils import delete_course_and_groups, reverse_url from contentstore.utils import delete_course_and_groups, reverse_url
from courseware.tests.factories import UserFactory from courseware.tests.factories import UserFactory
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from student.models import CourseEnrollment from student.models import CourseEnrollment
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
class TestUsersDefaultRole(ModuleStoreTestCase): class TestUsersDefaultRole(ModuleStoreTestCase):
......
...@@ -2,19 +2,18 @@ ...@@ -2,19 +2,18 @@
import collections import collections
from datetime import datetime, timedelta from datetime import datetime, timedelta
from pytz import UTC
from django.test import TestCase from django.test import TestCase
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase, SharedModuleStoreTestCase
from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys.edx.locations import SlashSeparatedCourseKey
from xmodule.modulestore.django import modulestore from pytz import UTC
from xmodule.partitions.partitions import UserPartition, Group
from openedx.core.djangoapps.site_configuration.tests.test_util import with_site_configuration_context
from contentstore import utils from contentstore import utils
from contentstore.tests.utils import CourseTestCase from contentstore.tests.utils import CourseTestCase
from openedx.core.djangoapps.site_configuration.tests.test_util import with_site_configuration_context
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase, SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
from xmodule.partitions.partitions import Group, UserPartition
class LMSLinksTestCase(TestCase): class LMSLinksTestCase(TestCase):
......
""" """
This test file will test registration, login, activation, and session activity timeouts This test file will test registration, login, activation, and session activity timeouts
""" """
import datetime
import time import time
import mock
import unittest import unittest
from ddt import ddt, data, unpack
from django.test import TestCase import mock
from django.test.utils import override_settings from ddt import data, ddt, unpack
from django.core.cache import cache
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.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.test import TestCase
from django.test.utils import override_settings
from freezegun import freeze_time
from pytz import UTC
from contentstore.models import PushNotificationConfig from contentstore.models import PushNotificationConfig
from contentstore.tests.test_course_settings import CourseTestCase from contentstore.tests.test_course_settings import CourseTestCase
from contentstore.tests.utils import parse_json, user, registration, AjaxEnabledTestClient from contentstore.tests.utils import AjaxEnabledTestClient, parse_json, registration, user
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
import datetime
from pytz import UTC
from freezegun import freeze_time
class ContentStoreTestCase(ModuleStoreTestCase): class ContentStoreTestCase(ModuleStoreTestCase):
......
...@@ -3,23 +3,23 @@ Utilities for contentstore tests ...@@ -3,23 +3,23 @@ Utilities for contentstore tests
''' '''
import json import json
import textwrap import textwrap
from mock import Mock
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.test.client import Client from django.test.client import Client
from opaque_keys.edx.locations import SlashSeparatedCourseKey, AssetLocation from mock import Mock
from opaque_keys.edx.locations import AssetLocation, SlashSeparatedCourseKey
from contentstore.utils import reverse_url from contentstore.utils import reverse_url
from student.models import Registration from student.models import Registration
from xmodule.modulestore.split_mongo.split import SplitMongoModuleStore
from xmodule.contentstore.django import contentstore from xmodule.contentstore.django import contentstore
from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.inheritance import own_metadata from xmodule.modulestore.inheritance import own_metadata
from xmodule.modulestore.split_mongo.split import SplitMongoModuleStore
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 xmodule.modulestore.xml_importer import import_course_from_xml
from xmodule.modulestore.tests.utils import ProceduralCourseTestMixin from xmodule.modulestore.tests.utils import ProceduralCourseTestMixin
from xmodule.modulestore.xml_importer import import_course_from_xml
TEST_DATA_DIR = settings.COMMON_TEST_DATA_ROOT TEST_DATA_DIR = settings.COMMON_TEST_DATA_ROOT
......
...@@ -4,26 +4,24 @@ Common utility functions useful throughout the contentstore ...@@ -4,26 +4,24 @@ Common utility functions useful throughout the contentstore
import logging import logging
from datetime import datetime from datetime import datetime
from pytz import UTC
from django.conf import settings from django.conf import settings
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from opaque_keys.edx.keys import CourseKey, UsageKey
from pytz import UTC
from django_comment_common.models import assign_default_role from django_comment_common.models import assign_default_role
from django_comment_common.utils import seed_permissions_roles from django_comment_common.utils import seed_permissions_roles
from openedx.core.djangoapps.self_paced.models import SelfPacedConfiguration from openedx.core.djangoapps.self_paced.models import SelfPacedConfiguration
from openedx.core.djangoapps.site_configuration.models import SiteConfiguration from openedx.core.djangoapps.site_configuration.models import SiteConfiguration
from xmodule.partitions.partitions_service import get_all_partitions_for_course from student import auth
from student.models import CourseEnrollment
from student.roles import CourseInstructorRole, CourseStaffRole
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.exceptions import ItemNotFoundError from xmodule.modulestore.exceptions import ItemNotFoundError
from opaque_keys.edx.keys import UsageKey, CourseKey from xmodule.partitions.partitions_service import get_all_partitions_for_course
from student.roles import CourseInstructorRole, CourseStaffRole
from student.models import CourseEnrollment
from student import auth
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
......
""" Helper methods for determining user access permissions in Studio """ """ Helper methods for determining user access permissions in Studio """
from student.roles import CourseInstructorRole
from student import auth from student import auth
from student.roles import CourseInstructorRole
def get_user_role(user, course_id): def get_user_role(user, course_id):
......
import json
import logging import logging
from functools import partial
import math import math
import json from functools import partial
from pymongo import ASCENDING, DESCENDING
from django.conf import settings from django.conf import settings
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
...@@ -11,11 +10,12 @@ from django.http import HttpResponseBadRequest, HttpResponseNotFound ...@@ -11,11 +10,12 @@ from django.http import HttpResponseBadRequest, HttpResponseNotFound
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.views.decorators.csrf import ensure_csrf_cookie from django.views.decorators.csrf import ensure_csrf_cookie
from django.views.decorators.http import require_http_methods, require_POST from django.views.decorators.http import require_http_methods, require_POST
from opaque_keys.edx.keys import AssetKey, CourseKey
from pymongo import ASCENDING, DESCENDING
from edxmako.shortcuts import render_to_response
from contentstore.utils import reverse_course_url from contentstore.utils import reverse_course_url
from contentstore.views.exception import AssetNotFoundException from contentstore.views.exception import AssetNotFoundException
from opaque_keys.edx.keys import CourseKey, AssetKey from edxmako.shortcuts import render_to_response
from openedx.core.djangoapps.contentserver.caching import del_cached_content from openedx.core.djangoapps.contentserver.caching import del_cached_content
from student.auth import has_course_author_access from student.auth import has_course_author_access
from util.date_utils import get_default_time_display from util.date_utils import get_default_time_display
......
...@@ -26,27 +26,26 @@ import logging ...@@ -26,27 +26,26 @@ import logging
from django.conf import settings from django.conf import settings
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.views.decorators.csrf import ensure_csrf_cookie from django.core.exceptions import PermissionDenied
from django.http import HttpResponse from django.http import HttpResponse
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.views.decorators.csrf import ensure_csrf_cookie
from django.views.decorators.http import require_http_methods from django.views.decorators.http import require_http_methods
from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import AssetKey, CourseKey
from contentstore.utils import reverse_course_url from contentstore.utils import get_lms_link_for_certificate_web_view, reverse_course_url
from contentstore.views.assets import delete_asset
from contentstore.views.exception import AssetNotFoundException
from course_modes.models import CourseMode
from edxmako.shortcuts import render_to_response from edxmako.shortcuts import render_to_response
from opaque_keys.edx.keys import CourseKey, AssetKey
from opaque_keys import InvalidKeyError
from eventtracking import tracker from eventtracking import tracker
from student.auth import has_studio_write_access from student.auth import has_studio_write_access
from student.roles import GlobalStaff from student.roles import GlobalStaff
from util.db import generate_int_id, MYSQL_MAX_INT from util.db import MYSQL_MAX_INT, generate_int_id
from util.json_request import JsonResponse from util.json_request import JsonResponse
from xmodule.modulestore import EdxJSONEncoder from xmodule.modulestore import EdxJSONEncoder
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from contentstore.views.assets import delete_asset
from contentstore.views.exception import AssetNotFoundException
from django.core.exceptions import PermissionDenied
from course_modes.models import CourseMode
from contentstore.utils import get_lms_link_for_certificate_web_view
CERTIFICATE_SCHEMA_VERSION = 1 CERTIFICATE_SCHEMA_VERSION = 1
CERTIFICATE_MINIMUM_ID = 100 CERTIFICATE_MINIMUM_ID = 100
......
...@@ -2,36 +2,30 @@ from __future__ import absolute_import ...@@ -2,36 +2,30 @@ from __future__ import absolute_import
import logging import logging
from django.http import HttpResponseBadRequest, Http404 from django.conf import settings
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.views.decorators.http import require_GET
from django.core.exceptions import PermissionDenied from django.core.exceptions import PermissionDenied
from django.conf import settings from django.http import Http404, HttpResponseBadRequest
from django.utils.translation import ugettext as _
from django.views.decorators.http import require_GET
from opaque_keys import InvalidKeyError from opaque_keys import InvalidKeyError
from opaque_keys.edx.asides import AsideUsageKeyV1, AsideUsageKeyV2 from opaque_keys.edx.asides import AsideUsageKeyV1, AsideUsageKeyV2
from xmodule.modulestore.exceptions import ItemNotFoundError from opaque_keys.edx.keys import UsageKey
from edxmako.shortcuts import render_to_response
from xmodule.modulestore.django import modulestore
from xblock.core import XBlock from xblock.core import XBlock
from xblock.django.request import webob_to_django_response, django_to_webob_request from xblock.django.request import django_to_webob_request, webob_to_django_response
from xblock.exceptions import NoSuchHandlerError from xblock.exceptions import NoSuchHandlerError
from xblock.plugin import PluginMissingError from xblock.plugin import PluginMissingError
from xblock.runtime import Mixologist from xblock.runtime import Mixologist
from contentstore.utils import get_lms_link_for_item, reverse_course_url, get_xblock_aside_instance from contentstore.utils import get_lms_link_for_item, get_xblock_aside_instance, reverse_course_url
from contentstore.views.helpers import get_parent_xblock, is_unit, xblock_type_display_name from contentstore.views.helpers import get_parent_xblock, is_unit, xblock_type_display_name
from contentstore.views.item import create_xblock_info, add_container_page_publishing_info, StudioEditModuleRuntime from contentstore.views.item import StudioEditModuleRuntime, add_container_page_publishing_info, create_xblock_info
from edxmako.shortcuts import render_to_response
from opaque_keys.edx.keys import UsageKey
from student.auth import has_course_author_access from student.auth import has_course_author_access
from django.utils.translation import ugettext as _ from xblock_django.api import authorable_xblocks, disabled_xblocks
from xblock_django.api import disabled_xblocks, authorable_xblocks
from xblock_django.models import XBlockStudioConfigurationFlag from xblock_django.models import XBlockStudioConfigurationFlag
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.exceptions import ItemNotFoundError
__all__ = [ __all__ = [
'container_handler', 'container_handler',
......
...@@ -7,75 +7,63 @@ import logging ...@@ -7,75 +7,63 @@ import logging
import random import random
import string # pylint: disable=deprecated-module import string # pylint: disable=deprecated-module
import django.utils
import six
from ccx_keys.locator import CCXLocator
from django.conf import settings from django.conf import settings
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.core.exceptions import PermissionDenied from django.core.exceptions import PermissionDenied
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.http import HttpResponse, HttpResponseBadRequest, HttpResponseNotFound, Http404 from django.http import Http404, HttpResponse, HttpResponseBadRequest, HttpResponseNotFound
from django.shortcuts import redirect from django.shortcuts import redirect
import django.utils
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.views.decorators.http import require_http_methods, require_GET
from django.views.decorators.csrf import ensure_csrf_cookie from django.views.decorators.csrf import ensure_csrf_cookie
import six from django.views.decorators.http import require_GET, require_http_methods
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 opaque_keys.edx.locations import Location from opaque_keys.edx.locations import Location
from .component import (
ADVANCED_COMPONENT_TYPES,
)
from .item import create_xblock_info
from .library import LIBRARIES_ENABLED, get_library_creator_status
from ccx_keys.locator import CCXLocator
from contentstore.course_group_config import ( from contentstore.course_group_config import (
COHORT_SCHEME, COHORT_SCHEME,
ENROLLMENT_SCHEME, ENROLLMENT_SCHEME,
GroupConfiguration,
GroupConfigurationsValidationError,
RANDOM_SCHEME, RANDOM_SCHEME,
GroupConfiguration,
GroupConfigurationsValidationError
) )
from contentstore.course_info_model import get_course_updates, update_course_updates, delete_course_update from contentstore.course_info_model import delete_course_update, get_course_updates, update_course_updates
from contentstore.courseware_index import CoursewareSearchIndexer, SearchIndexingError from contentstore.courseware_index import CoursewareSearchIndexer, SearchIndexingError
from contentstore.push_notification import push_notification_enabled from contentstore.push_notification import push_notification_enabled
from contentstore.tasks import rerun_course from contentstore.tasks import rerun_course
from contentstore.utils import ( from contentstore.utils import (
add_instructor, add_instructor,
initialize_permissions,
get_lms_link_for_item, get_lms_link_for_item,
initialize_permissions,
remove_all_instructors, remove_all_instructors,
reverse_course_url, reverse_course_url,
reverse_library_url, reverse_library_url,
reverse_usage_url,
reverse_url, reverse_url,
reverse_usage_url
) )
from contentstore.views.entrance_exam import ( from contentstore.views.entrance_exam import create_entrance_exam, delete_entrance_exam, update_entrance_exam
create_entrance_exam,
delete_entrance_exam,
update_entrance_exam,
)
from course_action_state.managers import CourseActionStateItemNotFoundError from course_action_state.managers import CourseActionStateItemNotFoundError
from course_action_state.models import CourseRerunState, CourseRerunUIStateManager from course_action_state.models import CourseRerunState, CourseRerunUIStateManager
from course_creators.views import get_course_creator_status, add_user_with_status_unrequested from course_creators.views import add_user_with_status_unrequested, get_course_creator_status
from edxmako.shortcuts import render_to_response from edxmako.shortcuts import render_to_response
from models.settings.course_grading import CourseGradingModel from models.settings.course_grading import CourseGradingModel
from models.settings.course_metadata import CourseMetadata from models.settings.course_metadata import CourseMetadata
from models.settings.encoder import CourseSettingsEncoder from models.settings.encoder import CourseSettingsEncoder
from openedx.core.djangoapps.content.course_structures.api.v0 import api, errors from openedx.core.djangoapps.content.course_structures.api.v0 import api, errors
from openedx.core.djangoapps.credit.api import is_credit_course, get_credit_requirements from openedx.core.djangoapps.credit.api import get_credit_requirements, is_credit_course
from openedx.core.djangoapps.credit.tasks import update_credit_course_requirements from openedx.core.djangoapps.credit.tasks import update_credit_course_requirements
from openedx.core.djangoapps.models.course_details import CourseDetails from openedx.core.djangoapps.models.course_details import CourseDetails
from openedx.core.djangoapps.self_paced.models import SelfPacedConfiguration from openedx.core.djangoapps.self_paced.models import SelfPacedConfiguration
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.djangolib.js_utils import dump_js_escaped_json
from openedx.core.lib.course_tabs import CourseTabPluginManager from openedx.core.lib.course_tabs import CourseTabPluginManager
from openedx.core.lib.courses import course_image_url from openedx.core.lib.courses import course_image_url
from openedx.core.djangolib.js_utils import dump_js_escaped_json
from student import auth from student import auth
from student.auth import has_course_author_access, has_studio_write_access, has_studio_read_access from student.auth import has_course_author_access, has_studio_read_access, has_studio_write_access
from student.roles import ( from student.roles import CourseCreatorRole, CourseInstructorRole, CourseStaffRole, GlobalStaff, UserBasedRole
CourseInstructorRole, CourseStaffRole, CourseCreatorRole, GlobalStaff, UserBasedRole
)
from util.course import get_link_for_about_page from util.course import get_link_for_about_page
from util.date_utils import get_default_time_display from util.date_utils import get_default_time_display
from util.json_request import JsonResponse, JsonResponseBadRequest, expect_json from util.json_request import JsonResponse, JsonResponseBadRequest, expect_json
...@@ -83,24 +71,23 @@ from util.milestones_helpers import ( ...@@ -83,24 +71,23 @@ from util.milestones_helpers import (
is_entrance_exams_enabled, is_entrance_exams_enabled,
is_prerequisite_courses_enabled, is_prerequisite_courses_enabled,
is_valid_course_key, is_valid_course_key,
set_prerequisite_courses, set_prerequisite_courses
)
from util.organizations_helpers import (
add_organization_course,
get_organization_by_short_name,
organizations_enabled,
) )
from util.organizations_helpers import add_organization_course, get_organization_by_short_name, organizations_enabled
from util.string_utils import _has_non_ascii_characters from util.string_utils import _has_non_ascii_characters
from xblock_django.api import deprecated_xblocks from xblock_django.api import deprecated_xblocks
from xmodule.contentstore.content import StaticContent from xmodule.contentstore.content import StaticContent
from xmodule.course_module import CourseFields from xmodule.course_module import DEFAULT_START_DATE, CourseFields
from xmodule.course_module import DEFAULT_START_DATE
from xmodule.error_module import ErrorDescriptor from xmodule.error_module import ErrorDescriptor
from xmodule.modulestore import EdxJSONEncoder from xmodule.modulestore import EdxJSONEncoder
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from xmodule.modulestore.exceptions import ItemNotFoundError, DuplicateCourseError from xmodule.modulestore.exceptions import DuplicateCourseError, ItemNotFoundError
from xmodule.tabs import CourseTab, CourseTabList, InvalidTabsException from xmodule.tabs import CourseTab, CourseTabList, InvalidTabsException
from .component import ADVANCED_COMPONENT_TYPES
from .item import create_xblock_info
from .library import LIBRARIES_ENABLED, get_library_creator_status
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
__all__ = ['course_info_handler', 'course_handler', 'course_listing', __all__ = ['course_info_handler', 'course_handler', 'course_listing',
......
...@@ -2,25 +2,25 @@ ...@@ -2,25 +2,25 @@
Entrance Exams view module -- handles all requests related to entrance exam management via Studio Entrance Exams view module -- handles all requests related to entrance exam management via Studio
Intended to be utilized as an AJAX callback handler, versus a proper view/screen Intended to be utilized as an AJAX callback handler, versus a proper view/screen
""" """
from functools import wraps
import logging import logging
from functools import wraps
from django.conf import settings
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.views.decorators.csrf import ensure_csrf_cookie
from django.http import HttpResponse, HttpResponseBadRequest from django.http import HttpResponse, HttpResponseBadRequest
from django.utils.translation import ugettext as _
from django.views.decorators.csrf import ensure_csrf_cookie
from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey, UsageKey
from openedx.core.djangolib.js_utils import dump_js_escaped_json
from contentstore.views.helpers import create_xblock, remove_entrance_exam_graders from contentstore.views.helpers import create_xblock, remove_entrance_exam_graders
from contentstore.views.item import delete_item from contentstore.views.item import delete_item
from models.settings.course_metadata import CourseMetadata from models.settings.course_metadata import CourseMetadata
from opaque_keys.edx.keys import CourseKey, UsageKey from openedx.core.djangolib.js_utils import dump_js_escaped_json
from opaque_keys import InvalidKeyError
from student.auth import has_course_author_access from student.auth import has_course_author_access
from util import milestones_helpers from util import milestones_helpers
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 django.conf import settings
from django.utils.translation import ugettext as _
__all__ = ['entrance_exam', ] __all__ = ['entrance_exam', ]
......
# pylint: disable=missing-docstring,unused-argument # pylint: disable=missing-docstring,unused-argument
from django.http import (HttpResponse, HttpResponseServerError,
HttpResponseNotFound)
from edxmako.shortcuts import render_to_string, render_to_response
import functools import functools
from django.http import HttpResponse, HttpResponseNotFound, HttpResponseServerError
from edxmako.shortcuts import render_to_response, render_to_string
from openedx.core.djangolib.js_utils import dump_js_escaped_json from openedx.core.djangolib.js_utils import dump_js_escaped_json
__all__ = ['not_found', 'server_error', 'render_404', 'render_500'] __all__ = ['not_found', 'server_error', 'render_404', 'render_500']
......
...@@ -7,14 +7,14 @@ import logging ...@@ -7,14 +7,14 @@ import logging
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.core.exceptions import PermissionDenied from django.core.exceptions import PermissionDenied
from django.views.decorators.csrf import ensure_csrf_cookie
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.views.decorators.csrf import ensure_csrf_cookie
from opaque_keys.edx.keys import CourseKey
from student.auth import has_course_author_access
import contentstore.git_export_utils as git_export_utils import contentstore.git_export_utils as git_export_utils
from edxmako.shortcuts import render_to_response from edxmako.shortcuts import render_to_response
from student.auth import has_course_author_access
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from opaque_keys.edx.keys import CourseKey
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
......
...@@ -4,24 +4,23 @@ Helper methods for Studio views. ...@@ -4,24 +4,23 @@ Helper methods for Studio views.
from __future__ import absolute_import from __future__ import absolute_import
from uuid import uuid4
import urllib import urllib
from uuid import uuid4
from django.conf import settings from django.conf import settings
from django.http import HttpResponse from django.http import HttpResponse
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from edxmako.shortcuts import render_to_string
from opaque_keys.edx.keys import UsageKey from opaque_keys.edx.keys import UsageKey
from xblock.core import XBlock from xblock.core import XBlock
import dogstats_wrapper as dog_stats_api
from xmodule.modulestore.django import modulestore
from xmodule.x_module import DEPRECATION_VSCOMPAT_EVENT
from xmodule.tabs import StaticTab
import dogstats_wrapper as dog_stats_api
from contentstore.utils import reverse_course_url, reverse_library_url, reverse_usage_url from contentstore.utils import reverse_course_url, reverse_library_url, reverse_usage_url
from edxmako.shortcuts import render_to_string
from models.settings.course_grading import CourseGradingModel from models.settings.course_grading import CourseGradingModel
from util.milestones_helpers import is_entrance_exams_enabled from util.milestones_helpers import is_entrance_exams_enabled
from xmodule.modulestore.django import modulestore
from xmodule.tabs import StaticTab
from xmodule.x_module import DEPRECATION_VSCOMPAT_EVENT
__all__ = ['event'] __all__ = ['event']
......
...@@ -8,9 +8,6 @@ import logging ...@@ -8,9 +8,6 @@ import logging
import os import os
import re import re
import shutil import shutil
from path import Path as path
from six import text_type
from django.conf import settings from django.conf import settings
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
...@@ -18,28 +15,26 @@ from django.core.exceptions import PermissionDenied ...@@ -18,28 +15,26 @@ from django.core.exceptions import PermissionDenied
from django.core.files import File from django.core.files import File
from django.core.servers.basehttp import FileWrapper from django.core.servers.basehttp import FileWrapper
from django.db import transaction from django.db import transaction
from django.http import HttpResponse, HttpResponseNotFound, Http404 from django.http import Http404, HttpResponse, HttpResponseNotFound
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.views.decorators.csrf import ensure_csrf_cookie from django.views.decorators.csrf import ensure_csrf_cookie
from django.views.decorators.http import require_http_methods, require_GET from django.views.decorators.http import require_GET, require_http_methods
from edxmako.shortcuts import render_to_response
from xmodule.exceptions import SerializationError
from xmodule.modulestore.django import modulestore
from opaque_keys.edx.keys import CourseKey from opaque_keys.edx.keys import CourseKey
from opaque_keys.edx.locator import LibraryLocator from opaque_keys.edx.locator import LibraryLocator
from path import Path as path
from six import text_type
from user_tasks.conf import settings as user_tasks_settings from user_tasks.conf import settings as user_tasks_settings
from user_tasks.models import UserTaskArtifact, UserTaskStatus from user_tasks.models import UserTaskArtifact, UserTaskStatus
from student.auth import has_course_author_access
from util.json_request import JsonResponse
from util.views import ensure_valid_course_key
from contentstore.storage import course_import_export_storage from contentstore.storage import course_import_export_storage
from contentstore.tasks import CourseExportTask, CourseImportTask, create_export_tarball, export_olx, import_olx from contentstore.tasks import CourseExportTask, CourseImportTask, create_export_tarball, export_olx, import_olx
from contentstore.utils import reverse_course_url, reverse_library_url from contentstore.utils import reverse_course_url, reverse_library_url
from edxmako.shortcuts import render_to_response
from student.auth import has_course_author_access
from util.json_request import JsonResponse
from util.views import ensure_valid_course_key
from xmodule.exceptions import SerializationError
from xmodule.modulestore.django import modulestore
__all__ = [ __all__ = [
'import_handler', 'import_status_handler', 'import_handler', 'import_status_handler',
......
...@@ -8,55 +8,62 @@ from datetime import datetime ...@@ -8,55 +8,62 @@ from datetime import datetime
from functools import partial from functools import partial
from uuid import uuid4 from uuid import uuid4
import dogstats_wrapper as dog_stats_api
from django.conf import settings from django.conf import settings
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.core.exceptions import PermissionDenied from django.core.exceptions import PermissionDenied
from django.http import HttpResponseBadRequest, HttpResponse, Http404 from django.http import Http404, HttpResponse, HttpResponseBadRequest
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.views.decorators.http import require_http_methods from django.views.decorators.http import require_http_methods
from opaque_keys.edx.keys import CourseKey from opaque_keys.edx.keys import CourseKey
from opaque_keys.edx.locator import LibraryUsageLocator from opaque_keys.edx.locator import LibraryUsageLocator
from pytz import UTC from pytz import UTC
from xblock.core import XBlock from xblock.core import XBlock
from xblock.fields import Scope from xblock.fields import Scope
from xblock.fragment import Fragment from xblock.fragment import Fragment
from xblock_config.models import CourseEditLTIFieldsEnabledFlag import dogstats_wrapper as dog_stats_api
from xblock_django.user_service import DjangoXBlockUserService
from cms.lib.xblock.authoring_mixin import VISIBILITY_VIEW from cms.lib.xblock.authoring_mixin import VISIBILITY_VIEW
from contentstore.utils import ( from contentstore.utils import (
find_release_date_source, find_staff_lock_source, is_currently_visible_to_students, ancestor_has_staff_lock,
ancestor_has_staff_lock, has_children_visible_to_specific_partition_groups, find_release_date_source,
get_user_partition_info, get_split_group_display_name, find_staff_lock_source,
get_split_group_display_name,
get_user_partition_info,
has_children_visible_to_specific_partition_groups,
is_currently_visible_to_students,
is_self_paced
)
from contentstore.views.helpers import (
create_xblock,
get_parent_xblock,
is_unit,
usage_key_with_run,
xblock_primary_child_category,
xblock_studio_url,
xblock_type_display_name
) )
from contentstore.views.helpers import is_unit, xblock_studio_url, xblock_primary_child_category, \
xblock_type_display_name, get_parent_xblock, create_xblock, usage_key_with_run
from contentstore.views.preview import get_preview_fragment from contentstore.views.preview import get_preview_fragment
from contentstore.utils import is_self_paced
from openedx.core.lib.gating import api as gating_api
from edxmako.shortcuts import render_to_string from edxmako.shortcuts import render_to_string
from models.settings.course_grading import CourseGradingModel from models.settings.course_grading import CourseGradingModel
from openedx.core.lib.xblock_utils import wrap_xblock, request_token from openedx.core.lib.gating import api as gating_api
from openedx.core.lib.xblock_utils import request_token, wrap_xblock
from static_replace import replace_static_urls from static_replace import replace_static_urls
from student.auth import has_studio_write_access, has_studio_read_access from student.auth import has_studio_read_access, has_studio_write_access
from util.date_utils import get_default_time_display from util.date_utils import get_default_time_display
from util.json_request import expect_json, JsonResponse from util.json_request import JsonResponse, expect_json
from util.milestones_helpers import is_entrance_exams_enabled from util.milestones_helpers import is_entrance_exams_enabled
from xblock_config.models import CourseEditLTIFieldsEnabledFlag
from xblock_django.user_service import DjangoXBlockUserService
from xmodule.course_module import DEFAULT_START_DATE from xmodule.course_module import DEFAULT_START_DATE
from xmodule.modulestore import ModuleStoreEnum, EdxJSONEncoder from xmodule.modulestore import EdxJSONEncoder, ModuleStoreEnum
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from xmodule.modulestore.draft_and_published import DIRECT_ONLY_CATEGORIES from xmodule.modulestore.draft_and_published import DIRECT_ONLY_CATEGORIES
from xmodule.modulestore.exceptions import ItemNotFoundError, InvalidLocationError from xmodule.modulestore.exceptions import InvalidLocationError, ItemNotFoundError
from xmodule.modulestore.inheritance import own_metadata from xmodule.modulestore.inheritance import own_metadata
from xmodule.services import ConfigurationService, SettingsService from xmodule.services import ConfigurationService, SettingsService
from xmodule.tabs import CourseTabList from xmodule.tabs import CourseTabList
from xmodule.x_module import PREVIEW_VIEWS, STUDIO_VIEW, STUDENT_VIEW, DEPRECATION_VSCOMPAT_EVENT from xmodule.x_module import DEPRECATION_VSCOMPAT_EVENT, PREVIEW_VIEWS, STUDENT_VIEW, STUDIO_VIEW
__all__ = [ __all__ = [
'orphan_handler', 'xblock_handler', 'xblock_view_handler', 'xblock_outline_handler', 'xblock_container_handler' 'orphan_handler', 'xblock_handler', 'xblock_view_handler', 'xblock_outline_handler', 'xblock_container_handler'
......
...@@ -7,31 +7,36 @@ from __future__ import absolute_import ...@@ -7,31 +7,36 @@ from __future__ import absolute_import
import logging import logging
from contentstore.views.item import create_xblock_info from django.conf import settings
from contentstore.utils import reverse_library_url, add_instructor
from django.http import HttpResponseNotAllowed, Http404, HttpResponseForbidden
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.core.exceptions import PermissionDenied from django.core.exceptions import PermissionDenied
from django.conf import settings from django.http import Http404, HttpResponseForbidden, HttpResponseNotAllowed
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.views.decorators.http import require_http_methods
from django.views.decorators.csrf import ensure_csrf_cookie from django.views.decorators.csrf import ensure_csrf_cookie
from edxmako.shortcuts import render_to_response from django.views.decorators.http import require_http_methods
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 opaque_keys.edx.locator import LibraryLocator, LibraryUsageLocator from opaque_keys.edx.locator import LibraryLocator, LibraryUsageLocator
from xmodule.modulestore.exceptions import DuplicateCourseError
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore
from .user import user_with_role
from contentstore.utils import add_instructor, reverse_library_url
from contentstore.views.item import create_xblock_info
from course_creators.views import get_course_creator_status from course_creators.views import get_course_creator_status
from .component import get_component_templates, CONTAINER_TEMPLATES from edxmako.shortcuts import render_to_response
from student.auth import ( from student.auth import (
STUDIO_VIEW_USERS, STUDIO_EDIT_ROLES, get_user_permissions, has_studio_read_access, has_studio_write_access STUDIO_EDIT_ROLES,
STUDIO_VIEW_USERS,
get_user_permissions,
has_studio_read_access,
has_studio_write_access
) )
from student.roles import CourseInstructorRole, CourseStaffRole, LibraryUserRole from student.roles import CourseInstructorRole, CourseStaffRole, LibraryUserRole
from util.json_request import expect_json, JsonResponse, JsonResponseBadRequest from util.json_request import JsonResponse, JsonResponseBadRequest, expect_json
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.exceptions import DuplicateCourseError
from .component import CONTAINER_TEMPLATES, get_component_templates
from .user import user_with_role
__all__ = ['library_handler', 'manage_library_users'] __all__ = ['library_handler', 'manage_library_users']
......
"""Organizations views for use with Studio.""" """Organizations views for use with Studio."""
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.http import HttpResponse
from django.utils.decorators import method_decorator from django.utils.decorators import method_decorator
from django.views.generic import View from django.views.generic import View
from django.http import HttpResponse
from openedx.core.djangolib.js_utils import dump_js_escaped_json from openedx.core.djangolib.js_utils import dump_js_escaped_json
from util.organizations_helpers import get_organizations from util.organizations_helpers import get_organizations
......
...@@ -4,44 +4,45 @@ import logging ...@@ -4,44 +4,45 @@ import logging
from functools import partial from functools import partial
from django.conf import settings from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.http import Http404, HttpResponseBadRequest from django.http import Http404, HttpResponseBadRequest
from django.contrib.auth.decorators import login_required
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from edxmako.shortcuts import render_to_string from opaque_keys.edx.keys import UsageKey
from xblock.django.request import django_to_webob_request, webob_to_django_response
from xblock.exceptions import NoSuchHandlerError
from xblock.fragment import Fragment
from xblock.runtime import KvsFieldData
import static_replace
from cms.lib.xblock.field_data import CmsFieldData
from contentstore.utils import get_visibility_partition_info
from contentstore.views.access import get_user_role
from edxmako.shortcuts import render_to_string
from lms.djangoapps.lms_xblock.field_data import LmsFieldData
from openedx.core.lib.license import wrap_with_license
from openedx.core.lib.xblock_utils import ( from openedx.core.lib.xblock_utils import (
replace_static_urls, wrap_xblock, wrap_fragment, wrap_xblock_aside, request_token, xblock_local_resource_url, replace_static_urls,
request_token,
wrap_fragment,
wrap_xblock,
wrap_xblock_aside,
xblock_local_resource_url
) )
from xmodule.x_module import PREVIEW_VIEWS, STUDENT_VIEW, AUTHOR_VIEW from util.sandboxing import can_execute_unsafe_code, get_python_lib_zip
from xblock_config.models import StudioConfig
from xblock_django.user_service import DjangoXBlockUserService
from xmodule.contentstore.django import contentstore from xmodule.contentstore.django import contentstore
from xmodule.error_module import ErrorDescriptor from xmodule.error_module import ErrorDescriptor
from xmodule.exceptions import NotFoundError, ProcessingError from xmodule.exceptions import NotFoundError, ProcessingError
from xmodule.modulestore.django import ModuleI18nService, modulestore
from xmodule.partitions.partitions_service import PartitionService from xmodule.partitions.partitions_service import PartitionService
from xmodule.studio_editable import has_author_view
from xmodule.services import SettingsService from xmodule.services import SettingsService
from xmodule.modulestore.django import modulestore, ModuleI18nService from xmodule.studio_editable import has_author_view
from openedx.core.lib.license import wrap_with_license from xmodule.x_module import AUTHOR_VIEW, PREVIEW_VIEWS, STUDENT_VIEW, ModuleSystem
from opaque_keys.edx.keys import UsageKey
from xmodule.x_module import ModuleSystem
from xblock.runtime import KvsFieldData
from xblock.django.request import webob_to_django_response, django_to_webob_request
from xblock.exceptions import NoSuchHandlerError
from xblock.fragment import Fragment
from xblock_django.user_service import DjangoXBlockUserService
from lms.djangoapps.lms_xblock.field_data import LmsFieldData
from cms.lib.xblock.field_data import CmsFieldData
from util.sandboxing import can_execute_unsafe_code, get_python_lib_zip
import static_replace
from .session_kv_store import SessionKeyValueStore
from .helpers import render_from_lms from .helpers import render_from_lms
from .session_kv_store import SessionKeyValueStore
from contentstore.utils import get_visibility_partition_info
from contentstore.views.access import get_user_role
from xblock_config.models import StudioConfig
__all__ = ['preview_handler'] __all__ = ['preview_handler']
......
""" """
Public views Public views
""" """
from django.views.decorators.csrf import ensure_csrf_cookie from django.conf import settings
from django.views.decorators.clickjacking import xframe_options_deny
from django.core.context_processors import csrf from django.core.context_processors import csrf
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.shortcuts import redirect from django.shortcuts import redirect
from django.conf import settings from django.views.decorators.clickjacking import xframe_options_deny
from django.views.decorators.csrf import ensure_csrf_cookie
from edxmako.shortcuts import render_to_response from edxmako.shortcuts import render_to_response
from openedx.core.djangoapps.external_auth.views import redirect_with_get, ssl_get_cert_from_request, ssl_login_shortcut
from openedx.core.djangoapps.external_auth.views import (
ssl_login_shortcut,
ssl_get_cert_from_request,
redirect_with_get,
)
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
__all__ = ['signup', 'login_page', 'howitworks'] __all__ = ['signup', 'login_page', 'howitworks']
......
""" """
Views related to course tabs Views related to course tabs
""" """
from student.auth import has_course_author_access
from util.json_request import expect_json, JsonResponse
from django.http import HttpResponseNotFound
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.core.exceptions import PermissionDenied from django.core.exceptions import PermissionDenied
from django.http import HttpResponseNotFound
from django.views.decorators.csrf import ensure_csrf_cookie from django.views.decorators.csrf import ensure_csrf_cookie
from django.views.decorators.http import require_http_methods from django.views.decorators.http import require_http_methods
from opaque_keys.edx.keys import CourseKey, UsageKey
from edxmako.shortcuts import render_to_response from edxmako.shortcuts import render_to_response
from xmodule.modulestore.django import modulestore from student.auth import has_course_author_access
from util.json_request import JsonResponse, expect_json
from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore import ModuleStoreEnum
from xmodule.tabs import CourseTabList, CourseTab, InvalidTabsException, StaticTab from xmodule.modulestore.django import modulestore
from opaque_keys.edx.keys import CourseKey, UsageKey from xmodule.tabs import CourseTab, CourseTabList, InvalidTabsException, StaticTab
from ..utils import get_lms_link_for_item from ..utils import get_lms_link_for_item
......
""" """
Tests access.py Tests access.py
""" """
from django.test import TestCase
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.test import TestCase
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from contentstore.views.access import get_user_role
from student.auth import add_users
from student.roles import CourseInstructorRole, CourseStaffRole from student.roles import CourseInstructorRole, CourseStaffRole
from student.tests.factories import AdminFactory from student.tests.factories import AdminFactory
from student.auth import add_users
from contentstore.views.access import get_user_role
from opaque_keys.edx.locations import SlashSeparatedCourseKey
class RolesTest(TestCase): class RolesTest(TestCase):
......
""" """
Unit tests for the asset upload endpoint. Unit tests for the asset upload endpoint.
""" """
import json
from datetime import datetime from datetime import datetime
from io import BytesIO from io import BytesIO
from pytz import UTC
from PIL import Image import mock
import json from ddt import data, ddt
from mock import patch
from django.conf import settings from django.conf import settings
from django.test.utils import override_settings
from mock import patch
from opaque_keys.edx.locations import AssetLocation, SlashSeparatedCourseKey
from PIL import Image
from pytz import UTC
from contentstore.tests.utils import CourseTestCase from contentstore.tests.utils import CourseTestCase
from contentstore.views import assets
from contentstore.utils import reverse_course_url from contentstore.utils import reverse_course_url
from contentstore.views import assets
from static_replace import replace_static_urls
from xmodule.assetstore import AssetMetadata from xmodule.assetstore import AssetMetadata
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.modulestore.django import modulestore
from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.xml_importer import import_course_from_xml from xmodule.modulestore.xml_importer import import_course_from_xml
from django.test.utils import override_settings
from opaque_keys.edx.locations import SlashSeparatedCourseKey, AssetLocation
from static_replace import replace_static_urls
import mock
from ddt import ddt
from ddt import data
TEST_DATA_DIR = settings.COMMON_TEST_DATA_ROOT TEST_DATA_DIR = settings.COMMON_TEST_DATA_ROOT
......
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