{"action":"created","comment":{"url":"https://api.github.com/repos/pulp/pulp/pulls/comments/40469777","id":40469777,"diff_hunk":"@@ -0,0 +1,74 @@\n+import unittest\n+\n+from celery.result import AsyncResult\n+import mock\n+\n+from pulp.server.webservices.middleware import postponed\n+\n+\n+class MockException(Exception):\n+    pass\n+\n+\n+class TestPostponedOperationMiddleware(unittest.TestCase):\n+    \"\"\"\n+    Tests for the handling of async exceptions.\n+    \"\"\"\n+\n+    @mock.patch('pulp.server.webservices.middleware.postponed.json_util.default')\n+    @mock.patch('pulp.server.webservices.middleware.postponed.TaskResult')\n+    @mock.patch('pulp.server.webservices.middleware.postponed.json')\n+    def test_get_operation_postboned_async_body_dict(self, mjson, mtask_result, mjson_default):\n+        \"\"\"\n+        Test handling of a AsyncResult call report.\n+        \"\"\"\n+        e = MockException()\n+        mock_result = mock.MagicMock()\n+        del mock_result.serializer\n+        e.call_report = AsyncResult(mock.MagicMock())\n+        mock_task_result = mtask_result.from_async_result.return_value\n+        mock_serialized = {'result': mock_result, 'spawned_tasks': []}\n+        mock_task_result.serialize.return_value = mock_serialized\n+        ret = postponed.PostponedOperationMiddleware._get_operation_postponed_body(e)\n+        mtask_result.from_async_result.assert_called_once_with(e.call_report)\n+        mock_task_result.serialize.assert_called_once_with()\n+        mjson.dumps.assert_called_once_with(mock_serialized, default=mjson_default)\n+        self.assertTrue(ret is mjson.dumps.return_value)\n+\n+    @mock.patch('pulp.server.webservices.middleware.postponed.json_util.default')\n+    @mock.patch('pulp.server.webservices.middleware.postponed.TaskResult')\n+    @mock.patch('pulp.server.webservices.middleware.postponed.json')\n+    def test_get_operation_postboned_not_async_body_old(self, mjson, mtask_result, mjson_default):","path":"server/test/unit/server/webservices/middleware/test_postponed.py","position":41,"original_position":41,"commit_id":"aaf1aad59bf7acc572fb9e6ffaa0b47d3b198f8c","original_commit_id":"aaf1aad59bf7acc572fb9e6ffaa0b47d3b198f8c","user":{"login":"rbarlow","id":354506,"avatar_url":"https://avatars.githubusercontent.com/u/354506?v=3","gravatar_id":"","url":"https://api.github.com/users/rbarlow","html_url":"https://github.com/rbarlow","followers_url":"https://api.github.com/users/rbarlow/followers","following_url":"https://api.github.com/users/rbarlow/following{/other_user}","gists_url":"https://api.github.com/users/rbarlow/gists{/gist_id}","starred_url":"https://api.github.com/users/rbarlow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rbarlow/subscriptions","organizations_url":"https://api.github.com/users/rbarlow/orgs","repos_url":"https://api.github.com/users/rbarlow/repos","events_url":"https://api.github.com/users/rbarlow/events{/privacy}","received_events_url":"https://api.github.com/users/rbarlow/received_events","type":"User","site_admin":false},"body":"s/b/p/","created_at":"2015-09-25T20:01:34Z","updated_at":"2015-09-25T20:01:34Z","html_url":"https://github.com/pulp/pulp/pull/2052#discussion_r40469777","pull_request_url":"https://api.github.com/repos/pulp/pulp/pulls/2052","_links":{"self":{"href":"https://api.github.com/repos/pulp/pulp/pulls/comments/40469777"},"html":{"href":"https://github.com/pulp/pulp/pull/2052#discussion_r40469777"},"pull_request":{"href":"https://api.github.com/repos/pulp/pulp/pulls/2052"}}},"pull_request":{"url":"https://api.github.com/repos/pulp/pulp/pulls/2052","id":45421528,"html_url":"https://github.com/pulp/pulp/pull/2052","diff_url":"https://github.com/pulp/pulp/pull/2052.diff","patch_url":"https://github.com/pulp/pulp/pull/2052.patch","issue_url":"https://api.github.com/repos/pulp/pulp/issues/2052","number":2052,"state":"open","locked":false,"title":"serialize ME documents in a call report","user":{"login":"asmacdo","id":1028657,"avatar_url":"https://avatars.githubusercontent.com/u/1028657?v=3","gravatar_id":"","url":"https://api.github.com/users/asmacdo","html_url":"https://github.com/asmacdo","followers_url":"https://api.github.com/users/asmacdo/followers","following_url":"https://api.github.com/users/asmacdo/following{/other_user}","gists_url":"https://api.github.com/users/asmacdo/gists{/gist_id}","starred_url":"https://api.github.com/users/asmacdo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asmacdo/subscriptions","organizations_url":"https://api.github.com/users/asmacdo/orgs","repos_url":"https://api.github.com/users/asmacdo/repos","events_url":"https://api.github.com/users/asmacdo/events{/privacy}","received_events_url":"https://api.github.com/users/asmacdo/received_events","type":"User","site_admin":false},"body":"If there are Mongoengine documents in an async call report, they must be serialized using the serializer found on the object's model.\r\n\r\nhttps://pulp.plan.io/issues/1259","created_at":"2015-09-18T15:48:03Z","updated_at":"2015-09-25T20:01:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f2a5279219770477652122f059fd3b0bf24bc052","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/pulp/pulp/pulls/2052/commits","review_comments_url":"https://api.github.com/repos/pulp/pulp/pulls/2052/comments","review_comment_url":"https://api.github.com/repos/pulp/pulp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pulp/pulp/issues/2052/comments","statuses_url":"https://api.github.com/repos/pulp/pulp/statuses/aaf1aad59bf7acc572fb9e6ffaa0b47d3b198f8c","head":{"label":"asmacdo:serialize-async-docs","ref":"serialize-async-docs","sha":"aaf1aad59bf7acc572fb9e6ffaa0b47d3b198f8c","user":{"login":"asmacdo","id":1028657,"avatar_url":"https://avatars.githubusercontent.com/u/1028657?v=3","gravatar_id":"","url":"https://api.github.com/users/asmacdo","html_url":"https://github.com/asmacdo","followers_url":"https://api.github.com/users/asmacdo/followers","following_url":"https://api.github.com/users/asmacdo/following{/other_user}","gists_url":"https://api.github.com/users/asmacdo/gists{/gist_id}","starred_url":"https://api.github.com/users/asmacdo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asmacdo/subscriptions","organizations_url":"https://api.github.com/users/asmacdo/orgs","repos_url":"https://api.github.com/users/asmacdo/repos","events_url":"https://api.github.com/users/asmacdo/events{/privacy}","received_events_url":"https://api.github.com/users/asmacdo/received_events","type":"User","site_admin":false},"repo":{"id":22577579,"name":"pulp","full_name":"asmacdo/pulp","owner":{"login":"asmacdo","id":1028657,"avatar_url":"https://avatars.githubusercontent.com/u/1028657?v=3","gravatar_id":"","url":"https://api.github.com/users/asmacdo","html_url":"https://github.com/asmacdo","followers_url":"https://api.github.com/users/asmacdo/followers","following_url":"https://api.github.com/users/asmacdo/following{/other_user}","gists_url":"https://api.github.com/users/asmacdo/gists{/gist_id}","starred_url":"https://api.github.com/users/asmacdo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asmacdo/subscriptions","organizations_url":"https://api.github.com/users/asmacdo/orgs","repos_url":"https://api.github.com/users/asmacdo/repos","events_url":"https://api.github.com/users/asmacdo/events{/privacy}","received_events_url":"https://api.github.com/users/asmacdo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/asmacdo/pulp","description":"Repository for Pulp platform code, including the server and base admin and consumer clients","fork":true,"url":"https://api.github.com/repos/asmacdo/pulp","forks_url":"https://api.github.com/repos/asmacdo/pulp/forks","keys_url":"https://api.github.com/repos/asmacdo/pulp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/asmacdo/pulp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/asmacdo/pulp/teams","hooks_url":"https://api.github.com/repos/asmacdo/pulp/hooks","issue_events_url":"https://api.github.com/repos/asmacdo/pulp/issues/events{/number}","events_url":"https://api.github.com/repos/asmacdo/pulp/events","assignees_url":"https://api.github.com/repos/asmacdo/pulp/assignees{/user}","branches_url":"https://api.github.com/repos/asmacdo/pulp/branches{/branch}","tags_url":"https://api.github.com/repos/asmacdo/pulp/tags","blobs_url":"https://api.github.com/repos/asmacdo/pulp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/asmacdo/pulp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/asmacdo/pulp/git/refs{/sha}","trees_url":"https://api.github.com/repos/asmacdo/pulp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/asmacdo/pulp/statuses/{sha}","languages_url":"https://api.github.com/repos/asmacdo/pulp/languages","stargazers_url":"https://api.github.com/repos/asmacdo/pulp/stargazers","contributors_url":"https://api.github.com/repos/asmacdo/pulp/contributors","subscribers_url":"https://api.github.com/repos/asmacdo/pulp/subscribers","subscription_url":"https://api.github.com/repos/asmacdo/pulp/subscription","commits_url":"https://api.github.com/repos/asmacdo/pulp/commits{/sha}","git_commits_url":"https://api.github.com/repos/asmacdo/pulp/git/commits{/sha}","comments_url":"https://api.github.com/repos/asmacdo/pulp/comments{/number}","issue_comment_url":"https://api.github.com/repos/asmacdo/pulp/issues/comments{/number}","contents_url":"https://api.github.com/repos/asmacdo/pulp/contents/{+path}","compare_url":"https://api.github.com/repos/asmacdo/pulp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/asmacdo/pulp/merges","archive_url":"https://api.github.com/repos/asmacdo/pulp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/asmacdo/pulp/downloads","issues_url":"https://api.github.com/repos/asmacdo/pulp/issues{/number}","pulls_url":"https://api.github.com/repos/asmacdo/pulp/pulls{/number}","milestones_url":"https://api.github.com/repos/asmacdo/pulp/milestones{/number}","notifications_url":"https://api.github.com/repos/asmacdo/pulp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/asmacdo/pulp/labels{/name}","releases_url":"https://api.github.com/repos/asmacdo/pulp/releases{/id}","created_at":"2014-08-03T15:27:48Z","updated_at":"2015-03-09T15:25:38Z","pushed_at":"2015-09-25T19:49:11Z","git_url":"git://github.com/asmacdo/pulp.git","ssh_url":"git@github.com:asmacdo/pulp.git","clone_url":"https://github.com/asmacdo/pulp.git","svn_url":"https://github.com/asmacdo/pulp","homepage":"","size":87114,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"pulp:master","ref":"master","sha":"d9c07b442e436382a9b6e80a5190c0769e73a928","user":{"login":"pulp","id":2103606,"avatar_url":"https://avatars.githubusercontent.com/u/2103606?v=3","gravatar_id":"","url":"https://api.github.com/users/pulp","html_url":"https://github.com/pulp","followers_url":"https://api.github.com/users/pulp/followers","following_url":"https://api.github.com/users/pulp/following{/other_user}","gists_url":"https://api.github.com/users/pulp/gists{/gist_id}","starred_url":"https://api.github.com/users/pulp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pulp/subscriptions","organizations_url":"https://api.github.com/users/pulp/orgs","repos_url":"https://api.github.com/users/pulp/repos","events_url":"https://api.github.com/users/pulp/events{/privacy}","received_events_url":"https://api.github.com/users/pulp/received_events","type":"Organization","site_admin":false},"repo":{"id":5314652,"name":"pulp","full_name":"pulp/pulp","owner":{"login":"pulp","id":2103606,"avatar_url":"https://avatars.githubusercontent.com/u/2103606?v=3","gravatar_id":"","url":"https://api.github.com/users/pulp","html_url":"https://github.com/pulp","followers_url":"https://api.github.com/users/pulp/followers","following_url":"https://api.github.com/users/pulp/following{/other_user}","gists_url":"https://api.github.com/users/pulp/gists{/gist_id}","starred_url":"https://api.github.com/users/pulp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pulp/subscriptions","organizations_url":"https://api.github.com/users/pulp/orgs","repos_url":"https://api.github.com/users/pulp/repos","events_url":"https://api.github.com/users/pulp/events{/privacy}","received_events_url":"https://api.github.com/users/pulp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pulp/pulp","description":"Repository for Pulp platform code, including the server and base admin and consumer clients","fork":false,"url":"https://api.github.com/repos/pulp/pulp","forks_url":"https://api.github.com/repos/pulp/pulp/forks","keys_url":"https://api.github.com/repos/pulp/pulp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pulp/pulp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pulp/pulp/teams","hooks_url":"https://api.github.com/repos/pulp/pulp/hooks","issue_events_url":"https://api.github.com/repos/pulp/pulp/issues/events{/number}","events_url":"https://api.github.com/repos/pulp/pulp/events","assignees_url":"https://api.github.com/repos/pulp/pulp/assignees{/user}","branches_url":"https://api.github.com/repos/pulp/pulp/branches{/branch}","tags_url":"https://api.github.com/repos/pulp/pulp/tags","blobs_url":"https://api.github.com/repos/pulp/pulp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pulp/pulp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pulp/pulp/git/refs{/sha}","trees_url":"https://api.github.com/repos/pulp/pulp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pulp/pulp/statuses/{sha}","languages_url":"https://api.github.com/repos/pulp/pulp/languages","stargazers_url":"https://api.github.com/repos/pulp/pulp/stargazers","contributors_url":"https://api.github.com/repos/pulp/pulp/contributors","subscribers_url":"https://api.github.com/repos/pulp/pulp/subscribers","subscription_url":"https://api.github.com/repos/pulp/pulp/subscription","commits_url":"https://api.github.com/repos/pulp/pulp/commits{/sha}","git_commits_url":"https://api.github.com/repos/pulp/pulp/git/commits{/sha}","comments_url":"https://api.github.com/repos/pulp/pulp/comments{/number}","issue_comment_url":"https://api.github.com/repos/pulp/pulp/issues/comments{/number}","contents_url":"https://api.github.com/repos/pulp/pulp/contents/{+path}","compare_url":"https://api.github.com/repos/pulp/pulp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pulp/pulp/merges","archive_url":"https://api.github.com/repos/pulp/pulp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pulp/pulp/downloads","issues_url":"https://api.github.com/repos/pulp/pulp/issues{/number}","pulls_url":"https://api.github.com/repos/pulp/pulp/pulls{/number}","milestones_url":"https://api.github.com/repos/pulp/pulp/milestones{/number}","notifications_url":"https://api.github.com/repos/pulp/pulp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pulp/pulp/labels{/name}","releases_url":"https://api.github.com/repos/pulp/pulp/releases{/id}","created_at":"2012-08-06T13:49:20Z","updated_at":"2015-09-23T12:06:22Z","pushed_at":"2015-09-25T19:58:04Z","git_url":"git://github.com/pulp/pulp.git","ssh_url":"git@github.com:pulp/pulp.git","clone_url":"https://github.com/pulp/pulp.git","svn_url":"https://github.com/pulp/pulp","homepage":"","size":208834,"stargazers_count":217,"watchers_count":217,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":88,"mirror_url":null,"open_issues_count":26,"forks":88,"open_issues":26,"watchers":217,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pulp/pulp/pulls/2052"},"html":{"href":"https://github.com/pulp/pulp/pull/2052"},"issue":{"href":"https://api.github.com/repos/pulp/pulp/issues/2052"},"comments":{"href":"https://api.github.com/repos/pulp/pulp/issues/2052/comments"},"review_comments":{"href":"https://api.github.com/repos/pulp/pulp/pulls/2052/comments"},"review_comment":{"href":"https://api.github.com/repos/pulp/pulp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pulp/pulp/pulls/2052/commits"},"statuses":{"href":"https://api.github.com/repos/pulp/pulp/statuses/aaf1aad59bf7acc572fb9e6ffaa0b47d3b198f8c"}}}}