{"action":"created","comment":{"url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/pulls/comments/33141273","id":33141273,"diff_hunk":"@@ -25,16 +44,57 @@ def test_that_getting_ping_json_with_a_valid_token_responds_with_HTTP_200(self):\n         self.assertEqual(response.status_code, 200)\n \n     def test_that_getting_ping_json_with_no_token_responds_with_HTTP_200(self):\n-        response = self.client.get(\n-            '/ping.json', {}, True, False)\n+        response =self.ping()\n         self.assertEqual(response.status_code, 200)\n \n     def test_that_getting_ping_json_with_no_token_produces_parseable_json(self):\n-        response = self.client.get(\n-            '/ping.json', {}, True, False)\n-        parsed = json.loads(response.content)\n+        self.assert_produces_parseable_json(self.ping())\n \n     def test_that_getting_ping_json_with_and_invalid_token_responds_with_HTTP_401(self):\n-        response = self.client.get(\n-            '/ping.json', {}, True, False, HTTP_AUTHORIZATION='Token 1234')\n+        response = self.ping(token='Token 1234')\n         self.assertEqual(response.status_code, 401)\n+\n+    # describe: healthcheck.json\n+    def test_that_getting_healthcheck_json_with_a_valid_token_produces_parseable_json(self):\n+        self.assert_produces_parseable_json(self.healthcheck(token=self.valid_token))\n+\n+    def test_that_when_the_database_is_ok_then_getting_healthcheck_json_with_a_valid_token_responds_with_HTTP_200(self):\n+        with patch('postcode_api.views.HealthcheckDotJsonView.is_database_ok', return_value=True):\n+            response = self.healthcheck()\n+        self.assertEqual(response.status_code, 200)\n+\n+    def test_that_when_the_database_is_ok_then_getting_healthcheck_json_with_no_token_responds_with_HTTP_200(self):\n+        with patch('postcode_api.views.HealthcheckDotJsonView.is_database_ok', return_value=True):\n+            response = self.healthcheck()\n+        self.assertEqual(response.status_code, 200)\n+\n+    def test_that_getting_healthcheck_json_with_no_token_produces_parseable_json(self):\n+        self.assert_produces_parseable_json(self.healthcheck())\n+\n+    def test_that_getting_healthcheck_json_with_and_invalid_token_responds_with_HTTP_401(self):\n+        response = self.healthcheck(token='Token 1234')\n+        self.assertEqual(response.status_code, 401)\n+\n+    def test_that_when_the_database_is_ok_it_shows_ok_true_in_the_database_element(self):\n+        with patch('postcode_api.views.HealthcheckDotJsonView.is_database_ok', return_value=True):\n+            response = self.healthcheck(token=self.valid_token)\n+        result = json.loads(response.content)\n+        self.assertEqual( True, result['database']['ok'] )","path":"postcodeinfo/apps/postcode_api/tests/views/test_support_views.py","position":86,"original_position":86,"commit_id":"a673b4c60afa484b68495f1110f0f79d84956ddf","original_commit_id":"a673b4c60afa484b68495f1110f0f79d84956ddf","user":{"login":"andyhd","id":35194,"avatar_url":"https://avatars.githubusercontent.com/u/35194?v=3","gravatar_id":"","url":"https://api.github.com/users/andyhd","html_url":"https://github.com/andyhd","followers_url":"https://api.github.com/users/andyhd/followers","following_url":"https://api.github.com/users/andyhd/following{/other_user}","gists_url":"https://api.github.com/users/andyhd/gists{/gist_id}","starred_url":"https://api.github.com/users/andyhd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andyhd/subscriptions","organizations_url":"https://api.github.com/users/andyhd/orgs","repos_url":"https://api.github.com/users/andyhd/repos","events_url":"https://api.github.com/users/andyhd/events{/privacy}","received_events_url":"https://api.github.com/users/andyhd/received_events","type":"User","site_admin":false},"body":"And another assert for this pattern:\r\n```python\r\ndef assert_json_ok(self, response, ok=False):\r\n    self.assertEqual(ok, json.loads(response).content)['ok'])\r\n\r\ndef test_that_when_blah_ok_true(self):\r\n    with patch('blah'):\r\n        self.assert_json_ok(self.healthcheck(token=self.valid_token))\r\n```","created_at":"2015-06-24T12:13:13Z","updated_at":"2015-06-24T12:13:13Z","html_url":"https://github.com/ministryofjustice/postcodeinfo/pull/53#discussion_r33141273","pull_request_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/pulls/53","_links":{"self":{"href":"https://api.github.com/repos/ministryofjustice/postcodeinfo/pulls/comments/33141273"},"html":{"href":"https://github.com/ministryofjustice/postcodeinfo/pull/53#discussion_r33141273"},"pull_request":{"href":"https://api.github.com/repos/ministryofjustice/postcodeinfo/pulls/53"}}},"pull_request":{"url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/pulls/53","id":38335504,"html_url":"https://github.com/ministryofjustice/postcodeinfo/pull/53","diff_url":"https://github.com/ministryofjustice/postcodeinfo/pull/53.diff","patch_url":"https://github.com/ministryofjustice/postcodeinfo/pull/53.patch","issue_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/issues/53","number":53,"state":"open","locked":false,"title":"added healthcheck.json","user":{"login":"aldavidson","id":134501,"avatar_url":"https://avatars.githubusercontent.com/u/134501?v=3","gravatar_id":"","url":"https://api.github.com/users/aldavidson","html_url":"https://github.com/aldavidson","followers_url":"https://api.github.com/users/aldavidson/followers","following_url":"https://api.github.com/users/aldavidson/following{/other_user}","gists_url":"https://api.github.com/users/aldavidson/gists{/gist_id}","starred_url":"https://api.github.com/users/aldavidson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aldavidson/subscriptions","organizations_url":"https://api.github.com/users/aldavidson/orgs","repos_url":"https://api.github.com/users/aldavidson/repos","events_url":"https://api.github.com/users/aldavidson/events{/privacy}","received_events_url":"https://api.github.com/users/aldavidson/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-06-23T13:23:07Z","updated_at":"2015-06-24T12:13:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5041a0f5e0b2ec84a3e27c8c4c82752abb02e725","assignee":{"login":"andyhd","id":35194,"avatar_url":"https://avatars.githubusercontent.com/u/35194?v=3","gravatar_id":"","url":"https://api.github.com/users/andyhd","html_url":"https://github.com/andyhd","followers_url":"https://api.github.com/users/andyhd/followers","following_url":"https://api.github.com/users/andyhd/following{/other_user}","gists_url":"https://api.github.com/users/andyhd/gists{/gist_id}","starred_url":"https://api.github.com/users/andyhd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andyhd/subscriptions","organizations_url":"https://api.github.com/users/andyhd/orgs","repos_url":"https://api.github.com/users/andyhd/repos","events_url":"https://api.github.com/users/andyhd/events{/privacy}","received_events_url":"https://api.github.com/users/andyhd/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/pulls/53/commits","review_comments_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/pulls/53/comments","review_comment_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/issues/53/comments","statuses_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/statuses/a673b4c60afa484b68495f1110f0f79d84956ddf","head":{"label":"ministryofjustice:healthcheck.json","ref":"healthcheck.json","sha":"a673b4c60afa484b68495f1110f0f79d84956ddf","user":{"login":"ministryofjustice","id":2203574,"avatar_url":"https://avatars.githubusercontent.com/u/2203574?v=3","gravatar_id":"","url":"https://api.github.com/users/ministryofjustice","html_url":"https://github.com/ministryofjustice","followers_url":"https://api.github.com/users/ministryofjustice/followers","following_url":"https://api.github.com/users/ministryofjustice/following{/other_user}","gists_url":"https://api.github.com/users/ministryofjustice/gists{/gist_id}","starred_url":"https://api.github.com/users/ministryofjustice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ministryofjustice/subscriptions","organizations_url":"https://api.github.com/users/ministryofjustice/orgs","repos_url":"https://api.github.com/users/ministryofjustice/repos","events_url":"https://api.github.com/users/ministryofjustice/events{/privacy}","received_events_url":"https://api.github.com/users/ministryofjustice/received_events","type":"Organization","site_admin":false},"repo":{"id":34381577,"name":"postcodeinfo","full_name":"ministryofjustice/postcodeinfo","owner":{"login":"ministryofjustice","id":2203574,"avatar_url":"https://avatars.githubusercontent.com/u/2203574?v=3","gravatar_id":"","url":"https://api.github.com/users/ministryofjustice","html_url":"https://github.com/ministryofjustice","followers_url":"https://api.github.com/users/ministryofjustice/followers","following_url":"https://api.github.com/users/ministryofjustice/following{/other_user}","gists_url":"https://api.github.com/users/ministryofjustice/gists{/gist_id}","starred_url":"https://api.github.com/users/ministryofjustice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ministryofjustice/subscriptions","organizations_url":"https://api.github.com/users/ministryofjustice/orgs","repos_url":"https://api.github.com/users/ministryofjustice/repos","events_url":"https://api.github.com/users/ministryofjustice/events{/privacy}","received_events_url":"https://api.github.com/users/ministryofjustice/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ministryofjustice/postcodeinfo","description":"REST API for looking up a given UK Postcode and getting addresses, lat/long, and local authority info","fork":false,"url":"https://api.github.com/repos/ministryofjustice/postcodeinfo","forks_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/forks","keys_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/teams","hooks_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/hooks","issue_events_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/issues/events{/number}","events_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/events","assignees_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/assignees{/user}","branches_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/branches{/branch}","tags_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/tags","blobs_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/git/refs{/sha}","trees_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/statuses/{sha}","languages_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/languages","stargazers_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/stargazers","contributors_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/contributors","subscribers_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/subscribers","subscription_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/subscription","commits_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/commits{/sha}","git_commits_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/git/commits{/sha}","comments_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/comments{/number}","issue_comment_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/issues/comments{/number}","contents_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/contents/{+path}","compare_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/merges","archive_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/downloads","issues_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/issues{/number}","pulls_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/pulls{/number}","milestones_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/milestones{/number}","notifications_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/labels{/name}","releases_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/releases{/id}","created_at":"2015-04-22T09:32:13Z","updated_at":"2015-05-14T12:17:34Z","pushed_at":"2015-06-24T10:06:39Z","git_url":"git://github.com/ministryofjustice/postcodeinfo.git","ssh_url":"git@github.com:ministryofjustice/postcodeinfo.git","clone_url":"https://github.com/ministryofjustice/postcodeinfo.git","svn_url":"https://github.com/ministryofjustice/postcodeinfo","homepage":"","size":1016,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"base":{"label":"ministryofjustice:master","ref":"master","sha":"13e37606ce4cf2a7e2e30d599568dd41c7a0e66c","user":{"login":"ministryofjustice","id":2203574,"avatar_url":"https://avatars.githubusercontent.com/u/2203574?v=3","gravatar_id":"","url":"https://api.github.com/users/ministryofjustice","html_url":"https://github.com/ministryofjustice","followers_url":"https://api.github.com/users/ministryofjustice/followers","following_url":"https://api.github.com/users/ministryofjustice/following{/other_user}","gists_url":"https://api.github.com/users/ministryofjustice/gists{/gist_id}","starred_url":"https://api.github.com/users/ministryofjustice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ministryofjustice/subscriptions","organizations_url":"https://api.github.com/users/ministryofjustice/orgs","repos_url":"https://api.github.com/users/ministryofjustice/repos","events_url":"https://api.github.com/users/ministryofjustice/events{/privacy}","received_events_url":"https://api.github.com/users/ministryofjustice/received_events","type":"Organization","site_admin":false},"repo":{"id":34381577,"name":"postcodeinfo","full_name":"ministryofjustice/postcodeinfo","owner":{"login":"ministryofjustice","id":2203574,"avatar_url":"https://avatars.githubusercontent.com/u/2203574?v=3","gravatar_id":"","url":"https://api.github.com/users/ministryofjustice","html_url":"https://github.com/ministryofjustice","followers_url":"https://api.github.com/users/ministryofjustice/followers","following_url":"https://api.github.com/users/ministryofjustice/following{/other_user}","gists_url":"https://api.github.com/users/ministryofjustice/gists{/gist_id}","starred_url":"https://api.github.com/users/ministryofjustice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ministryofjustice/subscriptions","organizations_url":"https://api.github.com/users/ministryofjustice/orgs","repos_url":"https://api.github.com/users/ministryofjustice/repos","events_url":"https://api.github.com/users/ministryofjustice/events{/privacy}","received_events_url":"https://api.github.com/users/ministryofjustice/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ministryofjustice/postcodeinfo","description":"REST API for looking up a given UK Postcode and getting addresses, lat/long, and local authority info","fork":false,"url":"https://api.github.com/repos/ministryofjustice/postcodeinfo","forks_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/forks","keys_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/teams","hooks_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/hooks","issue_events_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/issues/events{/number}","events_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/events","assignees_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/assignees{/user}","branches_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/branches{/branch}","tags_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/tags","blobs_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/git/refs{/sha}","trees_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/statuses/{sha}","languages_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/languages","stargazers_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/stargazers","contributors_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/contributors","subscribers_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/subscribers","subscription_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/subscription","commits_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/commits{/sha}","git_commits_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/git/commits{/sha}","comments_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/comments{/number}","issue_comment_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/issues/comments{/number}","contents_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/contents/{+path}","compare_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/merges","archive_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/downloads","issues_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/issues{/number}","pulls_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/pulls{/number}","milestones_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/milestones{/number}","notifications_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/labels{/name}","releases_url":"https://api.github.com/repos/ministryofjustice/postcodeinfo/releases{/id}","created_at":"2015-04-22T09:32:13Z","updated_at":"2015-05-14T12:17:34Z","pushed_at":"2015-06-24T10:06:39Z","git_url":"git://github.com/ministryofjustice/postcodeinfo.git","ssh_url":"git@github.com:ministryofjustice/postcodeinfo.git","clone_url":"https://github.com/ministryofjustice/postcodeinfo.git","svn_url":"https://github.com/ministryofjustice/postcodeinfo","homepage":"","size":1016,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ministryofjustice/postcodeinfo/pulls/53"},"html":{"href":"https://github.com/ministryofjustice/postcodeinfo/pull/53"},"issue":{"href":"https://api.github.com/repos/ministryofjustice/postcodeinfo/issues/53"},"comments":{"href":"https://api.github.com/repos/ministryofjustice/postcodeinfo/issues/53/comments"},"review_comments":{"href":"https://api.github.com/repos/ministryofjustice/postcodeinfo/pulls/53/comments"},"review_comment":{"href":"https://api.github.com/repos/ministryofjustice/postcodeinfo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ministryofjustice/postcodeinfo/pulls/53/commits"},"statuses":{"href":"https://api.github.com/repos/ministryofjustice/postcodeinfo/statuses/a673b4c60afa484b68495f1110f0f79d84956ddf"}}}}