{"action":"created","comment":{"url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/pulls/comments/26213595","id":26213595,"diff_hunk":"@@ -20,6 +21,22 @@ def test_all_schemas_are_valid():\n             yield check_schema_file, file_path\n \n \n+def test_updater_json_validates_correctly():\n+    invalid_updater_no_reason = {'updated_by': 'this'}\n+    invalid_updater_no_username = {'update_reason': 'this'}\n+    invalid_updater_no_fields = {'invalid': 'this'}\n+    valid_updater = {'updated_by': 'this', 'update_reason': 'hi'}\n+\n+    assert_equal(validates_against_schema(\n+        UPDATER_SCHEMA, invalid_updater_no_reason), False)\n+    assert_equal(validates_against_schema(\n+        UPDATER_SCHEMA, invalid_updater_no_username), False)\n+    assert_equal(validates_against_schema(\n+        UPDATER_SCHEMA, invalid_updater_no_fields), False)\n+    assert_equal(validates_against_schema(\n+        UPDATER_SCHEMA, valid_updater), True)","path":"tests/test_json_validation.py","position":27,"original_position":27,"commit_id":"f2c2d358ca89d726801b95ded4458e33812b8b8b","original_commit_id":"f2c2d358ca89d726801b95ded4458e33812b8b8b","user":{"login":"allait","id":246664,"avatar_url":"https://avatars.githubusercontent.com/u/246664?v=3","gravatar_id":"","url":"https://api.github.com/users/allait","html_url":"https://github.com/allait","followers_url":"https://api.github.com/users/allait/followers","following_url":"https://api.github.com/users/allait/following{/other_user}","gists_url":"https://api.github.com/users/allait/gists{/gist_id}","starred_url":"https://api.github.com/users/allait/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/allait/subscriptions","organizations_url":"https://api.github.com/users/allait/orgs","repos_url":"https://api.github.com/users/allait/repos","events_url":"https://api.github.com/users/allait/events{/privacy}","received_events_url":"https://api.github.com/users/allait/received_events","type":"User","site_admin":false},"body":"It would be nice to stick to using test generators (instead of having a series of asserts) for things like this. That way each check will pass/fail independently.","created_at":"2015-03-11T14:01:14Z","updated_at":"2015-03-11T14:01:14Z","html_url":"https://github.com/alphagov/digitalmarketplace-api/pull/45#discussion_r26213595","pull_request_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/pulls/45","_links":{"self":{"href":"https://api.github.com/repos/alphagov/digitalmarketplace-api/pulls/comments/26213595"},"html":{"href":"https://github.com/alphagov/digitalmarketplace-api/pull/45#discussion_r26213595"},"pull_request":{"href":"https://api.github.com/repos/alphagov/digitalmarketplace-api/pulls/45"}}},"pull_request":{"url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/pulls/45","id":30925870,"html_url":"https://github.com/alphagov/digitalmarketplace-api/pull/45","diff_url":"https://github.com/alphagov/digitalmarketplace-api/pull/45.diff","patch_url":"https://github.com/alphagov/digitalmarketplace-api/pull/45.patch","issue_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/issues/45","number":45,"state":"open","locked":false,"title":"Mi data audit","user":{"login":"minglis","id":369454,"avatar_url":"https://avatars.githubusercontent.com/u/369454?v=3","gravatar_id":"","url":"https://api.github.com/users/minglis","html_url":"https://github.com/minglis","followers_url":"https://api.github.com/users/minglis/followers","following_url":"https://api.github.com/users/minglis/following{/other_user}","gists_url":"https://api.github.com/users/minglis/gists{/gist_id}","starred_url":"https://api.github.com/users/minglis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/minglis/subscriptions","organizations_url":"https://api.github.com/users/minglis/orgs","repos_url":"https://api.github.com/users/minglis/repos","events_url":"https://api.github.com/users/minglis/events{/privacy}","received_events_url":"https://api.github.com/users/minglis/received_events","type":"User","site_admin":false},"body":"This story is to deliver the data audit story:\r\n\r\n[https://www.pivotaltracker.com/story/show/89081984](https://www.pivotaltracker.com/story/show/89081984)\r\n\r\nBasic premise is that there is a POST API endpoint which will allow us to update fields in the JSON data the describes a service. This action will have the side-effect creating an archived version of the previous state, such that we can discover what a service was at any point in time.\r\n\r\nStory does the following things:\r\n1) Changes to the database - **IF THIS NEEDS IT'S ON PULL REQUEST I'LL SPLIT IT**:\r\n- adds **updated_by** and **updated_reason** columns to the Services table;\r\n- populates the existing rows with default values for these new columns, which then are not-null\r\n- adds a new table ServicesArchive\r\n\r\n2) Changes to the PUT API\r\n- Now will only allow a **single** PUT against a service to create the initial row.\r\n- Any subsequent PUT against that service will result in a 409 Conflict response\r\n- PUT does **not** make an archived entry\r\n- requires an extra piece of JSON to describe who imported and why:\r\n\r\n    { updated_details: { updated_by: '_username_', updated_reason: '_the whys_' }}\r\n\r\n- import script populates this new JSON which current UNIX user and standard reason - no change to command line args\r\n\r\n3) Changes to POST API\r\n- POST API enabled\r\n- Requires **updated_details** JSON as described above\r\n- Takes second JSON block where any key value pair can be supplied\r\n\r\n    {services: {key: value}}\r\n\r\n- Value can be any valid JSON - objects, lists, strings, etc\r\n- Logic is to load service from the database, update the JSON with the supplied values and then valid against the JSONParse schemas we use on import.\r\n- Successful validation will lead to the creation of the archive row and the update of the *live* row.\r\n- URL\r\n\r\n    POST /services/{:service_id}\r\n\r\n4) New API endpoints for the archive\r\n- The ServiceArchive table is addressable through two new endpoings\r\n\r\nTo get an individual row from the archive:\r\n\r\n    GET /service-archive/{:pk}\r\n\r\nTo get all rows for a service:\r\n\r\n    GET /service-archive?service-id={:service-id}\r\n\r\n5) Explorer page for API testing\r\n- Added a new page\r\n\r\n    GET /_explorer\r\n\r\n- This page is a Bootstrap/JQuery top on the API endpoints for in-browser testing.\r\n- You're all welcome to make it better!\r\n\r\n","created_at":"2015-03-11T09:19:55Z","updated_at":"2015-03-11T14:01:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3b532f6ea5ddb334fe1f846b0de4dab89f63355f","assignee":{"login":"robyoung","id":14287,"avatar_url":"https://avatars.githubusercontent.com/u/14287?v=3","gravatar_id":"","url":"https://api.github.com/users/robyoung","html_url":"https://github.com/robyoung","followers_url":"https://api.github.com/users/robyoung/followers","following_url":"https://api.github.com/users/robyoung/following{/other_user}","gists_url":"https://api.github.com/users/robyoung/gists{/gist_id}","starred_url":"https://api.github.com/users/robyoung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robyoung/subscriptions","organizations_url":"https://api.github.com/users/robyoung/orgs","repos_url":"https://api.github.com/users/robyoung/repos","events_url":"https://api.github.com/users/robyoung/events{/privacy}","received_events_url":"https://api.github.com/users/robyoung/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/pulls/45/commits","review_comments_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/pulls/45/comments","review_comment_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/pulls/comments{/number}","comments_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/issues/45/comments","statuses_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/statuses/f2c2d358ca89d726801b95ded4458e33812b8b8b","head":{"label":"alphagov:mi_data_audit","ref":"mi_data_audit","sha":"f2c2d358ca89d726801b95ded4458e33812b8b8b","user":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"repo":{"id":26963583,"name":"digitalmarketplace-api","full_name":"alphagov/digitalmarketplace-api","owner":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/alphagov/digitalmarketplace-api","description":"Digital Marketplace API.","fork":false,"url":"https://api.github.com/repos/alphagov/digitalmarketplace-api","forks_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/forks","keys_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/teams","hooks_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/hooks","issue_events_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/issues/events{/number}","events_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/events","assignees_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/assignees{/user}","branches_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/branches{/branch}","tags_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/tags","blobs_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/statuses/{sha}","languages_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/languages","stargazers_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/stargazers","contributors_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/contributors","subscribers_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/subscribers","subscription_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/subscription","commits_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/contents/{+path}","compare_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/merges","archive_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/downloads","issues_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/issues{/number}","pulls_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/pulls{/number}","milestones_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/milestones{/number}","notifications_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/labels{/name}","releases_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/releases{/id}","created_at":"2014-11-21T14:41:36Z","updated_at":"2015-03-06T10:03:59Z","pushed_at":"2015-03-11T09:22:44Z","git_url":"git://github.com/alphagov/digitalmarketplace-api.git","ssh_url":"git@github.com:alphagov/digitalmarketplace-api.git","clone_url":"https://github.com/alphagov/digitalmarketplace-api.git","svn_url":"https://github.com/alphagov/digitalmarketplace-api","homepage":null,"size":1148,"stargazers_count":2,"watchers_count":2,"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":2,"default_branch":"master"}},"base":{"label":"alphagov:master","ref":"master","sha":"32770ded9f6cbf0369e8c0dac4f56879fe5015ec","user":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"repo":{"id":26963583,"name":"digitalmarketplace-api","full_name":"alphagov/digitalmarketplace-api","owner":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/alphagov/digitalmarketplace-api","description":"Digital Marketplace API.","fork":false,"url":"https://api.github.com/repos/alphagov/digitalmarketplace-api","forks_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/forks","keys_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/teams","hooks_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/hooks","issue_events_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/issues/events{/number}","events_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/events","assignees_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/assignees{/user}","branches_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/branches{/branch}","tags_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/tags","blobs_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/statuses/{sha}","languages_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/languages","stargazers_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/stargazers","contributors_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/contributors","subscribers_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/subscribers","subscription_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/subscription","commits_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/contents/{+path}","compare_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/merges","archive_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/downloads","issues_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/issues{/number}","pulls_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/pulls{/number}","milestones_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/milestones{/number}","notifications_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/labels{/name}","releases_url":"https://api.github.com/repos/alphagov/digitalmarketplace-api/releases{/id}","created_at":"2014-11-21T14:41:36Z","updated_at":"2015-03-06T10:03:59Z","pushed_at":"2015-03-11T09:22:44Z","git_url":"git://github.com/alphagov/digitalmarketplace-api.git","ssh_url":"git@github.com:alphagov/digitalmarketplace-api.git","clone_url":"https://github.com/alphagov/digitalmarketplace-api.git","svn_url":"https://github.com/alphagov/digitalmarketplace-api","homepage":null,"size":1148,"stargazers_count":2,"watchers_count":2,"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":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/alphagov/digitalmarketplace-api/pulls/45"},"html":{"href":"https://github.com/alphagov/digitalmarketplace-api/pull/45"},"issue":{"href":"https://api.github.com/repos/alphagov/digitalmarketplace-api/issues/45"},"comments":{"href":"https://api.github.com/repos/alphagov/digitalmarketplace-api/issues/45/comments"},"review_comments":{"href":"https://api.github.com/repos/alphagov/digitalmarketplace-api/pulls/45/comments"},"review_comment":{"href":"https://api.github.com/repos/alphagov/digitalmarketplace-api/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/alphagov/digitalmarketplace-api/pulls/45/commits"},"statuses":{"href":"https://api.github.com/repos/alphagov/digitalmarketplace-api/statuses/f2c2d358ca89d726801b95ded4458e33812b8b8b"}}}}