-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Enable mongodb to be used as back-end for git-based authoring workflow #652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
1b111b1
add ability to import course (into CMS / edge) without static content,
ichuang a5bb971
add static_asset_path metadata to course, and honor its use in link r…
ichuang 220ec52
Merge branch 'master' of github.com:edx/edx-platform into feature/ich…
ichuang 39b6465
pep8 in inheritance.py
ichuang 13bb3bf
pylint
ichuang 2249692
pylint
ichuang e9ef450
pylint
ichuang 210fa11
modify handling of info/handouts and module_render to honor static_as…
ichuang 2fe4895
more static_asset_path handling in courses.py
ichuang fedfa7c
fix tabs.py to properly handle static_asset_path
ichuang 91bf6ad
remove extra debugging line from courses.py
ichuang 95952bd
add tests of static_asset_path and importing with no static;
ichuang 0d938d3
Merge branch 'master' of github.com:edx/edx-platform into feature/ich…
ichuang 8a84e67
clean up test_import_nostatic.py
ichuang d2e93f7
remove unncessary images from new test course
ichuang 9b26e5b
dummy commit - trigger jenkins rebuild
ichuang 42af561
pep8 and pylint for tests of nostatic import
ichuang 2ba0d40
fix pep8 violations
ef98c54
fix some pylint violations
fb3a5bf
remove unused class
0c1c3f1
loop in static import testing into common/* tests
77a38af
add some draft courseware importing paths in common/* tests
842556d
add new test data with draft content
079470d
add some more tests in common to increase coverage
7138aed
add xlint tests in test_mongo.py
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
cms/djangoapps/contentstore/tests/test_import_nostatic.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| #pylint: disable=E1101 | ||
| ''' | ||
| Tests for importing with no static | ||
| ''' | ||
|
|
||
| from django.test.client import Client | ||
| from django.test.utils import override_settings | ||
| from django.conf import settings | ||
| from path import path | ||
| import copy | ||
|
|
||
| from django.contrib.auth.models import User | ||
|
|
||
| from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase | ||
|
|
||
| from xmodule.modulestore import Location | ||
| from xmodule.modulestore.django import modulestore | ||
| from xmodule.contentstore.django import contentstore | ||
| from xmodule.modulestore.xml_importer import import_from_xml | ||
| from xmodule.contentstore.content import StaticContent | ||
|
|
||
| from xmodule.course_module import CourseDescriptor | ||
|
|
||
| from xmodule.exceptions import NotFoundError | ||
| from uuid import uuid4 | ||
|
|
||
|
|
||
| TEST_DATA_CONTENTSTORE = copy.deepcopy(settings.CONTENTSTORE) | ||
| TEST_DATA_CONTENTSTORE['OPTIONS']['db'] = 'test_xcontent_%s' % uuid4().hex | ||
|
|
||
|
|
||
| @override_settings(CONTENTSTORE=TEST_DATA_CONTENTSTORE) | ||
| class ContentStoreImportNoStaticTest(ModuleStoreTestCase): | ||
| """ | ||
| Tests that rely on the toy and test_import_course courses. | ||
| NOTE: refactor using CourseFactory so they do not. | ||
| """ | ||
| def setUp(self): | ||
|
|
||
| settings.MODULESTORE['default']['OPTIONS']['fs_root'] = path('common/test/data') | ||
| settings.MODULESTORE['direct']['OPTIONS']['fs_root'] = path('common/test/data') | ||
| uname = 'testuser' | ||
| email = 'test+courses@edx.org' | ||
| password = 'foo' | ||
|
|
||
| # Create the use so we can log them in. | ||
| self.user = User.objects.create_user(uname, email, password) | ||
|
|
||
| # Note that we do not actually need to do anything | ||
| # for registration if we directly mark them active. | ||
| self.user.is_active = True | ||
| # Staff has access to view all courses | ||
| self.user.is_staff = True | ||
|
|
||
| # Save the data that we've just changed to the db. | ||
| self.user.save() | ||
|
|
||
| self.client = Client() | ||
| self.client.login(username=uname, password=password) | ||
|
|
||
| def load_test_import_course(self): | ||
| ''' | ||
| Load the standard course used to test imports (for do_import_static=False behavior). | ||
| ''' | ||
| content_store = contentstore() | ||
| module_store = modulestore('direct') | ||
| import_from_xml(module_store, 'common/test/data/', ['test_import_course'], static_content_store=content_store, do_import_static=False, verbose=True) | ||
| course_location = CourseDescriptor.id_to_location('edX/test_import_course/2012_Fall') | ||
| course = module_store.get_item(course_location) | ||
| self.assertIsNotNone(course) | ||
|
|
||
| return module_store, content_store, course, course_location | ||
|
|
||
| def test_static_import(self): | ||
| ''' | ||
| Stuff in static_import should always be imported into contentstore | ||
| ''' | ||
| _, content_store, course, course_location = self.load_test_import_course() | ||
|
|
||
| # make sure we have ONE asset in our contentstore ("should_be_imported.html") | ||
| all_assets = content_store.get_all_content_for_course(course_location) | ||
| print "len(all_assets)=%d" % len(all_assets) | ||
| self.assertEqual(len(all_assets), 1) | ||
|
|
||
| content = None | ||
| try: | ||
| location = StaticContent.get_location_from_path('/c4x/edX/test_import_course/asset/should_be_imported.html') | ||
| content = content_store.find(location) | ||
| except NotFoundError: | ||
| pass | ||
|
|
||
| self.assertIsNotNone(content) | ||
|
|
||
| # make sure course.lms.static_asset_path is correct | ||
| print "static_asset_path = {0}".format(course.lms.static_asset_path) | ||
| self.assertEqual(course.lms.static_asset_path, 'test_import_course') | ||
|
|
||
| def test_asset_import_nostatic(self): | ||
| ''' | ||
| This test validates that an image asset is NOT imported when do_import_static=False | ||
| ''' | ||
| content_store = contentstore() | ||
|
|
||
| module_store = modulestore('direct') | ||
| import_from_xml(module_store, 'common/test/data/', ['toy'], static_content_store=content_store, do_import_static=False, verbose=True) | ||
|
|
||
| course_location = CourseDescriptor.id_to_location('edX/toy/2012_Fall') | ||
| module_store.get_item(course_location) | ||
|
|
||
| # make sure we have NO assets in our contentstore | ||
| all_assets = content_store.get_all_content_for_course(course_location) | ||
| print "len(all_assets)=%d" % len(all_assets) | ||
| self.assertEqual(len(all_assets), 0) | ||
|
|
||
| def test_no_static_link_rewrites_on_import(self): | ||
| module_store = modulestore('direct') | ||
| import_from_xml(module_store, 'common/test/data/', ['toy'], do_import_static=False, verbose=True) | ||
|
|
||
| handouts = module_store.get_item(Location(['i4x', 'edX', 'toy', 'course_info', 'handouts', None])) | ||
| self.assertIn('/static/', handouts.data) | ||
|
|
||
| handouts = module_store.get_item(Location(['i4x', 'edX', 'toy', 'html', 'toyhtml', None])) | ||
| self.assertIn('/static/', handouts.data) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is your plan to not use Mongo (via GridFS) for your static resources but serve those off filesystem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes - that is the main point of this PR. There are courses with huge
static resource collections, which take too long to import. And the gridfs
contentstore doest allow hierarchial storage.
This PR is already operating in production at MIT.
On Aug 19, 2013 9:22 AM, "chrisndodge" notifications@github.com wrote: