GitHub PullRequestReviewCommentEvent at 2014-07-16 18:52:06
Repository: edx-platform
Actor: sarina
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/comments/15019474","id":15019474,"diff_hunk":"@@ -0,0 +1,290 @@\n+\"\"\"\n+This suite of tests verifies that courses exported from one modulestore can be imported into\n+another modulestore and the result will be identical (up to a small number of changes to identifiers).\n+\n+It does this by providing facilities for creating and cleaning up each of the modulestore types,\n+and then for each combination of modulestores, performing the sequence:\n+    1) use xml_importer to read a course from xml from disk into the first modulestore (called the source)\n+    2) use xml_exporter to dump the course from the source modulestore to disk\n+    3) use xml_importer to read the dumped course into a second modulestore (called the destination)\n+    4) Compare all modules in the source and destination modulestores to make sure that they line up\n+\n+\"\"\"\n+\n+import ddt\n+import itertools\n+import random\n+from contextlib import contextmanager, nested\n+from functools import partial\n+from unittest import TestCase, SkipTest\n+from shutil import rmtree\n+from tempfile import mkdtemp\n+from opaque_keys.edx.locations import SlashSeparatedCourseKey\n+\n+from xmodule.tests import CourseComparisonTest\n+\n+from xmodule.modulestore.split_mongo.split import SplitMongoModuleStore\n+from xmodule.modulestore.mongo.base import ModuleStoreEnum\n+from xmodule.modulestore.mongo.draft import DraftModuleStore\n+from xmodule.modulestore.mixed import MixedModuleStore\n+from xmodule.contentstore.mongo import MongoContentStore\n+from xmodule.modulestore.xml_importer import import_from_xml\n+from xmodule.modulestore.xml_exporter import export_to_xml\n+\n+COMMON_DOCSTORE_CONFIG = {\n+    'host': 'localhost'\n+}\n+\n+\n+class MemoryCache(object):\n+    \"\"\"\n+    This fits the metadata_inheritance_cache_subsystem interface used by\n+    the modulestore, and stores the data in a dictionary in memory.\n+    \"\"\"\n+    def __init__(self):\n+        self._data = {}\n+\n+    def get(self, key, default=None):\n+        return self._data.get(key, default)\n+\n+    def set(self, key, value):\n+        self._data[key] = value\n+\n+\n+class MongoModulestoreBuilder(object):\n+    \"\"\"\n+    A builder class for a DraftModuleStore.\n+    \"\"\"\n+    @contextmanager\n+    def build(self, contentstore):\n+        \"\"\"\n+        A contextmanager that returns an isolated mongo modulestore, and then deletes\n+        all of its data at the end of the context.\n+\n+        Args:\n+            contentstore: The contentstore that this modulestore should use to store\n+                all of its assets.\n+        \"\"\"\n+        doc_store_config = dict(\n+            db='modulestore{}'.format(random.randint(0, 10000)),\n+            collection='xmodule',\n+            **COMMON_DOCSTORE_CONFIG\n+        )\n+        fs_root = mkdtemp()\n+\n+        modulestore = DraftModuleStore(\n+            contentstore,\n+            doc_store_config,\n+            fs_root,\n+            render_template=repr,\n+            branch_setting_func=lambda: ModuleStoreEnum.Branch.draft_preferred,\n+            metadata_inheritance_cache_subsystem=MemoryCache(),\n+        )\n+\n+        try:\n+            yield modulestore\n+        finally:\n+            db = modulestore.database\n+            db.connection.drop_database(db)\n+            db.connection.close()\n+            rmtree(fs_root)\n+\n+    def __repr__(self):\n+        return 'MongoModulestoreBuilder()'\n+\n+\n+class VersioningModulestoreBuilder(object):\n+    \"\"\"\n+    A builder class for a VersioningModuleStore.\n+    \"\"\"\n+    @contextmanager\n+    def build(self, contentstore):\n+        \"\"\"\n+        A contextmanager that returns an isolated versioning modulestore, and then deletes\n+        all of its data at the end of the context.\n+\n+        Args:\n+            contentstore: The contentstore that this modulestore should use to store\n+                all of its assets.\n+        \"\"\"\n+        raise SkipTest(\"DraftVersioningModuleStore doesn't yet support the same interface as the rest of the modulestores\")\n+        doc_store_config = dict(\n+            db='modulestore{}'.format(random.randint(0, 10000)),\n+            collection='split_module',\n+            **COMMON_DOCSTORE_CONFIG\n+        )\n+        fs_root = mkdtemp()\n+\n+        modulestore = SplitMongoModuleStore(\n+            contentstore,\n+            doc_store_config,\n+            fs_root,\n+            render_template=repr,\n+        )\n+\n+        try:\n+            yield modulestore\n+        finally:\n+\n+            db = modulestore.db\n+            db.connection.drop_database(db)\n+            db.connection.close()\n+            rmtree(fs_root)\n+\n+    def __repr__(self):\n+        return 'SplitModulestoreBuilder()'\n+\n+class MixedModulestoreBuilder(object):\n+    \"\"\"\n+    A builder class for a MixedModuleStore.\n+    \"\"\"\n+    def __init__(self, store_builders, mappings=None):\n+        \"\"\"\n+        Args:\n+            store_builders: A list of modulestore builder objects. These will be instantiated, in order,\n+                as the backing stores for the MixedModuleStore.\n+            mappings: Any course mappings to pass to the MixedModuleStore on instantiation.\n+        \"\"\"\n+        self.store_builders = store_builders\n+        self.mappings = mappings or {}\n+\n+    @contextmanager\n+    def build(self, contentstore):\n+        \"\"\"\n+        A contextmanager that returns a mixed modulestore built on top of modulestores\n+        generated by other builder classes.\n+\n+        Args:\n+            contentstore: The contentstore that this modulestore should use to store\n+                all of its assets.\n+        \"\"\"\n+        names, generators = zip(*self.store_builders)\n+\n+        with nested(*(gen.build(contentstore) for gen in generators)) as modulestores:\n+            # Make the modulestore creation function just return the already-created modulestores\n+            store_iterator = iter(modulestores)\n+            create_modulestore_instance = lambda *args, **kwargs: store_iterator.next()\n+\n+            # Generate a fake list of stores to give the already generated stores appropriate names\n+            stores = [{'NAME': name, 'ENGINE': 'This space deliberately left blank'} for name in names]\n+\n+            modulestore = MixedModuleStore(contentstore, self.mappings, stores, create_modulestore_instance=create_modulestore_instance)\n+\n+            yield modulestore\n+\n+    def __repr__(self):\n+        return 'MixedModulestoreBuilder({!r}, {!r})'.format(self.store_builders, self.mappings)\n+\n+\n+class MongoContentstoreBuilder(object):\n+    \"\"\"\n+    A builder class for a MongoContentStore.\n+    \"\"\"\n+    @contextmanager\n+    def build(self):\n+        \"\"\"\n+        A contextmanager that returns a MongoContentStore, and deletes its contents\n+        when the context closes.\n+        \"\"\"\n+        contentstore = MongoContentStore(\n+            db='contentstore{}'.format(random.randint(0, 10000)),\n+            collection='content',\n+            **COMMON_DOCSTORE_CONFIG\n+        )\n+\n+        try:\n+            yield contentstore\n+        finally:\n+            db = contentstore.fs_files.database\n+            db.connection.drop_database(db)\n+            db.connection.close()\n+\n+    def __repr__(self):\n+        return 'MongoContentstoreBuilder()'\n+\n+\n+MODULESTORE_SETUPS = (\n+    MongoModulestoreBuilder(),\n+    VersioningModulestoreBuilder(),\n+    MixedModulestoreBuilder([('draft', MongoModulestoreBuilder())]),\n+    MixedModulestoreBuilder([('split', VersioningModulestoreBuilder())]),\n+)\n+CONTENTSTORE_SETUPS = (MongoContentstoreBuilder(),)\n+COURSE_DATA_NAMES = ('toy', 'manual-testing-complete')\n+\n+@ddt.ddt\n+class CrossStoreXMLRoundtrip(CourseComparisonTest):","path":"common/lib/xmodule/xmodule/modulestore/tests/test_cross_modulestore_import_export.py","position":225,"original_position":216,"commit_id":"fc474e9408943939c88d908177c80271b549c784","original_commit_id":"2a97ea74120bba754e44987763eb90ec32bc6076","user":{"login":"sarina","id":1985317,"avatar_url":"https://avatars.githubusercontent.com/u/1985317?","gravatar_id":"136faf64ffa4486f0038265b06756f52","url":"https://api.github.com/users/sarina","html_url":"https://github.com/sarina","followers_url":"https://api.github.com/users/sarina/followers","following_url":"https://api.github.com/users/sarina/following{/other_user}","gists_url":"https://api.github.com/users/sarina/gists{/gist_id}","starred_url":"https://api.github.com/users/sarina/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sarina/subscriptions","organizations_url":"https://api.github.com/users/sarina/orgs","repos_url":"https://api.github.com/users/sarina/repos","events_url":"https://api.github.com/users/sarina/events{/privacy}","received_events_url":"https://api.github.com/users/sarina/received_events","type":"User","site_admin":false},"body":"docstring for this class","created_at":"2014-07-16T18:52:06Z","updated_at":"2014-07-16T18:52:06Z","html_url":"https://github.com/edx/edx-platform/pull/4445#discussion_r15019474","pull_request_url":"https://api.github.com/repos/edx/edx-platform/pulls/4445","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments/15019474"},"html":{"href":"https://github.com/edx/edx-platform/pull/4445#discussion_r15019474"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/4445"}}},"pull_request":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/4445","id":18468071,"html_url":"https://github.com/edx/edx-platform/pull/4445","diff_url":"https://github.com/edx/edx-platform/pull/4445.diff","patch_url":"https://github.com/edx/edx-platform/pull/4445.patch","issue_url":"https://api.github.com/repos/edx/edx-platform/issues/4445","number":4445,"state":"open","title":"Add tests for xml import/export between different modulestores","user":{"login":"cpennington","id":30236,"avatar_url":"https://avatars.githubusercontent.com/u/30236?","gravatar_id":"bf7434838ed52e9c1c4536d064451605","url":"https://api.github.com/users/cpennington","html_url":"https://github.com/cpennington","followers_url":"https://api.github.com/users/cpennington/followers","following_url":"https://api.github.com/users/cpennington/following{/other_user}","gists_url":"https://api.github.com/users/cpennington/gists{/gist_id}","starred_url":"https://api.github.com/users/cpennington/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cpennington/subscriptions","organizations_url":"https://api.github.com/users/cpennington/orgs","repos_url":"https://api.github.com/users/cpennington/repos","events_url":"https://api.github.com/users/cpennington/events{/privacy}","received_events_url":"https://api.github.com/users/cpennington/received_events","type":"User","site_admin":false},"body":null,"created_at":"2014-07-16T13:39:41Z","updated_at":"2014-07-16T18:52:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"623c86594ed8cf21006d8250f6e1f23b853051fc","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-platform/pulls/4445/commits","review_comments_url":"https://api.github.com/repos/edx/edx-platform/pulls/4445/comments","review_comment_url":"https://api.github.com/repos/edx/edx-platform/pulls/comments/{number}","comments_url":"https://api.github.com/repos/edx/edx-platform/issues/4445/comments","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/fc474e9408943939c88d908177c80271b549c784","head":{"label":"cpennington:cross-store-xml-import-export","ref":"cross-store-xml-import-export","sha":"fc474e9408943939c88d908177c80271b549c784","user":{"login":"cpennington","id":30236,"avatar_url":"https://avatars.githubusercontent.com/u/30236?","gravatar_id":"bf7434838ed52e9c1c4536d064451605","url":"https://api.github.com/users/cpennington","html_url":"https://github.com/cpennington","followers_url":"https://api.github.com/users/cpennington/followers","following_url":"https://api.github.com/users/cpennington/following{/other_user}","gists_url":"https://api.github.com/users/cpennington/gists{/gist_id}","starred_url":"https://api.github.com/users/cpennington/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cpennington/subscriptions","organizations_url":"https://api.github.com/users/cpennington/orgs","repos_url":"https://api.github.com/users/cpennington/repos","events_url":"https://api.github.com/users/cpennington/events{/privacy}","received_events_url":"https://api.github.com/users/cpennington/received_events","type":"User","site_admin":false},"repo":{"id":10688258,"name":"edx-platform","full_name":"cpennington/edx-platform","owner":{"login":"cpennington","id":30236,"avatar_url":"https://avatars.githubusercontent.com/u/30236?","gravatar_id":"bf7434838ed52e9c1c4536d064451605","url":"https://api.github.com/users/cpennington","html_url":"https://github.com/cpennington","followers_url":"https://api.github.com/users/cpennington/followers","following_url":"https://api.github.com/users/cpennington/following{/other_user}","gists_url":"https://api.github.com/users/cpennington/gists{/gist_id}","starred_url":"https://api.github.com/users/cpennington/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cpennington/subscriptions","organizations_url":"https://api.github.com/users/cpennington/orgs","repos_url":"https://api.github.com/users/cpennington/repos","events_url":"https://api.github.com/users/cpennington/events{/privacy}","received_events_url":"https://api.github.com/users/cpennington/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cpennington/edx-platform","description":"the edX learning management system (LMS) and course authoring tool, Studio","fork":true,"url":"https://api.github.com/repos/cpennington/edx-platform","forks_url":"https://api.github.com/repos/cpennington/edx-platform/forks","keys_url":"https://api.github.com/repos/cpennington/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cpennington/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cpennington/edx-platform/teams","hooks_url":"https://api.github.com/repos/cpennington/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/cpennington/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/cpennington/edx-platform/events","assignees_url":"https://api.github.com/repos/cpennington/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/cpennington/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/cpennington/edx-platform/tags","blobs_url":"https://api.github.com/repos/cpennington/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cpennington/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cpennington/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/cpennington/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cpennington/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/cpennington/edx-platform/languages","stargazers_url":"https://api.github.com/repos/cpennington/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/cpennington/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/cpennington/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/cpennington/edx-platform/subscription","commits_url":"https://api.github.com/repos/cpennington/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/cpennington/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/cpennington/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/cpennington/edx-platform/issues/comments/{number}","contents_url":"https://api.github.com/repos/cpennington/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/cpennington/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cpennington/edx-platform/merges","archive_url":"https://api.github.com/repos/cpennington/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cpennington/edx-platform/downloads","issues_url":"https://api.github.com/repos/cpennington/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/cpennington/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/cpennington/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/cpennington/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cpennington/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/cpennington/edx-platform/releases{/id}","created_at":"2013-06-14T12:13:54Z","updated_at":"2014-06-24T17:55:28Z","pushed_at":"2014-07-16T18:52:09Z","git_url":"git://github.com/cpennington/edx-platform.git","ssh_url":"git@github.com:cpennington/edx-platform.git","clone_url":"https://github.com/cpennington/edx-platform.git","svn_url":"https://github.com/cpennington/edx-platform","homepage":"http://code.edx.org/","size":247736,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"a71919efa7f50500e19245317ad11a2014f9cac1","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?","gravatar_id":"e1f6c6dc8772c47c0261cd5df2ed2814","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":10391073,"name":"edx-platform","full_name":"edx/edx-platform","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?","gravatar_id":"e1f6c6dc8772c47c0261cd5df2ed2814","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/edx-platform","description":"Open edX, the edX platform that powers http://www.edx.org","fork":false,"url":"https://api.github.com/repos/edx/edx-platform","forks_url":"https://api.github.com/repos/edx/edx-platform/forks","keys_url":"https://api.github.com/repos/edx/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-platform/teams","hooks_url":"https://api.github.com/repos/edx/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-platform/events","assignees_url":"https://api.github.com/repos/edx/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-platform/tags","blobs_url":"https://api.github.com/repos/edx/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-platform/languages","stargazers_url":"https://api.github.com/repos/edx/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-platform/subscription","commits_url":"https://api.github.com/repos/edx/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-platform/issues/comments/{number}","contents_url":"https://api.github.com/repos/edx/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-platform/merges","archive_url":"https://api.github.com/repos/edx/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-platform/downloads","issues_url":"https://api.github.com/repos/edx/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-platform/releases{/id}","created_at":"2013-05-30T20:20:38Z","updated_at":"2014-07-16T12:10:17Z","pushed_at":"2014-07-16T18:48:27Z","git_url":"git://github.com/edx/edx-platform.git","ssh_url":"git@github.com:edx/edx-platform.git","clone_url":"https://github.com/edx/edx-platform.git","svn_url":"https://github.com/edx/edx-platform","homepage":"http://code.edx.org/","size":1189673,"stargazers_count":1310,"watchers_count":1310,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":723,"mirror_url":null,"open_issues_count":154,"forks":723,"open_issues":154,"watchers":1310,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/4445"},"html":{"href":"https://github.com/edx/edx-platform/pull/4445"},"issue":{"href":"https://api.github.com/repos/edx/edx-platform/issues/4445"},"comments":{"href":"https://api.github.com/repos/edx/edx-platform/issues/4445/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/4445/comments"},"review_comment":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/4445/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-platform/statuses/fc474e9408943939c88d908177c80271b549c784"}}}}