{"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/comments/71763697","id":71763697,"diff_hunk":"@@ -0,0 +1,136 @@\n+\"\"\" Tests for DiscussionXBLock\"\"\"\n+import ddt\n+import mock\n+from nose.plugins.attrib import attr\n+from unittest import TestCase\n+\n+from safe_lxml import etree\n+\n+from openedx.core.lib.xblock_builtin.xblock_discussion.xblock_discussion import DiscussionXBlock\n+from xblock.field_data import DictFieldData\n+from xblock.fields import ScopeIds, UNIQUE_ID, NO_CACHE_VALUE\n+from xblock.runtime import Runtime\n+\n+\n+@attr('shard2')\n+@ddt.ddt\n+class DiscussionXBlockImportExportTests(TestCase):\n+    \"\"\"\n+    Import and export tests\n+    \"\"\"\n+    DISCUSSION_XBLOCK_LOCATION = \"openedx.core.lib.xblock_builtin.xblock_discussion.xblock_discussion.DiscussionXBlock\"","path":"openedx/core/lib/xblock_builtin/xblock_discussion/tests.py","position":21,"original_position":21,"commit_id":"67cb7fe7115dab3d181f33a3e03cf33b6f83b2f5","original_commit_id":"67cb7fe7115dab3d181f33a3e03cf33b6f83b2f5","user":{"login":"bradenmacdonald","id":945577,"avatar_url":"https://avatars.githubusercontent.com/u/945577?v=3","gravatar_id":"","url":"https://api.github.com/users/bradenmacdonald","html_url":"https://github.com/bradenmacdonald","followers_url":"https://api.github.com/users/bradenmacdonald/followers","following_url":"https://api.github.com/users/bradenmacdonald/following{/other_user}","gists_url":"https://api.github.com/users/bradenmacdonald/gists{/gist_id}","starred_url":"https://api.github.com/users/bradenmacdonald/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bradenmacdonald/subscriptions","organizations_url":"https://api.github.com/users/bradenmacdonald/orgs","repos_url":"https://api.github.com/users/bradenmacdonald/repos","events_url":"https://api.github.com/users/bradenmacdonald/events{/privacy}","received_events_url":"https://api.github.com/users/bradenmacdonald/received_events","type":"User","site_admin":false},"body":"Nit: I think you can also just `from ... import DiscussionXBlock` and then use decorators like `@patch.object(DiscussionXBlock, 'load_definition_xml', ...)` which I think is cleaner.","created_at":"2016-07-21T18:45:13Z","updated_at":"2016-07-21T18:45:13Z","html_url":"https://github.com/edx/edx-platform/pull/13056#discussion_r71763697","pull_request_url":"https://api.github.com/repos/edx/edx-platform/pulls/13056","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments/71763697"},"html":{"href":"https://github.com/edx/edx-platform/pull/13056#discussion_r71763697"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/13056"}}},"pull_request":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/13056","id":78307359,"html_url":"https://github.com/edx/edx-platform/pull/13056","diff_url":"https://github.com/edx/edx-platform/pull/13056.diff","patch_url":"https://github.com/edx/edx-platform/pull/13056.patch","issue_url":"https://api.github.com/repos/edx/edx-platform/issues/13056","number":13056,"state":"open","locked":false,"title":"[TNL-5001] Import-export issues when importing legacy discussion OLX format","user":{"login":"e-kolpakov","id":3330048,"avatar_url":"https://avatars.githubusercontent.com/u/3330048?v=3","gravatar_id":"","url":"https://api.github.com/users/e-kolpakov","html_url":"https://github.com/e-kolpakov","followers_url":"https://api.github.com/users/e-kolpakov/followers","following_url":"https://api.github.com/users/e-kolpakov/following{/other_user}","gists_url":"https://api.github.com/users/e-kolpakov/gists{/gist_id}","starred_url":"https://api.github.com/users/e-kolpakov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/e-kolpakov/subscriptions","organizations_url":"https://api.github.com/users/e-kolpakov/orgs","repos_url":"https://api.github.com/users/e-kolpakov/repos","events_url":"https://api.github.com/users/e-kolpakov/events{/privacy}","received_events_url":"https://api.github.com/users/e-kolpakov/received_events","type":"User","site_admin":false},"body":"**Description:** This PR is aimed to fix problems with discussions when courses are imported over an existing course.\r\n\r\n**JIRA:** [TNL-5001](https://openedx.atlassian.net/browse/TNL-5001)\r\n**Sandbox:** [LMS](http://pr13056.sandbox.opencraft.hosting/), [Studio](http://studio-pr13056.sandbox.opencraft.hosting/)\r\n\r\n**Merge deadline:** AFAIK, one of the affected courses have a [launch this Thursday](https://openedx.atlassian.net/browse/TNL-5001?focusedCommentId=202846&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-202846) (07/21, today), so ASAP.\r\n\r\n**Testing instructions:**\r\n1. Obtain legacy (pre7/13/2016) course export and new course export of the same course (TNL-5001 contains examples: [old](https://openedx.atlassian.net/secure/attachment/36803/discussion-export-xblock.tar.gz), [new](https://tasks.opencraft.com/secure/attachment/11649/discussion-export-xblock.tar.gz))\r\n2. Use current master\r\n3. Import \"new\" course OLX into any course.\r\n4. The course contains \"Custom Topic Unit\" (ID: 9d307ad9eef54cac8774a4ea4211495b) - open it in Studio. \r\n5. Note that this unit contains discussion component. Discussion ID will be c37f098c47b718877ddd09e5d705feaff9ae9b69, category and target will be \"Custom Topic\" and \"Custom Subcategory\"\r\n6. Make a post in the forums\r\n7. Import \"old\" course OLX over the existing course (same one)\r\n8. The course contains the same \"Custom Topic Unit\" - open it in studio\r\n9. Note that this unit contains discussion component. Discussion ID will be different, category and target will be reset to default\r\n10. In LMS the post made in step 4 is missing.\r\n11. Switch to current branch.\r\n12. Import \"old\" course OLX over the existing course (same one)\r\n13. Open \"Custom Topic Unit\" in studio; note that discussion ID is still different (but same as in step 9), but category and topic are restored.\r\n14. In LMS post will still be missing; create new one.\r\n15. Export the course\r\n16. Import the course over the exiting course (same one)\r\n17. Note discussion ID, category and topic are the same; post from step 14 is visible in LMS\r\n18. Import \"old\" course OLX into existing course (same one).\r\n19. Note discussion ID, category and topic are the same; post from step 14 is visible in LMS\r\n\r\n\r\n**Author concerns:** It looks like problem with missing discussion threads exists because `discussion_id` was forced to be exported - later, when course is imported over *different* course with existing discussions, exported value would be used instead of generated one (which is stable, but depends on course ID) and cause DiscussionXBlock to have different discussion_id.\r\n\r\nAs a result, all course exports made between #12582 and this PR will be poisonous forever, unless we take one step further and force **ignoring** discussion_ids coming from the OLX (it is not implemented in this PR as it might cause other kinds of trouble in future).","created_at":"2016-07-21T12:31:08Z","updated_at":"2016-07-21T18:45:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"64a6b8a5e620832d81fd14ab4185621635465d5d","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-platform/pulls/13056/commits","review_comments_url":"https://api.github.com/repos/edx/edx-platform/pulls/13056/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/13056/comments","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/67cb7fe7115dab3d181f33a3e03cf33b6f83b2f5","head":{"label":"open-craft:ekolpakov/fix_legacy_discussion_import","ref":"ekolpakov/fix_legacy_discussion_import","sha":"67cb7fe7115dab3d181f33a3e03cf33b6f83b2f5","user":{"login":"open-craft","id":7414786,"avatar_url":"https://avatars.githubusercontent.com/u/7414786?v=3","gravatar_id":"","url":"https://api.github.com/users/open-craft","html_url":"https://github.com/open-craft","followers_url":"https://api.github.com/users/open-craft/followers","following_url":"https://api.github.com/users/open-craft/following{/other_user}","gists_url":"https://api.github.com/users/open-craft/gists{/gist_id}","starred_url":"https://api.github.com/users/open-craft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/open-craft/subscriptions","organizations_url":"https://api.github.com/users/open-craft/orgs","repos_url":"https://api.github.com/users/open-craft/repos","events_url":"https://api.github.com/users/open-craft/events{/privacy}","received_events_url":"https://api.github.com/users/open-craft/received_events","type":"Organization","site_admin":false},"repo":{"id":19940883,"name":"edx-platform","full_name":"open-craft/edx-platform","owner":{"login":"open-craft","id":7414786,"avatar_url":"https://avatars.githubusercontent.com/u/7414786?v=3","gravatar_id":"","url":"https://api.github.com/users/open-craft","html_url":"https://github.com/open-craft","followers_url":"https://api.github.com/users/open-craft/followers","following_url":"https://api.github.com/users/open-craft/following{/other_user}","gists_url":"https://api.github.com/users/open-craft/gists{/gist_id}","starred_url":"https://api.github.com/users/open-craft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/open-craft/subscriptions","organizations_url":"https://api.github.com/users/open-craft/orgs","repos_url":"https://api.github.com/users/open-craft/repos","events_url":"https://api.github.com/users/open-craft/events{/privacy}","received_events_url":"https://api.github.com/users/open-craft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/open-craft/edx-platform","description":"the edX learning management system (LMS) and course authoring tool, Studio","fork":true,"url":"https://api.github.com/repos/open-craft/edx-platform","forks_url":"https://api.github.com/repos/open-craft/edx-platform/forks","keys_url":"https://api.github.com/repos/open-craft/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/open-craft/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/open-craft/edx-platform/teams","hooks_url":"https://api.github.com/repos/open-craft/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/open-craft/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/open-craft/edx-platform/events","assignees_url":"https://api.github.com/repos/open-craft/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/open-craft/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/open-craft/edx-platform/tags","blobs_url":"https://api.github.com/repos/open-craft/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/open-craft/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/open-craft/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/open-craft/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/open-craft/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/open-craft/edx-platform/languages","stargazers_url":"https://api.github.com/repos/open-craft/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/open-craft/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/open-craft/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/open-craft/edx-platform/subscription","commits_url":"https://api.github.com/repos/open-craft/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/open-craft/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/open-craft/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/open-craft/edx-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/open-craft/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/open-craft/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/open-craft/edx-platform/merges","archive_url":"https://api.github.com/repos/open-craft/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/open-craft/edx-platform/downloads","issues_url":"https://api.github.com/repos/open-craft/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/open-craft/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/open-craft/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/open-craft/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/open-craft/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/open-craft/edx-platform/releases{/id}","deployments_url":"https://api.github.com/repos/open-craft/edx-platform/deployments","created_at":"2014-05-19T12:28:25Z","updated_at":"2016-02-04T22:30:58Z","pushed_at":"2016-07-21T14:45:37Z","git_url":"git://github.com/open-craft/edx-platform.git","ssh_url":"git@github.com:open-craft/edx-platform.git","clone_url":"https://github.com/open-craft/edx-platform.git","svn_url":"https://github.com/open-craft/edx-platform","homepage":"http://code.edx.org/","size":659134,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":1,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"67e15e22e6b821a9c96ee091bc035bd682c128b9","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","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=3","gravatar_id":"","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":"The Open edX platform, the software that powers edX!","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}","deployments_url":"https://api.github.com/repos/edx/edx-platform/deployments","created_at":"2013-05-30T20:20:38Z","updated_at":"2016-07-21T16:21:40Z","pushed_at":"2016-07-21T18:43:41Z","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://open.edx.org/","size":795373,"stargazers_count":2679,"watchers_count":2679,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1616,"mirror_url":null,"open_issues_count":192,"forks":1616,"open_issues":192,"watchers":2679,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/13056"},"html":{"href":"https://github.com/edx/edx-platform/pull/13056"},"issue":{"href":"https://api.github.com/repos/edx/edx-platform/issues/13056"},"comments":{"href":"https://api.github.com/repos/edx/edx-platform/issues/13056/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/13056/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/13056/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-platform/statuses/67cb7fe7115dab3d181f33a3e03cf33b6f83b2f5"}}}}
{"actor":{"display_login":"bradenmacdonald"}}