{"action":"created","comment":{"url":"https://api.github.com/repos/Connexions/cnx-authoring/pulls/comments/41528046","id":41528046,"diff_hunk":"@@ -22,6 +22,124 @@ class ModelUtilitiesTestCase(unittest.TestCase):\n     maxDiff = None\n \n     @httpretty.activate\n+    def test_revise_content(self):\n+        archive_url = \"http://example.com\"\n+        settings = {'archive.url': archive_url}\n+\n+        from ..models import DEFAULT_LICENSE\n+        content_id = 'uuid'\n+        content_title = 'title'\n+        archived_data = {\n+            'id': content_id,\n+            'version': '1',\n+            'license': DEFAULT_LICENSE.__json__(),\n+            'title': content_title,\n+            'authors': [{}, {}, {}],\n+            'maintainers': [{}, {}, {}],\n+            'publishers': [{}, {}, {}],\n+            'licensors': [{}, {}, {}],\n+            'translators': [{}, {}, {}],\n+            'editors': [{}, {}, {}],\n+            'illustrators': [{}, {}, {}],\n+            'created': 'awhile ago',\n+            'revised': 'just now',\n+            }\n+\n+        url = \"{}/contents/{}.json\".format(archive_url, content_id)\n+        faux_response_body = json.dumps(archived_data)\n+        httpretty.register_uri(httpretty.GET, url,\n+                               body=faux_response_body, status=200)\n+\n+        request = pyramid_testing.DummyRequest()\n+        request.registry = mock.Mock()\n+        request.registry.settings = settings\n+\n+        from ..models import revise_content\n+        document_as_dict = revise_content(request, id=content_id)\n+\n+        expected = archived_data.copy()\n+        role_attrs = ('authors', 'licensors', 'editors', 'illustrators',\n+                      'maintainers', 'publishers', 'translators',)\n+        for role_attr in  role_attrs:\n+            expected[role_attr] = [{'has_accepted':True},{'has_accepted':True},{'has_accepted':True}]\n+        expected['revised'] = None\n+        self.assertEqual(document_as_dict, expected)\n+\n+    @httpretty.activate\n+    def test_revise_content_upgrades_license(self):\n+        archive_url = \"http://example.com\"\n+        settings = {'archive.url': archive_url}\n+\n+        from ..models import LICENSES, DEFAULT_LICENSE\n+        license = [l for l in LICENSES if l.url.find('by/3') >= 0][0]\n+\n+        content_id = 'uuid'\n+        content_title = 'title'\n+        archived_data = {\n+            'id': content_id,\n+            'version': '1',\n+            'license': license.__json__(),\n+            'title': content_title,\n+            'publishers': [{}, {}, {}],\n+            }\n+\n+        url = \"{}/contents/{}.json\".format(archive_url, content_id)\n+        faux_response_body = json.dumps(archived_data)\n+        httpretty.register_uri(httpretty.GET, url,\n+                               body=faux_response_body, status=200)\n+\n+        request = pyramid_testing.DummyRequest()\n+        request.registry = mock.Mock()\n+        request.registry.settings = settings\n+\n+        from ..models import revise_content\n+        document_as_dict = revise_content(request, id=content_id)\n+\n+        self.assertEqual(document_as_dict['license']['version'],\n+                         DEFAULT_LICENSE.version)\n+        self.assertEqual(document_as_dict['license']['upgraded'],True)\n+\n+","path":"cnxauthoring/tests/test_models.py","position":81,"original_position":81,"commit_id":"654ca9d1d5b286d504b0082392c88f9bc8b66520","original_commit_id":"654ca9d1d5b286d504b0082392c88f9bc8b66520","user":{"login":"pumazi","id":168470,"avatar_url":"https://avatars.githubusercontent.com/u/168470?v=3","gravatar_id":"","url":"https://api.github.com/users/pumazi","html_url":"https://github.com/pumazi","followers_url":"https://api.github.com/users/pumazi/followers","following_url":"https://api.github.com/users/pumazi/following{/other_user}","gists_url":"https://api.github.com/users/pumazi/gists{/gist_id}","starred_url":"https://api.github.com/users/pumazi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pumazi/subscriptions","organizations_url":"https://api.github.com/users/pumazi/orgs","repos_url":"https://api.github.com/users/pumazi/repos","events_url":"https://api.github.com/users/pumazi/events{/privacy}","received_events_url":"https://api.github.com/users/pumazi/received_events","type":"User","site_admin":false},"body":"pep8 \"too many blank lines (2)\"\r\n\r\nOnly use two lines between function and class definitions.","created_at":"2015-10-08T15:27:46Z","updated_at":"2015-10-08T15:27:46Z","html_url":"https://github.com/Connexions/cnx-authoring/pull/237#discussion_r41528046","pull_request_url":"https://api.github.com/repos/Connexions/cnx-authoring/pulls/237","_links":{"self":{"href":"https://api.github.com/repos/Connexions/cnx-authoring/pulls/comments/41528046"},"html":{"href":"https://github.com/Connexions/cnx-authoring/pull/237#discussion_r41528046"},"pull_request":{"href":"https://api.github.com/repos/Connexions/cnx-authoring/pulls/237"}}},"pull_request":{"url":"https://api.github.com/repos/Connexions/cnx-authoring/pulls/237","id":47079205,"html_url":"https://github.com/Connexions/cnx-authoring/pull/237","diff_url":"https://github.com/Connexions/cnx-authoring/pull/237.diff","patch_url":"https://github.com/Connexions/cnx-authoring/pull/237.patch","issue_url":"https://api.github.com/repos/Connexions/cnx-authoring/issues/237","number":237,"state":"open","locked":false,"title":"Upgrade license on revision, as well","user":{"login":"reedstrm","id":253212,"avatar_url":"https://avatars.githubusercontent.com/u/253212?v=3","gravatar_id":"","url":"https://api.github.com/users/reedstrm","html_url":"https://github.com/reedstrm","followers_url":"https://api.github.com/users/reedstrm/followers","following_url":"https://api.github.com/users/reedstrm/following{/other_user}","gists_url":"https://api.github.com/users/reedstrm/gists{/gist_id}","starred_url":"https://api.github.com/users/reedstrm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reedstrm/subscriptions","organizations_url":"https://api.github.com/users/reedstrm/orgs","repos_url":"https://api.github.com/users/reedstrm/repos","events_url":"https://api.github.com/users/reedstrm/events{/privacy}","received_events_url":"https://api.github.com/users/reedstrm/received_events","type":"User","site_admin":false},"body":"Currently, we will checkout code to authoring with a license that is not valid for publication. This leads to errors on attempting to publish. This upgrades the license, and tags it as upgraded so that webview can DTRT in the UI (emphasize the upgrade in the accept license dialog, probably) ","created_at":"2015-10-07T20:41:43Z","updated_at":"2015-10-08T15:27:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2443ea6f99dff27b1872edd58ec88851fd487082","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Connexions/cnx-authoring/pulls/237/commits","review_comments_url":"https://api.github.com/repos/Connexions/cnx-authoring/pulls/237/comments","review_comment_url":"https://api.github.com/repos/Connexions/cnx-authoring/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Connexions/cnx-authoring/issues/237/comments","statuses_url":"https://api.github.com/repos/Connexions/cnx-authoring/statuses/654ca9d1d5b286d504b0082392c88f9bc8b66520","head":{"label":"Connexions:upgrade-license-on-revision","ref":"upgrade-license-on-revision","sha":"654ca9d1d5b286d504b0082392c88f9bc8b66520","user":{"login":"Connexions","id":772455,"avatar_url":"https://avatars.githubusercontent.com/u/772455?v=3","gravatar_id":"","url":"https://api.github.com/users/Connexions","html_url":"https://github.com/Connexions","followers_url":"https://api.github.com/users/Connexions/followers","following_url":"https://api.github.com/users/Connexions/following{/other_user}","gists_url":"https://api.github.com/users/Connexions/gists{/gist_id}","starred_url":"https://api.github.com/users/Connexions/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Connexions/subscriptions","organizations_url":"https://api.github.com/users/Connexions/orgs","repos_url":"https://api.github.com/users/Connexions/repos","events_url":"https://api.github.com/users/Connexions/events{/privacy}","received_events_url":"https://api.github.com/users/Connexions/received_events","type":"Organization","site_admin":false},"repo":{"id":17671906,"name":"cnx-authoring","full_name":"Connexions/cnx-authoring","owner":{"login":"Connexions","id":772455,"avatar_url":"https://avatars.githubusercontent.com/u/772455?v=3","gravatar_id":"","url":"https://api.github.com/users/Connexions","html_url":"https://github.com/Connexions","followers_url":"https://api.github.com/users/Connexions/followers","following_url":"https://api.github.com/users/Connexions/following{/other_user}","gists_url":"https://api.github.com/users/Connexions/gists{/gist_id}","starred_url":"https://api.github.com/users/Connexions/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Connexions/subscriptions","organizations_url":"https://api.github.com/users/Connexions/orgs","repos_url":"https://api.github.com/users/Connexions/repos","events_url":"https://api.github.com/users/Connexions/events{/privacy}","received_events_url":"https://api.github.com/users/Connexions/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Connexions/cnx-authoring","description":"figure","fork":false,"url":"https://api.github.com/repos/Connexions/cnx-authoring","forks_url":"https://api.github.com/repos/Connexions/cnx-authoring/forks","keys_url":"https://api.github.com/repos/Connexions/cnx-authoring/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Connexions/cnx-authoring/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Connexions/cnx-authoring/teams","hooks_url":"https://api.github.com/repos/Connexions/cnx-authoring/hooks","issue_events_url":"https://api.github.com/repos/Connexions/cnx-authoring/issues/events{/number}","events_url":"https://api.github.com/repos/Connexions/cnx-authoring/events","assignees_url":"https://api.github.com/repos/Connexions/cnx-authoring/assignees{/user}","branches_url":"https://api.github.com/repos/Connexions/cnx-authoring/branches{/branch}","tags_url":"https://api.github.com/repos/Connexions/cnx-authoring/tags","blobs_url":"https://api.github.com/repos/Connexions/cnx-authoring/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Connexions/cnx-authoring/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Connexions/cnx-authoring/git/refs{/sha}","trees_url":"https://api.github.com/repos/Connexions/cnx-authoring/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Connexions/cnx-authoring/statuses/{sha}","languages_url":"https://api.github.com/repos/Connexions/cnx-authoring/languages","stargazers_url":"https://api.github.com/repos/Connexions/cnx-authoring/stargazers","contributors_url":"https://api.github.com/repos/Connexions/cnx-authoring/contributors","subscribers_url":"https://api.github.com/repos/Connexions/cnx-authoring/subscribers","subscription_url":"https://api.github.com/repos/Connexions/cnx-authoring/subscription","commits_url":"https://api.github.com/repos/Connexions/cnx-authoring/commits{/sha}","git_commits_url":"https://api.github.com/repos/Connexions/cnx-authoring/git/commits{/sha}","comments_url":"https://api.github.com/repos/Connexions/cnx-authoring/comments{/number}","issue_comment_url":"https://api.github.com/repos/Connexions/cnx-authoring/issues/comments{/number}","contents_url":"https://api.github.com/repos/Connexions/cnx-authoring/contents/{+path}","compare_url":"https://api.github.com/repos/Connexions/cnx-authoring/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Connexions/cnx-authoring/merges","archive_url":"https://api.github.com/repos/Connexions/cnx-authoring/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Connexions/cnx-authoring/downloads","issues_url":"https://api.github.com/repos/Connexions/cnx-authoring/issues{/number}","pulls_url":"https://api.github.com/repos/Connexions/cnx-authoring/pulls{/number}","milestones_url":"https://api.github.com/repos/Connexions/cnx-authoring/milestones{/number}","notifications_url":"https://api.github.com/repos/Connexions/cnx-authoring/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Connexions/cnx-authoring/labels{/name}","releases_url":"https://api.github.com/repos/Connexions/cnx-authoring/releases{/id}","created_at":"2014-03-12T15:29:22Z","updated_at":"2015-04-28T20:56:36Z","pushed_at":"2015-10-07T20:41:44Z","git_url":"git://github.com/Connexions/cnx-authoring.git","ssh_url":"git@github.com:Connexions/cnx-authoring.git","clone_url":"https://github.com/Connexions/cnx-authoring.git","svn_url":"https://github.com/Connexions/cnx-authoring","homepage":"","size":2617,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":11,"forks":3,"open_issues":11,"watchers":1,"default_branch":"master"}},"base":{"label":"Connexions:master","ref":"master","sha":"725ccd1cdcbccb5f47854d121838c7a03bf3de64","user":{"login":"Connexions","id":772455,"avatar_url":"https://avatars.githubusercontent.com/u/772455?v=3","gravatar_id":"","url":"https://api.github.com/users/Connexions","html_url":"https://github.com/Connexions","followers_url":"https://api.github.com/users/Connexions/followers","following_url":"https://api.github.com/users/Connexions/following{/other_user}","gists_url":"https://api.github.com/users/Connexions/gists{/gist_id}","starred_url":"https://api.github.com/users/Connexions/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Connexions/subscriptions","organizations_url":"https://api.github.com/users/Connexions/orgs","repos_url":"https://api.github.com/users/Connexions/repos","events_url":"https://api.github.com/users/Connexions/events{/privacy}","received_events_url":"https://api.github.com/users/Connexions/received_events","type":"Organization","site_admin":false},"repo":{"id":17671906,"name":"cnx-authoring","full_name":"Connexions/cnx-authoring","owner":{"login":"Connexions","id":772455,"avatar_url":"https://avatars.githubusercontent.com/u/772455?v=3","gravatar_id":"","url":"https://api.github.com/users/Connexions","html_url":"https://github.com/Connexions","followers_url":"https://api.github.com/users/Connexions/followers","following_url":"https://api.github.com/users/Connexions/following{/other_user}","gists_url":"https://api.github.com/users/Connexions/gists{/gist_id}","starred_url":"https://api.github.com/users/Connexions/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Connexions/subscriptions","organizations_url":"https://api.github.com/users/Connexions/orgs","repos_url":"https://api.github.com/users/Connexions/repos","events_url":"https://api.github.com/users/Connexions/events{/privacy}","received_events_url":"https://api.github.com/users/Connexions/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Connexions/cnx-authoring","description":"figure","fork":false,"url":"https://api.github.com/repos/Connexions/cnx-authoring","forks_url":"https://api.github.com/repos/Connexions/cnx-authoring/forks","keys_url":"https://api.github.com/repos/Connexions/cnx-authoring/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Connexions/cnx-authoring/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Connexions/cnx-authoring/teams","hooks_url":"https://api.github.com/repos/Connexions/cnx-authoring/hooks","issue_events_url":"https://api.github.com/repos/Connexions/cnx-authoring/issues/events{/number}","events_url":"https://api.github.com/repos/Connexions/cnx-authoring/events","assignees_url":"https://api.github.com/repos/Connexions/cnx-authoring/assignees{/user}","branches_url":"https://api.github.com/repos/Connexions/cnx-authoring/branches{/branch}","tags_url":"https://api.github.com/repos/Connexions/cnx-authoring/tags","blobs_url":"https://api.github.com/repos/Connexions/cnx-authoring/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Connexions/cnx-authoring/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Connexions/cnx-authoring/git/refs{/sha}","trees_url":"https://api.github.com/repos/Connexions/cnx-authoring/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Connexions/cnx-authoring/statuses/{sha}","languages_url":"https://api.github.com/repos/Connexions/cnx-authoring/languages","stargazers_url":"https://api.github.com/repos/Connexions/cnx-authoring/stargazers","contributors_url":"https://api.github.com/repos/Connexions/cnx-authoring/contributors","subscribers_url":"https://api.github.com/repos/Connexions/cnx-authoring/subscribers","subscription_url":"https://api.github.com/repos/Connexions/cnx-authoring/subscription","commits_url":"https://api.github.com/repos/Connexions/cnx-authoring/commits{/sha}","git_commits_url":"https://api.github.com/repos/Connexions/cnx-authoring/git/commits{/sha}","comments_url":"https://api.github.com/repos/Connexions/cnx-authoring/comments{/number}","issue_comment_url":"https://api.github.com/repos/Connexions/cnx-authoring/issues/comments{/number}","contents_url":"https://api.github.com/repos/Connexions/cnx-authoring/contents/{+path}","compare_url":"https://api.github.com/repos/Connexions/cnx-authoring/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Connexions/cnx-authoring/merges","archive_url":"https://api.github.com/repos/Connexions/cnx-authoring/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Connexions/cnx-authoring/downloads","issues_url":"https://api.github.com/repos/Connexions/cnx-authoring/issues{/number}","pulls_url":"https://api.github.com/repos/Connexions/cnx-authoring/pulls{/number}","milestones_url":"https://api.github.com/repos/Connexions/cnx-authoring/milestones{/number}","notifications_url":"https://api.github.com/repos/Connexions/cnx-authoring/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Connexions/cnx-authoring/labels{/name}","releases_url":"https://api.github.com/repos/Connexions/cnx-authoring/releases{/id}","created_at":"2014-03-12T15:29:22Z","updated_at":"2015-04-28T20:56:36Z","pushed_at":"2015-10-07T20:41:44Z","git_url":"git://github.com/Connexions/cnx-authoring.git","ssh_url":"git@github.com:Connexions/cnx-authoring.git","clone_url":"https://github.com/Connexions/cnx-authoring.git","svn_url":"https://github.com/Connexions/cnx-authoring","homepage":"","size":2617,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":11,"forks":3,"open_issues":11,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Connexions/cnx-authoring/pulls/237"},"html":{"href":"https://github.com/Connexions/cnx-authoring/pull/237"},"issue":{"href":"https://api.github.com/repos/Connexions/cnx-authoring/issues/237"},"comments":{"href":"https://api.github.com/repos/Connexions/cnx-authoring/issues/237/comments"},"review_comments":{"href":"https://api.github.com/repos/Connexions/cnx-authoring/pulls/237/comments"},"review_comment":{"href":"https://api.github.com/repos/Connexions/cnx-authoring/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Connexions/cnx-authoring/pulls/237/commits"},"statuses":{"href":"https://api.github.com/repos/Connexions/cnx-authoring/statuses/654ca9d1d5b286d504b0082392c88f9bc8b66520"}}}}