GitHub PullRequestReviewCommentEvent at 2014-08-15 20:21:43
Repository: edx-platform
Actor: cpennington
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/comments/16313416","id":16313416,"diff_hunk":"@@ -199,6 +202,109 @@ def test_no_such_course(self):\n             assert_false(self.draft_store.has_course(mix_cased))\n             assert_false(self.draft_store.has_course(mix_cased, ignore_case=True))\n \n+    def _make_asset_metadata(self, asset_loc, filename):\n+        return AssetMetadata(asset_loc, filename, internal_name='EKMND332DDBK', filepath='pictures/historical',\n+                             locked=False, edited_by='CourseAuthor', edited_on=datetime.now(), curr_version='v1.0', prev_version='v0.95')\n+\n+    def _setup_asset_metadata(self):\n+        \"\"\"\n+        Set up a quantity of test asset metadata for testing purposes.\n+        \"\"\"\n+        ASSET_FIELDS = ('filename', 'internal_name', 'filepath', 'locked', 'edited_by', 'edited_on', 'curr_version', 'prev_version')\n+        ASSET1_VALS = ('pic1.jpg', 'EKMND332DDBK', 'pix/archive', False, 'Author1', datetime.now(), '14', '13')\n+        ASSET2_VALS = ('shout.ogg', 'KFMDONSKF39K', 'sounds', True, 'Author1', datetime.now(), '1', None)\n+        ASSET3_VALS = ('code.tgz', 'ZZB2333YBDMW', 'exercises/14', False, 'Author2', datetime.now(), 'AB', 'AA')\n+        ASSET4_VALS = ('dog.png', 'PUPY4242X', 'pictures/animals', True, 'Author3', datetime.now(), 5, 4)\n+        ASSET5_VALS = ('not_here.txt', 'JJJCCC747', '/dev/null', False, 'Author4', datetime.now(), 50, 49)\n+\n+        ASSET1 = dict(zip(ASSET_FIELDS, ASSET1_VALS))\n+        ASSET2 = dict(zip(ASSET_FIELDS, ASSET2_VALS))\n+        ASSET3 = dict(zip(ASSET_FIELDS, ASSET3_VALS))\n+        ASSET4 = dict(zip(ASSET_FIELDS, ASSET4_VALS))\n+        NON_EXISTENT_ASSET = dict(zip(ASSET_FIELDS, ASSET5_VALS))\n+\n+        courses = self.draft_store.get_courses()\n+        self.course1 = courses[0]\n+        self.course2 = courses[1]\n+\n+        asset1_loc = self.course1.id.make_asset_key('asset', ASSET1['filename'])\n+        asset2_loc = self.course1.id.make_asset_key('asset', ASSET2['filename'])\n+        asset3_loc = self.course2.id.make_asset_key('asset', ASSET3['filename'])\n+        asset4_loc = self.course2.id.make_asset_key('asset', ASSET4['filename'])\n+        asset5_loc = self.course2.id.make_asset_key('asset', NON_EXISTENT_ASSET['filename'])\n+\n+        self.asset1_md = AssetMetadata(asset1_loc, asset1_loc.path, **ASSET1)\n+        self.asset2_md = AssetMetadata(asset2_loc, asset2_loc.path, **ASSET2)\n+        self.asset3_md = AssetMetadata(asset3_loc, asset3_loc.path, **ASSET3)\n+        self.asset4_md = AssetMetadata(asset4_loc, asset4_loc.path, **ASSET4)\n+        self.asset5_md = AssetMetadata(asset5_loc, asset5_loc.path, **NON_EXISTENT_ASSET)\n+\n+        assert_true(self.draft_store.save_asset_metadata(self.course1.id, self.asset1_md))\n+        assert_true(self.draft_store.save_asset_metadata(self.course1.id, self.asset2_md))\n+        assert_true(self.draft_store.save_asset_metadata(self.course2.id, self.asset3_md))\n+        assert_true(self.draft_store.save_asset_metadata(self.course2.id, self.asset4_md))\n+        # asset5 is not saved on purpose!\n+\n+    def _teardown_asset_metadata(self):\n+        self.draft_store.delete_all_asset_metadata(self.course1.id)\n+        self.draft_store.delete_all_asset_metadata(self.course2.id)\n+\n+    def test_asset_metadata_save_one_and_confirm(self):\n+        courses = self.draft_store.get_courses()\n+        course = courses[0]\n+        ASSET_FILENAME = 'burnside.jpg'\n+        new_asset_loc = course.id.make_asset_key('asset', ASSET_FILENAME)\n+        # Confirm that the asset's metadata is not present.\n+        assert_is_none(self.draft_store.find_asset_metadata(course.id, new_asset_loc))\n+        # Save the asset's metadata.\n+        new_asset_md = self._make_asset_metadata(new_asset_loc, ASSET_FILENAME)\n+        assert_true(self.draft_store.save_asset_metadata(course.id, new_asset_md))\n+        # Find the asset's metadata and confirm it's the same.\n+        found_asset_md = self.draft_store.find_asset_metadata(course.id, new_asset_loc)\n+        assert_not_none(found_asset_md)\n+        assert_equals(new_asset_md, found_asset_md)\n+        # Confirm that only one asset's metadata exists.\n+        assert_equals(len(self.draft_store.get_all_asset_metadata(course.id)), 1)\n+        # Delete all metadata and confirm it's gone.\n+        self.draft_store.delete_all_asset_metadata(course.id)\n+        assert_equals(len(self.draft_store.get_all_asset_metadata(course.id)), 0)\n+\n+    def test_asset_metadata_delete_all_without_creation(self):\n+        courses = self.draft_store.get_courses()\n+        course = courses[0]\n+        # Confirm that no asset metadata exists.\n+        assert_equals(len(self.draft_store.get_all_asset_metadata(course.id)), 0)\n+        # Now delete the non-existent metadata.\n+        self.draft_store.delete_all_asset_metadata(course.id)\n+        assert_equals(len(self.draft_store.get_all_asset_metadata(course.id)), 0)\n+\n+    def test_asset_metadata_save_many_and_delete_one(self):\n+        self._setup_asset_metadata()\n+        # Make sure there's two assets.\n+        assert_equals(len(self.draft_store.get_all_asset_metadata(self.course1.id)), 2)\n+        # Delete one of the assets.\n+        assert_equals(self.draft_store.delete_asset_metadata(self.course1.id, self.asset1_md.asset_id), 1)\n+        # Attempt to delete an asset that doesn't exist.\n+        assert_equals(self.draft_store.delete_asset_metadata(self.course1.id, self.asset5_md.asset_id), 0)\n+        # Attempt to delete an asset from the wrong course.\n+        assert_equals(self.draft_store.delete_asset_metadata(self.course2.id, self.asset2_md.asset_id), 0)","path":"common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py","position":113,"original_position":113,"commit_id":"4276ea00120915b890b8743eea84cf0ce1f75a7f","original_commit_id":"4276ea00120915b890b8743eea84cf0ce1f75a7f","user":{"login":"cpennington","id":30236,"avatar_url":"https://avatars.githubusercontent.com/u/30236?v=2","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":"Prefer `self.assertEquals` and that family of methods.","created_at":"2014-08-15T20:21:43Z","updated_at":"2014-08-15T20:21:43Z","html_url":"https://github.com/edx/edx-platform/pull/4854#discussion_r16313416","pull_request_url":"https://api.github.com/repos/edx/edx-platform/pulls/4854","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments/16313416"},"html":{"href":"https://github.com/edx/edx-platform/pull/4854#discussion_r16313416"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/4854"}}},"pull_request":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/4854","id":19851023,"html_url":"https://github.com/edx/edx-platform/pull/4854","diff_url":"https://github.com/edx/edx-platform/pull/4854.diff","patch_url":"https://github.com/edx/edx-platform/pull/4854.patch","issue_url":"https://api.github.com/repos/edx/edx-platform/issues/4854","number":4854,"state":"open","locked":false,"title":"Phase 1 of adding asset metadata saving to old Mongo","user":{"login":"doctoryes","id":7285237,"avatar_url":"https://avatars.githubusercontent.com/u/7285237?v=2","gravatar_id":"575476542e13bff12a11e64d62e289a2","url":"https://api.github.com/users/doctoryes","html_url":"https://github.com/doctoryes","followers_url":"https://api.github.com/users/doctoryes/followers","following_url":"https://api.github.com/users/doctoryes/following{/other_user}","gists_url":"https://api.github.com/users/doctoryes/gists{/gist_id}","starred_url":"https://api.github.com/users/doctoryes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/doctoryes/subscriptions","organizations_url":"https://api.github.com/users/doctoryes/orgs","repos_url":"https://api.github.com/users/doctoryes/repos","events_url":"https://api.github.com/users/doctoryes/events{/privacy}","received_events_url":"https://api.github.com/users/doctoryes/received_events","type":"User","site_admin":false},"body":"@dmitchell @cpennington Here's the first phase of my work. Look at the tests to see what is implemented and what isn't yet.","created_at":"2014-08-15T15:48:57Z","updated_at":"2014-08-15T20:21:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a0c902ae7839fb0e9b0ca10c85078560c4f87fe4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-platform/pulls/4854/commits","review_comments_url":"https://api.github.com/repos/edx/edx-platform/pulls/4854/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/4854/comments","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/4276ea00120915b890b8743eea84cf0ce1f75a7f","head":{"label":"edx:jeskew/assetstore_modulestore_work","ref":"jeskew/assetstore_modulestore_work","sha":"4276ea00120915b890b8743eea84cf0ce1f75a7f","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=2","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?v=2","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://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-08-15T20:21:15Z","pushed_at":"2014-08-15T20:21:33Z","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://openedx.org/","size":1549542,"stargazers_count":1366,"watchers_count":1366,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":762,"mirror_url":null,"open_issues_count":104,"forks":762,"open_issues":104,"watchers":1366,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"3cd4610b5a1daf580ebf66ba740e1da3464b2e71","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=2","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?v=2","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://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-08-15T20:21:15Z","pushed_at":"2014-08-15T20:21:33Z","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://openedx.org/","size":1549542,"stargazers_count":1366,"watchers_count":1366,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":762,"mirror_url":null,"open_issues_count":104,"forks":762,"open_issues":104,"watchers":1366,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/4854"},"html":{"href":"https://github.com/edx/edx-platform/pull/4854"},"issue":{"href":"https://api.github.com/repos/edx/edx-platform/issues/4854"},"comments":{"href":"https://api.github.com/repos/edx/edx-platform/issues/4854/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/4854/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/4854/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-platform/statuses/4276ea00120915b890b8743eea84cf0ce1f75a7f"}}}}