From 980f30c17fd5af45364982703ef02e625373f4d6 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Fri, 5 Dec 2014 13:05:46 -0500 Subject: [PATCH] Move lms.lib.xblock into lms.djangoapps.lms_xblock in preparation add database backed configuration to it --- {lms/lib/xblock => cms/djangoapps}/__init__.py | 0 cms/djangoapps/contentstore/views/preview.py | 2 +- cms/envs/common.py | 2 +- lms/djangoapps/courseware/module_render.py | 4 ++-- lms/djangoapps/courseware/tests/__init__.py | 4 ++-- .../courseware/tests/test_lti_integration.py | 2 +- lms/djangoapps/courseware/tests/test_masquerade.py | 2 +- lms/djangoapps/courseware/tests/test_module_render.py | 3 ++- .../courseware/tests/test_submitting_problems.py | 2 +- lms/djangoapps/courseware/tests/tests.py | 2 +- .../instructor/views/instructor_dashboard.py | 2 +- .../instructor_task/tests/test_integration.py | 2 +- .../xblock/test => djangoapps/lms_xblock}/__init__.py | 0 .../xblock => djangoapps/lms_xblock}/field_data.py | 0 lms/{lib/xblock => djangoapps/lms_xblock}/mixin.py | 0 lms/{lib/xblock => djangoapps/lms_xblock}/runtime.py | 0 lms/djangoapps/lms_xblock/test/__init__.py | 0 .../lms_xblock}/test/test_runtime.py | 2 +- lms/djangoapps/notes/tests.py | 11 ++++++----- .../open_ended_grading/open_ended_notifications.py | 2 +- .../open_ended_grading/staff_grading_service.py | 2 +- lms/djangoapps/open_ended_grading/utils.py | 2 +- lms/envs/common.py | 2 +- pavelib/quality.py | 6 +++--- 24 files changed, 28 insertions(+), 26 deletions(-) rename {lms/lib/xblock => cms/djangoapps}/__init__.py (100%) rename lms/{lib/xblock/test => djangoapps/lms_xblock}/__init__.py (100%) rename lms/{lib/xblock => djangoapps/lms_xblock}/field_data.py (100%) rename lms/{lib/xblock => djangoapps/lms_xblock}/mixin.py (100%) rename lms/{lib/xblock => djangoapps/lms_xblock}/runtime.py (100%) create mode 100644 lms/djangoapps/lms_xblock/test/__init__.py rename lms/{lib/xblock => djangoapps/lms_xblock}/test/test_runtime.py (98%) diff --git a/lms/lib/xblock/__init__.py b/cms/djangoapps/__init__.py similarity index 100% rename from lms/lib/xblock/__init__.py rename to cms/djangoapps/__init__.py diff --git a/cms/djangoapps/contentstore/views/preview.py b/cms/djangoapps/contentstore/views/preview.py index 772fc4c264..0d1dfec64f 100644 --- a/cms/djangoapps/contentstore/views/preview.py +++ b/cms/djangoapps/contentstore/views/preview.py @@ -22,7 +22,7 @@ from xblock.django.request import webob_to_django_response, django_to_webob_requ from xblock.exceptions import NoSuchHandlerError from xblock.fragment import Fragment -from lms.lib.xblock.field_data import LmsFieldData +from lms.djangoapps.lms_xblock.field_data import LmsFieldData from cms.lib.xblock.field_data import CmsFieldData from cms.lib.xblock.runtime import local_resource_url diff --git a/cms/envs/common.py b/cms/envs/common.py index 6951a08a43..d21242c8b5 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -36,7 +36,7 @@ from lms.envs.common import ( from path import path from warnings import simplefilter -from lms.lib.xblock.mixin import LmsBlockMixin +from lms.djangoapps.lms_xblock.mixin import LmsBlockMixin from dealer.git import git from xmodule.modulestore.edit_info import EditInfoMixin diff --git a/lms/djangoapps/courseware/module_render.py b/lms/djangoapps/courseware/module_render.py index 5b79b9dd78..6294f46f00 100644 --- a/lms/djangoapps/courseware/module_render.py +++ b/lms/djangoapps/courseware/module_render.py @@ -21,8 +21,8 @@ from capa.xqueue_interface import XQueueInterface from courseware.access import has_access, get_user_role from courseware.masquerade import setup_masquerade from courseware.model_data import FieldDataCache, DjangoKeyValueStore -from lms.lib.xblock.field_data import LmsFieldData -from lms.lib.xblock.runtime import LmsModuleSystem, unquote_slashes, quote_slashes +from lms.djangoapps.lms_xblock.field_data import LmsFieldData +from lms.djangoapps.lms_xblock.runtime import LmsModuleSystem, unquote_slashes, quote_slashes from edxmako.shortcuts import render_to_string from eventtracking import tracker from psychometrics.psychoanalyze import make_psychometrics_data_update_handler diff --git a/lms/djangoapps/courseware/tests/__init__.py b/lms/djangoapps/courseware/tests/__init__.py index c0cf78fdb3..ede67b9778 100644 --- a/lms/djangoapps/courseware/tests/__init__.py +++ b/lms/djangoapps/courseware/tests/__init__.py @@ -20,8 +20,8 @@ from opaque_keys.edx.locations import Location from xmodule.modulestore.django import modulestore from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase -from lms.lib.xblock.field_data import LmsFieldData -from lms.lib.xblock.runtime import quote_slashes +from lms.djangoapps.lms_xblock.field_data import LmsFieldData +from lms.djangoapps.lms_xblock.runtime import quote_slashes @override_settings(MODULESTORE=TEST_DATA_MONGO_MODULESTORE) diff --git a/lms/djangoapps/courseware/tests/test_lti_integration.py b/lms/djangoapps/courseware/tests/test_lti_integration.py index 0811cf09a7..2c7da15823 100644 --- a/lms/djangoapps/courseware/tests/test_lti_integration.py +++ b/lms/djangoapps/courseware/tests/test_lti_integration.py @@ -13,7 +13,7 @@ from django.test.utils import override_settings from courseware.tests import BaseTestXmodule from xmodule.modulestore.tests.django_utils import TEST_DATA_MOCK_MODULESTORE from courseware.views import get_course_lti_endpoints -from lms.lib.xblock.runtime import quote_slashes +from lms.djangoapps.lms_xblock.runtime import quote_slashes from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory from xmodule.x_module import STUDENT_VIEW diff --git a/lms/djangoapps/courseware/tests/test_masquerade.py b/lms/djangoapps/courseware/tests/test_masquerade.py index 8262dc6c6b..6a567cb466 100644 --- a/lms/djangoapps/courseware/tests/test_masquerade.py +++ b/lms/djangoapps/courseware/tests/test_masquerade.py @@ -15,7 +15,7 @@ from opaque_keys.edx.locations import SlashSeparatedCourseKey from courseware.tests.factories import StaffFactory from courseware.tests.helpers import LoginEnrollmentTestCase -from lms.lib.xblock.runtime import quote_slashes +from lms.djangoapps.lms_xblock.runtime import quote_slashes from xmodule.modulestore.django import modulestore, clear_existing_modulestores from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.django_utils import TEST_DATA_MIXED_GRADED_MODULESTORE diff --git a/lms/djangoapps/courseware/tests/test_module_render.py b/lms/djangoapps/courseware/tests/test_module_render.py index 28c595fe8a..0c2bb313ee 100644 --- a/lms/djangoapps/courseware/tests/test_module_render.py +++ b/lms/djangoapps/courseware/tests/test_module_render.py @@ -30,9 +30,10 @@ from xmodule.modulestore.tests.django_utils import ( TEST_DATA_XML_MODULESTORE ) from courseware.tests.test_submitting_problems import TestSubmittingProblems -from lms.lib.xblock.runtime import quote_slashes +from lms.djangoapps.lms_xblock.runtime import quote_slashes from student.models import anonymous_id_for_user from xmodule.lti_module import LTIDescriptor + from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore.django import modulestore from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase diff --git a/lms/djangoapps/courseware/tests/test_submitting_problems.py b/lms/djangoapps/courseware/tests/test_submitting_problems.py index ae6a4b0dab..3a7ddd8939 100644 --- a/lms/djangoapps/courseware/tests/test_submitting_problems.py +++ b/lms/djangoapps/courseware/tests/test_submitting_problems.py @@ -21,7 +21,7 @@ from courseware import grades from courseware.models import StudentModule from courseware.tests.helpers import LoginEnrollmentTestCase from xmodule.modulestore.tests.django_utils import TEST_DATA_MOCK_MODULESTORE -from lms.lib.xblock.runtime import quote_slashes +from lms.djangoapps.lms_xblock.runtime import quote_slashes from student.tests.factories import UserFactory from student.models import anonymous_id_for_user from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase diff --git a/lms/djangoapps/courseware/tests/tests.py b/lms/djangoapps/courseware/tests/tests.py index a748f93666..def1dffbe2 100644 --- a/lms/djangoapps/courseware/tests/tests.py +++ b/lms/djangoapps/courseware/tests/tests.py @@ -12,7 +12,7 @@ from opaque_keys.edx.locations import SlashSeparatedCourseKey from courseware.tests.helpers import LoginEnrollmentTestCase from xmodule.modulestore.tests.django_utils import TEST_DATA_XML_MODULESTORE as XML_MODULESTORE from xmodule.modulestore.tests.django_utils import TEST_DATA_MIXED_TOY_MODULESTORE as TOY_MODULESTORE -from lms.lib.xblock.field_data import LmsFieldData +from lms.djangoapps.lms_xblock.field_data import LmsFieldData from xmodule.error_module import ErrorDescriptor from xmodule.modulestore.django import modulestore from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase diff --git a/lms/djangoapps/instructor/views/instructor_dashboard.py b/lms/djangoapps/instructor/views/instructor_dashboard.py index 0ba515b7d4..7a2ed19fad 100644 --- a/lms/djangoapps/instructor/views/instructor_dashboard.py +++ b/lms/djangoapps/instructor/views/instructor_dashboard.py @@ -19,7 +19,7 @@ from django.http import Http404 from django.conf import settings from util.json_request import JsonResponse -from lms.lib.xblock.runtime import quote_slashes +from lms.djangoapps.lms_xblock.runtime import quote_slashes from xmodule_modifiers import wrap_xblock from xmodule.html_module import HtmlDescriptor from xmodule.modulestore.django import modulestore diff --git a/lms/djangoapps/instructor_task/tests/test_integration.py b/lms/djangoapps/instructor_task/tests/test_integration.py index 68c1a44cbc..72580de00b 100644 --- a/lms/djangoapps/instructor_task/tests/test_integration.py +++ b/lms/djangoapps/instructor_task/tests/test_integration.py @@ -32,7 +32,7 @@ from instructor_task.tasks_helper import upload_grades_csv from instructor_task.tests.test_base import (InstructorTaskModuleTestCase, TestReportMixin, TEST_COURSE_ORG, TEST_COURSE_NUMBER, OPTION_1, OPTION_2) from capa.responsetypes import StudentInputError -from lms.lib.xblock.runtime import quote_slashes +from lms.djangoapps.lms_xblock.runtime import quote_slashes log = logging.getLogger(__name__) diff --git a/lms/lib/xblock/test/__init__.py b/lms/djangoapps/lms_xblock/__init__.py similarity index 100% rename from lms/lib/xblock/test/__init__.py rename to lms/djangoapps/lms_xblock/__init__.py diff --git a/lms/lib/xblock/field_data.py b/lms/djangoapps/lms_xblock/field_data.py similarity index 100% rename from lms/lib/xblock/field_data.py rename to lms/djangoapps/lms_xblock/field_data.py diff --git a/lms/lib/xblock/mixin.py b/lms/djangoapps/lms_xblock/mixin.py similarity index 100% rename from lms/lib/xblock/mixin.py rename to lms/djangoapps/lms_xblock/mixin.py diff --git a/lms/lib/xblock/runtime.py b/lms/djangoapps/lms_xblock/runtime.py similarity index 100% rename from lms/lib/xblock/runtime.py rename to lms/djangoapps/lms_xblock/runtime.py diff --git a/lms/djangoapps/lms_xblock/test/__init__.py b/lms/djangoapps/lms_xblock/test/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lms/lib/xblock/test/test_runtime.py b/lms/djangoapps/lms_xblock/test/test_runtime.py similarity index 98% rename from lms/lib/xblock/test/test_runtime.py rename to lms/djangoapps/lms_xblock/test/test_runtime.py index dd6f9200fd..3345fbcc57 100644 --- a/lms/lib/xblock/test/test_runtime.py +++ b/lms/djangoapps/lms_xblock/test/test_runtime.py @@ -9,7 +9,7 @@ from mock import Mock from unittest import TestCase from urlparse import urlparse from opaque_keys.edx.locations import SlashSeparatedCourseKey -from lms.lib.xblock.runtime import quote_slashes, unquote_slashes, LmsModuleSystem +from lms.djangoapps.lms_xblock.runtime import quote_slashes, unquote_slashes, LmsModuleSystem TEST_STRINGS = [ '', diff --git a/lms/djangoapps/notes/tests.py b/lms/djangoapps/notes/tests.py index 3484fd66eb..4da4e7147d 100644 --- a/lms/djangoapps/notes/tests.py +++ b/lms/djangoapps/notes/tests.py @@ -2,6 +2,8 @@ Unit tests for the notes app. """ +from mock import patch, Mock + from opaque_keys.edx.locations import SlashSeparatedCourseKey from django.test import TestCase from django.test.client import Client @@ -12,7 +14,7 @@ from django.core.exceptions import ValidationError import collections import json -from . import utils, api, models +from notes import utils, api, models class UtilsTest(TestCase): @@ -49,7 +51,9 @@ class ApiTest(TestCase): self.client = Client() # Mocks - api.api_enabled = self.mock_api_enabled(True) + patcher = patch.object(api, 'api_enabled', Mock(return_value=True)) + patcher.start() + self.addCleanup(patcher.stop) # Create two accounts self.password = 'abc' @@ -73,9 +77,6 @@ class ApiTest(TestCase): # Make sure no note with this ID ever exists for testing purposes self.NOTE_ID_DOES_NOT_EXIST = 99999 - def mock_api_enabled(self, is_enabled): - return (lambda request, course_id: is_enabled) - def login(self, as_student=None): username = None password = self.password diff --git a/lms/djangoapps/open_ended_grading/open_ended_notifications.py b/lms/djangoapps/open_ended_grading/open_ended_notifications.py index 01267d8b9c..cf1185e1c7 100644 --- a/lms/djangoapps/open_ended_grading/open_ended_notifications.py +++ b/lms/djangoapps/open_ended_grading/open_ended_notifications.py @@ -10,7 +10,7 @@ from xmodule.open_ended_grading_classes.controller_query_service import Controll from xmodule.modulestore.django import ModuleI18nService from courseware.access import has_access -from lms.lib.xblock.runtime import LmsModuleSystem +from lms.djangoapps.lms_xblock.runtime import LmsModuleSystem from edxmako.shortcuts import render_to_string from student.models import unique_id_for_user from util.cache import cache diff --git a/lms/djangoapps/open_ended_grading/staff_grading_service.py b/lms/djangoapps/open_ended_grading/staff_grading_service.py index 0aeed52da2..7d7200fba8 100644 --- a/lms/djangoapps/open_ended_grading/staff_grading_service.py +++ b/lms/djangoapps/open_ended_grading/staff_grading_service.py @@ -14,7 +14,7 @@ from xmodule.open_ended_grading_classes.grading_service_module import GradingSer from xmodule.modulestore.django import ModuleI18nService from courseware.access import has_access -from lms.lib.xblock.runtime import LmsModuleSystem +from lms.djangoapps.lms_xblock.runtime import LmsModuleSystem from edxmako.shortcuts import render_to_string from student.models import unique_id_for_user diff --git a/lms/djangoapps/open_ended_grading/utils.py b/lms/djangoapps/open_ended_grading/utils.py index 6c7532985a..4ab0c4d7ac 100644 --- a/lms/djangoapps/open_ended_grading/utils.py +++ b/lms/djangoapps/open_ended_grading/utils.py @@ -9,7 +9,7 @@ from xmodule.open_ended_grading_classes.grading_service_module import GradingSer from django.utils.translation import ugettext as _ from django.conf import settings -from lms.lib.xblock.runtime import LmsModuleSystem +from lms.djangoapps.lms_xblock.runtime import LmsModuleSystem from edxmako.shortcuts import render_to_string diff --git a/lms/envs/common.py b/lms/envs/common.py index 7bfdd83070..a8b1c25012 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -34,7 +34,7 @@ from django.utils.translation import ugettext_lazy as _ from .discussionsettings import * from xmodule.modulestore.modulestore_settings import update_module_store_settings -from lms.lib.xblock.mixin import LmsBlockMixin +from lms.djangoapps.lms_xblock.mixin import LmsBlockMixin ################################### FEATURES ################################### # The display name of the platform to be used in templates/emails/etc. diff --git a/pavelib/quality.py b/pavelib/quality.py index 18fd9611e0..924ed00e5d 100644 --- a/pavelib/quality.py +++ b/pavelib/quality.py @@ -34,8 +34,8 @@ def find_fixme(options): apps_list = ' '.join(apps) pythonpath_prefix = ( - "PYTHONPATH={system}:{system}/djangoapps:{system}/" - "lib:common/djangoapps:common/lib".format( + "PYTHONPATH={system}:{system}/lib" + "common/djangoapps:common/lib".format( system=system ) ) @@ -83,7 +83,7 @@ def run_pylint(options): apps = [system] - for directory in ['djangoapps', 'lib']: + for directory in ['lib']: dirs = os.listdir(os.path.join(system, directory)) apps.extend([d for d in dirs if os.path.isdir(os.path.join(system, directory, d))])