{"action":"created","comment":{"url":"https://api.github.com/repos/myhpom/MyHPOM/pulls/comments/221596584","pull_request_review_id":160280289,"id":221596584,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMTU5NjU4NA==","diff_hunk":"@@ -0,0 +1,72 @@\n+import json\n+import os\n+from django.core.urlresolvers import reverse\n+from django.test import TestCase\n+\n+from myhpom.models import CloudFactoryDocumentRun\n+\n+CF_PATH = os.path.join(os.path.dirname(__file__), 'fixtures', 'cloudfactory')\n+SUCCESS_DATA = open(os.path.join(CF_PATH, 'callback_success.json')).read()\n+\n+\n+class CloudfactoryResponseTest(TestCase):\n+\n+    def test_no_data(self):\n+        # When no data is posted to the viewpoint, a 4xx code is returned,\n+        # alerting the requestor that the problem is theirs\n+        response = self.client.post(reverse('myhpom:cloudfactory_response'))\n+        self.assertEqual(400, response.status_code)\n+\n+    def test_badly_formed_data(self):\n+        # When non-json data is sent, we return a 400 to alert the user to the\n+        # bad formatting.\n+        response = self.client.post(\n+            reverse('myhpom:cloudfactory_response'), data='blah', content_type='text/example')\n+        self.assertEqual(400, response.status_code)\n+\n+    def test_no_id(self):\n+        # Record doesn't exist on our end - we want a log of this.\n+        response = self.client.post(reverse('myhpom:cloudfactory_response'), data=SUCCESS_DATA, content_type='application/json')\n+        self.assertEqual(404, response.status_code)\n+\n+    def test_already_finished(self):\n+        # When CloudFactoryDocumentRun exists, but it is already 'finished' - we\n+        # don't expect to receive any updates\n+        run = CloudFactoryDocumentRun.objects.create(run_id='E7gVrtVQJx')\n+        for status in CloudFactoryDocumentRun.STATUS_FINAL_STATES:\n+            run.status = status\n+            run.save()\n+            response = self.client.post(reverse('myhpom:cloudfactory_response'), data=SUCCESS_DATA, content_type='application/json')\n+            self.assertEqual(400, response.status_code, '%s should fail' % status)\n+\n+    def test_failed_review(self):\n+        # We get back a response that says any of the output criteria failed\n+        run = CloudFactoryDocumentRun.objects.create(run_id='E7gVrtVQJx')\n+\n+        # Try all the possible keys that could fail - they should all cause the\n+        # run to transition to finished.\n+        failed_data = json.loads(SUCCESS_DATA)\n+        for output in failed_data['units'][0]['output'].keys():\n+            failed_data['units'][0]['output'][output] = False","path":"myhpom/tests/test_cloudfactory_response_view.py","position":52,"original_position":50,"commit_id":"01abf2c43bc9cd3795e17f5abf215ebd09061ef4","original_commit_id":"306d26bba501d11a99a785b7de68538ce27ef5f7","user":{"login":"dsummersl","id":30856,"node_id":"MDQ6VXNlcjMwODU2","avatar_url":"https://avatars3.githubusercontent.com/u/30856?v=4","gravatar_id":"","url":"https://api.github.com/users/dsummersl","html_url":"https://github.com/dsummersl","followers_url":"https://api.github.com/users/dsummersl/followers","following_url":"https://api.github.com/users/dsummersl/following{/other_user}","gists_url":"https://api.github.com/users/dsummersl/gists{/gist_id}","starred_url":"https://api.github.com/users/dsummersl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dsummersl/subscriptions","organizations_url":"https://api.github.com/users/dsummersl/orgs","repos_url":"https://api.github.com/users/dsummersl/repos","events_url":"https://api.github.com/users/dsummersl/events{/privacy}","received_events_url":"https://api.github.com/users/dsummersl/received_events","type":"User","site_admin":false},"body":"Woops, I'll move the failed_data inside the loop.","created_at":"2018-10-01T12:52:51Z","updated_at":"2018-10-01T12:52:51Z","html_url":"https://github.com/myhpom/MyHPOM/pull/295#discussion_r221596584","pull_request_url":"https://api.github.com/repos/myhpom/MyHPOM/pulls/295","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/myhpom/MyHPOM/pulls/comments/221596584"},"html":{"href":"https://github.com/myhpom/MyHPOM/pull/295#discussion_r221596584"},"pull_request":{"href":"https://api.github.com/repos/myhpom/MyHPOM/pulls/295"}},"in_reply_to_id":221353826},"pull_request":{"url":"https://api.github.com/repos/myhpom/MyHPOM/pulls/295","id":218784093,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE4Nzg0MDkz","html_url":"https://github.com/myhpom/MyHPOM/pull/295","diff_url":"https://github.com/myhpom/MyHPOM/pull/295.diff","patch_url":"https://github.com/myhpom/MyHPOM/pull/295.patch","issue_url":"https://api.github.com/repos/myhpom/MyHPOM/issues/295","number":295,"state":"open","locked":false,"title":"Mh 253: handle cf responses","user":{"login":"dsummersl","id":30856,"node_id":"MDQ6VXNlcjMwODU2","avatar_url":"https://avatars3.githubusercontent.com/u/30856?v=4","gravatar_id":"","url":"https://api.github.com/users/dsummersl","html_url":"https://github.com/dsummersl","followers_url":"https://api.github.com/users/dsummersl/followers","following_url":"https://api.github.com/users/dsummersl/following{/other_user}","gists_url":"https://api.github.com/users/dsummersl/gists{/gist_id}","starred_url":"https://api.github.com/users/dsummersl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dsummersl/subscriptions","organizations_url":"https://api.github.com/users/dsummersl/orgs","repos_url":"https://api.github.com/users/dsummersl/repos","events_url":"https://api.github.com/users/dsummersl/events{/privacy}","received_events_url":"https://api.github.com/users/dsummersl/received_events","type":"User","site_admin":false},"body":"What these changes do:\r\n * Added some `verification*` methods that can be used in the upload templates to display various text based on the results of the verification.\r\n * Added some simple styling based on Shane's comments ( I think a followon ticket will address some comps he will eventually give us?)\r\n * Implemented the callback handler endpoint that CF would call.\r\n * Opened up a couple options in the admin to make it easy to test out various states of a run.\r\n * I ran into some circular referencing with the 'cf run' model and opted to move it in with the other models that its closely related to.\r\n\r\n\r\n---\r\n\r\n- [x] Add test cases for views?\r\n- [x] Add some example JSON docs that Gerald could use to test this. _I've updated the Jira ticket with notes for Gerald._\r\n- [x] Provide some instructions for how the callback handler could be called (rather than the admin).\r\n- [x] maybe I was too cavalier about moving the run model into documents...in hindsight seems like a big change. Maybe I should have hacked around the circular dependency instead?\r\n- [x] When a document is uploaded it says 'saved' b/c the run hasn't been picked up immediately (and may not be). Perhaps something other than 'Saved' is in order akin to 'verifying' so it is clear what the next step is?\r\n- [x] There is a risk that CF never calls our callback function...we should have a periodic task that updates the status of runs that have been 'processing' for 'too long'. Given that we don't have a working CF integration to truly test with, I think this should be a separate ticket (and if Shean that sounds right to you, I'll open that ticket on the backlog).\r\n- [x] There is also no recovery from request failures or general failures - there should be some support for retries in some cases. I think this should also be a followup ticket, once we have a full verification process working with CF.","created_at":"2018-09-27T20:47:19Z","updated_at":"2018-10-01T12:52:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f3c0a7353f804c1b10a444a0461afb1a6f9114d1","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/myhpom/MyHPOM/pulls/295/commits","review_comments_url":"https://api.github.com/repos/myhpom/MyHPOM/pulls/295/comments","review_comment_url":"https://api.github.com/repos/myhpom/MyHPOM/pulls/comments{/number}","comments_url":"https://api.github.com/repos/myhpom/MyHPOM/issues/295/comments","statuses_url":"https://api.github.com/repos/myhpom/MyHPOM/statuses/01abf2c43bc9cd3795e17f5abf215ebd09061ef4","head":{"label":"myhpom:mh-253-handle-cf-responses","ref":"mh-253-handle-cf-responses","sha":"01abf2c43bc9cd3795e17f5abf215ebd09061ef4","user":{"login":"myhpom","id":36999832,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM2OTk5ODMy","avatar_url":"https://avatars0.githubusercontent.com/u/36999832?v=4","gravatar_id":"","url":"https://api.github.com/users/myhpom","html_url":"https://github.com/myhpom","followers_url":"https://api.github.com/users/myhpom/followers","following_url":"https://api.github.com/users/myhpom/following{/other_user}","gists_url":"https://api.github.com/users/myhpom/gists{/gist_id}","starred_url":"https://api.github.com/users/myhpom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/myhpom/subscriptions","organizations_url":"https://api.github.com/users/myhpom/orgs","repos_url":"https://api.github.com/users/myhpom/repos","events_url":"https://api.github.com/users/myhpom/events{/privacy}","received_events_url":"https://api.github.com/users/myhpom/received_events","type":"Organization","site_admin":false},"repo":{"id":98585306,"node_id":"MDEwOlJlcG9zaXRvcnk5ODU4NTMwNg==","name":"MyHPOM","full_name":"myhpom/MyHPOM","private":false,"owner":{"login":"myhpom","id":36999832,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM2OTk5ODMy","avatar_url":"https://avatars0.githubusercontent.com/u/36999832?v=4","gravatar_id":"","url":"https://api.github.com/users/myhpom","html_url":"https://github.com/myhpom","followers_url":"https://api.github.com/users/myhpom/followers","following_url":"https://api.github.com/users/myhpom/following{/other_user}","gists_url":"https://api.github.com/users/myhpom/gists{/gist_id}","starred_url":"https://api.github.com/users/myhpom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/myhpom/subscriptions","organizations_url":"https://api.github.com/users/myhpom/orgs","repos_url":"https://api.github.com/users/myhpom/repos","events_url":"https://api.github.com/users/myhpom/events{/privacy}","received_events_url":"https://api.github.com/users/myhpom/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/myhpom/MyHPOM","description":"My Health Peace of Mind gives you a place to plan and communicate important information about your future healthcare wishes to those closest to you and those who provide medical care to you.","fork":true,"url":"https://api.github.com/repos/myhpom/MyHPOM","forks_url":"https://api.github.com/repos/myhpom/MyHPOM/forks","keys_url":"https://api.github.com/repos/myhpom/MyHPOM/keys{/key_id}","collaborators_url":"https://api.github.com/repos/myhpom/MyHPOM/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/myhpom/MyHPOM/teams","hooks_url":"https://api.github.com/repos/myhpom/MyHPOM/hooks","issue_events_url":"https://api.github.com/repos/myhpom/MyHPOM/issues/events{/number}","events_url":"https://api.github.com/repos/myhpom/MyHPOM/events","assignees_url":"https://api.github.com/repos/myhpom/MyHPOM/assignees{/user}","branches_url":"https://api.github.com/repos/myhpom/MyHPOM/branches{/branch}","tags_url":"https://api.github.com/repos/myhpom/MyHPOM/tags","blobs_url":"https://api.github.com/repos/myhpom/MyHPOM/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/myhpom/MyHPOM/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/myhpom/MyHPOM/git/refs{/sha}","trees_url":"https://api.github.com/repos/myhpom/MyHPOM/git/trees{/sha}","statuses_url":"https://api.github.com/repos/myhpom/MyHPOM/statuses/{sha}","languages_url":"https://api.github.com/repos/myhpom/MyHPOM/languages","stargazers_url":"https://api.github.com/repos/myhpom/MyHPOM/stargazers","contributors_url":"https://api.github.com/repos/myhpom/MyHPOM/contributors","subscribers_url":"https://api.github.com/repos/myhpom/MyHPOM/subscribers","subscription_url":"https://api.github.com/repos/myhpom/MyHPOM/subscription","commits_url":"https://api.github.com/repos/myhpom/MyHPOM/commits{/sha}","git_commits_url":"https://api.github.com/repos/myhpom/MyHPOM/git/commits{/sha}","comments_url":"https://api.github.com/repos/myhpom/MyHPOM/comments{/number}","issue_comment_url":"https://api.github.com/repos/myhpom/MyHPOM/issues/comments{/number}","contents_url":"https://api.github.com/repos/myhpom/MyHPOM/contents/{+path}","compare_url":"https://api.github.com/repos/myhpom/MyHPOM/compare/{base}...{head}","merges_url":"https://api.github.com/repos/myhpom/MyHPOM/merges","archive_url":"https://api.github.com/repos/myhpom/MyHPOM/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/myhpom/MyHPOM/downloads","issues_url":"https://api.github.com/repos/myhpom/MyHPOM/issues{/number}","pulls_url":"https://api.github.com/repos/myhpom/MyHPOM/pulls{/number}","milestones_url":"https://api.github.com/repos/myhpom/MyHPOM/milestones{/number}","notifications_url":"https://api.github.com/repos/myhpom/MyHPOM/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/myhpom/MyHPOM/labels{/name}","releases_url":"https://api.github.com/repos/myhpom/MyHPOM/releases{/id}","deployments_url":"https://api.github.com/repos/myhpom/MyHPOM/deployments","created_at":"2017-07-27T22:40:57Z","updated_at":"2018-09-27T17:03:29Z","pushed_at":"2018-09-28T22:01:41Z","git_url":"git://github.com/myhpom/MyHPOM.git","ssh_url":"git@github.com:myhpom/MyHPOM.git","clone_url":"https://github.com/myhpom/MyHPOM.git","svn_url":"https://github.com/myhpom/MyHPOM","homepage":"https://www.myhpom.org","size":233304,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":24,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":0,"open_issues":24,"watchers":1,"default_branch":"myhpom-develop"}},"base":{"label":"myhpom:myhpom-develop","ref":"myhpom-develop","sha":"6866ec0304194e4e9624207ca14b380de47d2598","user":{"login":"myhpom","id":36999832,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM2OTk5ODMy","avatar_url":"https://avatars0.githubusercontent.com/u/36999832?v=4","gravatar_id":"","url":"https://api.github.com/users/myhpom","html_url":"https://github.com/myhpom","followers_url":"https://api.github.com/users/myhpom/followers","following_url":"https://api.github.com/users/myhpom/following{/other_user}","gists_url":"https://api.github.com/users/myhpom/gists{/gist_id}","starred_url":"https://api.github.com/users/myhpom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/myhpom/subscriptions","organizations_url":"https://api.github.com/users/myhpom/orgs","repos_url":"https://api.github.com/users/myhpom/repos","events_url":"https://api.github.com/users/myhpom/events{/privacy}","received_events_url":"https://api.github.com/users/myhpom/received_events","type":"Organization","site_admin":false},"repo":{"id":98585306,"node_id":"MDEwOlJlcG9zaXRvcnk5ODU4NTMwNg==","name":"MyHPOM","full_name":"myhpom/MyHPOM","private":false,"owner":{"login":"myhpom","id":36999832,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM2OTk5ODMy","avatar_url":"https://avatars0.githubusercontent.com/u/36999832?v=4","gravatar_id":"","url":"https://api.github.com/users/myhpom","html_url":"https://github.com/myhpom","followers_url":"https://api.github.com/users/myhpom/followers","following_url":"https://api.github.com/users/myhpom/following{/other_user}","gists_url":"https://api.github.com/users/myhpom/gists{/gist_id}","starred_url":"https://api.github.com/users/myhpom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/myhpom/subscriptions","organizations_url":"https://api.github.com/users/myhpom/orgs","repos_url":"https://api.github.com/users/myhpom/repos","events_url":"https://api.github.com/users/myhpom/events{/privacy}","received_events_url":"https://api.github.com/users/myhpom/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/myhpom/MyHPOM","description":"My Health Peace of Mind gives you a place to plan and communicate important information about your future healthcare wishes to those closest to you and those who provide medical care to you.","fork":true,"url":"https://api.github.com/repos/myhpom/MyHPOM","forks_url":"https://api.github.com/repos/myhpom/MyHPOM/forks","keys_url":"https://api.github.com/repos/myhpom/MyHPOM/keys{/key_id}","collaborators_url":"https://api.github.com/repos/myhpom/MyHPOM/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/myhpom/MyHPOM/teams","hooks_url":"https://api.github.com/repos/myhpom/MyHPOM/hooks","issue_events_url":"https://api.github.com/repos/myhpom/MyHPOM/issues/events{/number}","events_url":"https://api.github.com/repos/myhpom/MyHPOM/events","assignees_url":"https://api.github.com/repos/myhpom/MyHPOM/assignees{/user}","branches_url":"https://api.github.com/repos/myhpom/MyHPOM/branches{/branch}","tags_url":"https://api.github.com/repos/myhpom/MyHPOM/tags","blobs_url":"https://api.github.com/repos/myhpom/MyHPOM/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/myhpom/MyHPOM/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/myhpom/MyHPOM/git/refs{/sha}","trees_url":"https://api.github.com/repos/myhpom/MyHPOM/git/trees{/sha}","statuses_url":"https://api.github.com/repos/myhpom/MyHPOM/statuses/{sha}","languages_url":"https://api.github.com/repos/myhpom/MyHPOM/languages","stargazers_url":"https://api.github.com/repos/myhpom/MyHPOM/stargazers","contributors_url":"https://api.github.com/repos/myhpom/MyHPOM/contributors","subscribers_url":"https://api.github.com/repos/myhpom/MyHPOM/subscribers","subscription_url":"https://api.github.com/repos/myhpom/MyHPOM/subscription","commits_url":"https://api.github.com/repos/myhpom/MyHPOM/commits{/sha}","git_commits_url":"https://api.github.com/repos/myhpom/MyHPOM/git/commits{/sha}","comments_url":"https://api.github.com/repos/myhpom/MyHPOM/comments{/number}","issue_comment_url":"https://api.github.com/repos/myhpom/MyHPOM/issues/comments{/number}","contents_url":"https://api.github.com/repos/myhpom/MyHPOM/contents/{+path}","compare_url":"https://api.github.com/repos/myhpom/MyHPOM/compare/{base}...{head}","merges_url":"https://api.github.com/repos/myhpom/MyHPOM/merges","archive_url":"https://api.github.com/repos/myhpom/MyHPOM/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/myhpom/MyHPOM/downloads","issues_url":"https://api.github.com/repos/myhpom/MyHPOM/issues{/number}","pulls_url":"https://api.github.com/repos/myhpom/MyHPOM/pulls{/number}","milestones_url":"https://api.github.com/repos/myhpom/MyHPOM/milestones{/number}","notifications_url":"https://api.github.com/repos/myhpom/MyHPOM/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/myhpom/MyHPOM/labels{/name}","releases_url":"https://api.github.com/repos/myhpom/MyHPOM/releases{/id}","deployments_url":"https://api.github.com/repos/myhpom/MyHPOM/deployments","created_at":"2017-07-27T22:40:57Z","updated_at":"2018-09-27T17:03:29Z","pushed_at":"2018-09-28T22:01:41Z","git_url":"git://github.com/myhpom/MyHPOM.git","ssh_url":"git@github.com:myhpom/MyHPOM.git","clone_url":"https://github.com/myhpom/MyHPOM.git","svn_url":"https://github.com/myhpom/MyHPOM","homepage":"https://www.myhpom.org","size":233304,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":24,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":0,"open_issues":24,"watchers":1,"default_branch":"myhpom-develop"}},"_links":{"self":{"href":"https://api.github.com/repos/myhpom/MyHPOM/pulls/295"},"html":{"href":"https://github.com/myhpom/MyHPOM/pull/295"},"issue":{"href":"https://api.github.com/repos/myhpom/MyHPOM/issues/295"},"comments":{"href":"https://api.github.com/repos/myhpom/MyHPOM/issues/295/comments"},"review_comments":{"href":"https://api.github.com/repos/myhpom/MyHPOM/pulls/295/comments"},"review_comment":{"href":"https://api.github.com/repos/myhpom/MyHPOM/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/myhpom/MyHPOM/pulls/295/commits"},"statuses":{"href":"https://api.github.com/repos/myhpom/MyHPOM/statuses/01abf2c43bc9cd3795e17f5abf215ebd09061ef4"}},"author_association":"NONE"}}
{"actor":{"display_login":"dsummersl"}}