{"action":"created","comment":{"url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/pulls/comments/90611632","pull_request_review_id":11128049,"id":90611632,"diff_hunk":"@@ -41,15 +44,73 @@ def test_schema(self):\n             self.fail(\"{} Schema Validation Errors.\".format(len(errors)))\n \n     @staticmethod\n-    def validate_json_against_schema(file, json_file, schema):\n+    def validate_json_against_schema(file, json_to_validate, schema):\n         try:\n-            json_to_validate = json.load(json_file)\n             validate(json_to_validate, schema)\n+            return []\n         except jsonschema.exceptions.ValidationError as e:\n-            return \"Schema Validation Error! File [{}] does not validate against schema. Error [{}]\".format(file, e)\n+            return [\"Schema Validation Error! File [{}] does not validate against schema. Error [{}]\".format(file, e)]\n         except JSONDecodeError as e:\n-            return \"JSON Parse Error! Could not parse [{}]. Error [{}]\".format(file, e)\n+            return [\"JSON Parse Error! Could not parse [{}]. Error [{}]\".format(file, e)]\n+\n+\n+    @staticmethod\n+    def validate_schema_contains_valid_routing_rules(file, json_to_validate):\n+\n+        errors = []\n+\n+        for block in SchemaHelper.get_blocks(json_to_validate):\n+            if 'routing_rules' in block and len(block['routing_rules']) > 0:\n+                for rule in block['routing_rules']:\n+                    is_goto_rule = 'goto' in rule and 'id' in rule['goto'].keys()\n+                    if is_goto_rule:\n+                        try:\n+                            if rule['goto']['id'] == 'summary':\n+                                continue\n+\n+                            SchemaHelper.get_block(json_to_validate, rule['goto']['id'])\n+                        except StopIteration:\n+                            errors.append(\"Schema Error. File[{}] Routing rule routes to invalid block [{}]\".format(file, rule['goto']['id']))\n+\n+        return errors\n+\n+\n+    @staticmethod\n+    def validate_schema_containing_routing_rules_has_default_if_nots_all_answers_routed(file, json_to_validate):\n+\n+        errors = []\n+\n+        for block in SchemaHelper.get_blocks(json_to_validate):\n+\n+            if 'sections' in block:\n+                for section in block['sections']:\n+                    if 'questions' in section:\n+                        for question in section['questions']:\n+                            if 'answers' in question:\n+                                for answer in question['answers']:\n+                                    if answer['type'] == 'Radio' or answer['type'] == 'Checkbox':\n+\n+                                        if 'routing_rules' in block and len(block['routing_rules']) > 0:\n+\n+                                            options = []","path":"tests/app/data/test_schema_validation.py","position":80,"original_position":80,"commit_id":"ddc09c7ab6a794067be33a137d26fd2828217226","original_commit_id":"e1b2742b518594ed481cea6be01fc45859e63fb2","user":{"login":"benjefferies","id":15050019,"avatar_url":"https://avatars.githubusercontent.com/u/15050019?v=3","gravatar_id":"","url":"https://api.github.com/users/benjefferies","html_url":"https://github.com/benjefferies","followers_url":"https://api.github.com/users/benjefferies/followers","following_url":"https://api.github.com/users/benjefferies/following{/other_user}","gists_url":"https://api.github.com/users/benjefferies/gists{/gist_id}","starred_url":"https://api.github.com/users/benjefferies/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benjefferies/subscriptions","organizations_url":"https://api.github.com/users/benjefferies/orgs","repos_url":"https://api.github.com/users/benjefferies/repos","events_url":"https://api.github.com/users/benjefferies/events{/privacy}","received_events_url":"https://api.github.com/users/benjefferies/received_events","type":"User","site_admin":false},"body":"Could do some nice bit of python magic here\r\n\r\n```\r\noptions = [option['value'] for option in answer['options']]\r\n```","created_at":"2016-12-02T09:39:53Z","updated_at":"2016-12-02T09:43:28Z","html_url":"https://github.com/ONSdigital/eq-survey-runner/pull/608#discussion_r90611632","pull_request_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/pulls/608","_links":{"self":{"href":"https://api.github.com/repos/ONSdigital/eq-survey-runner/pulls/comments/90611632"},"html":{"href":"https://github.com/ONSdigital/eq-survey-runner/pull/608#discussion_r90611632"},"pull_request":{"href":"https://api.github.com/repos/ONSdigital/eq-survey-runner/pulls/608"}}},"pull_request":{"url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/pulls/608","id":96095093,"html_url":"https://github.com/ONSdigital/eq-survey-runner/pull/608","diff_url":"https://github.com/ONSdigital/eq-survey-runner/pull/608.diff","patch_url":"https://github.com/ONSdigital/eq-survey-runner/pull/608.patch","issue_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/issues/608","number":608,"state":"open","locked":false,"title":"Extend schema validation to validate routing rules are valid","user":{"login":"jonnyshaw89","id":7594012,"avatar_url":"https://avatars.githubusercontent.com/u/7594012?v=3","gravatar_id":"","url":"https://api.github.com/users/jonnyshaw89","html_url":"https://github.com/jonnyshaw89","followers_url":"https://api.github.com/users/jonnyshaw89/followers","following_url":"https://api.github.com/users/jonnyshaw89/following{/other_user}","gists_url":"https://api.github.com/users/jonnyshaw89/gists{/gist_id}","starred_url":"https://api.github.com/users/jonnyshaw89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonnyshaw89/subscriptions","organizations_url":"https://api.github.com/users/jonnyshaw89/orgs","repos_url":"https://api.github.com/users/jonnyshaw89/repos","events_url":"https://api.github.com/users/jonnyshaw89/events{/privacy}","received_events_url":"https://api.github.com/users/jonnyshaw89/received_events","type":"User","site_admin":false},"body":"### What is the context of this PR?\r\nExtend the schema validation test to ensure that the routing rules are semantically correct and cover all scenarios. \r\n\r\nFixes 601 and Fixes 602\r\n\r\n### How to review \r\nRe-test issues.\r\n","created_at":"2016-12-01T14:09:27Z","updated_at":"2016-12-02T09:43:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3660bb19929e40381c0da2d64f7c7af690b99269","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/pulls/608/commits","review_comments_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/pulls/608/comments","review_comment_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/issues/608/comments","statuses_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/statuses/ddc09c7ab6a794067be33a137d26fd2828217226","head":{"label":"ONSdigital:extend-schema-validation","ref":"extend-schema-validation","sha":"ddc09c7ab6a794067be33a137d26fd2828217226","user":{"login":"ONSdigital","id":6865137,"avatar_url":"https://avatars.githubusercontent.com/u/6865137?v=3","gravatar_id":"","url":"https://api.github.com/users/ONSdigital","html_url":"https://github.com/ONSdigital","followers_url":"https://api.github.com/users/ONSdigital/followers","following_url":"https://api.github.com/users/ONSdigital/following{/other_user}","gists_url":"https://api.github.com/users/ONSdigital/gists{/gist_id}","starred_url":"https://api.github.com/users/ONSdigital/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ONSdigital/subscriptions","organizations_url":"https://api.github.com/users/ONSdigital/orgs","repos_url":"https://api.github.com/users/ONSdigital/repos","events_url":"https://api.github.com/users/ONSdigital/events{/privacy}","received_events_url":"https://api.github.com/users/ONSdigital/received_events","type":"Organization","site_admin":false},"repo":{"id":49205589,"name":"eq-survey-runner","full_name":"ONSdigital/eq-survey-runner","owner":{"login":"ONSdigital","id":6865137,"avatar_url":"https://avatars.githubusercontent.com/u/6865137?v=3","gravatar_id":"","url":"https://api.github.com/users/ONSdigital","html_url":"https://github.com/ONSdigital","followers_url":"https://api.github.com/users/ONSdigital/followers","following_url":"https://api.github.com/users/ONSdigital/following{/other_user}","gists_url":"https://api.github.com/users/ONSdigital/gists{/gist_id}","starred_url":"https://api.github.com/users/ONSdigital/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ONSdigital/subscriptions","organizations_url":"https://api.github.com/users/ONSdigital/orgs","repos_url":"https://api.github.com/users/ONSdigital/repos","events_url":"https://api.github.com/users/ONSdigital/events{/privacy}","received_events_url":"https://api.github.com/users/ONSdigital/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ONSdigital/eq-survey-runner","description":"eQ Survey Runner","fork":false,"url":"https://api.github.com/repos/ONSdigital/eq-survey-runner","forks_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/forks","keys_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/teams","hooks_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/hooks","issue_events_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/issues/events{/number}","events_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/events","assignees_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/assignees{/user}","branches_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/branches{/branch}","tags_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/tags","blobs_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/git/refs{/sha}","trees_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/statuses/{sha}","languages_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/languages","stargazers_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/stargazers","contributors_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/contributors","subscribers_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/subscribers","subscription_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/subscription","commits_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/commits{/sha}","git_commits_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/git/commits{/sha}","comments_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/comments{/number}","issue_comment_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/issues/comments{/number}","contents_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/contents/{+path}","compare_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/merges","archive_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/downloads","issues_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/issues{/number}","pulls_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/pulls{/number}","milestones_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/milestones{/number}","notifications_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/labels{/name}","releases_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/releases{/id}","deployments_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/deployments","created_at":"2016-01-07T13:15:26Z","updated_at":"2016-11-10T09:21:31Z","pushed_at":"2016-12-02T09:42:59Z","git_url":"git://github.com/ONSdigital/eq-survey-runner.git","ssh_url":"git@github.com:ONSdigital/eq-survey-runner.git","clone_url":"https://github.com/ONSdigital/eq-survey-runner.git","svn_url":"https://github.com/ONSdigital/eq-survey-runner","homepage":null,"size":8620,"stargazers_count":5,"watchers_count":5,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":22,"forks":2,"open_issues":22,"watchers":5,"default_branch":"master"}},"base":{"label":"ONSdigital:master","ref":"master","sha":"f5ef411732e278413f4f9db265e7276c07c55e7b","user":{"login":"ONSdigital","id":6865137,"avatar_url":"https://avatars.githubusercontent.com/u/6865137?v=3","gravatar_id":"","url":"https://api.github.com/users/ONSdigital","html_url":"https://github.com/ONSdigital","followers_url":"https://api.github.com/users/ONSdigital/followers","following_url":"https://api.github.com/users/ONSdigital/following{/other_user}","gists_url":"https://api.github.com/users/ONSdigital/gists{/gist_id}","starred_url":"https://api.github.com/users/ONSdigital/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ONSdigital/subscriptions","organizations_url":"https://api.github.com/users/ONSdigital/orgs","repos_url":"https://api.github.com/users/ONSdigital/repos","events_url":"https://api.github.com/users/ONSdigital/events{/privacy}","received_events_url":"https://api.github.com/users/ONSdigital/received_events","type":"Organization","site_admin":false},"repo":{"id":49205589,"name":"eq-survey-runner","full_name":"ONSdigital/eq-survey-runner","owner":{"login":"ONSdigital","id":6865137,"avatar_url":"https://avatars.githubusercontent.com/u/6865137?v=3","gravatar_id":"","url":"https://api.github.com/users/ONSdigital","html_url":"https://github.com/ONSdigital","followers_url":"https://api.github.com/users/ONSdigital/followers","following_url":"https://api.github.com/users/ONSdigital/following{/other_user}","gists_url":"https://api.github.com/users/ONSdigital/gists{/gist_id}","starred_url":"https://api.github.com/users/ONSdigital/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ONSdigital/subscriptions","organizations_url":"https://api.github.com/users/ONSdigital/orgs","repos_url":"https://api.github.com/users/ONSdigital/repos","events_url":"https://api.github.com/users/ONSdigital/events{/privacy}","received_events_url":"https://api.github.com/users/ONSdigital/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ONSdigital/eq-survey-runner","description":"eQ Survey Runner","fork":false,"url":"https://api.github.com/repos/ONSdigital/eq-survey-runner","forks_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/forks","keys_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/teams","hooks_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/hooks","issue_events_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/issues/events{/number}","events_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/events","assignees_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/assignees{/user}","branches_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/branches{/branch}","tags_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/tags","blobs_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/git/refs{/sha}","trees_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/statuses/{sha}","languages_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/languages","stargazers_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/stargazers","contributors_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/contributors","subscribers_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/subscribers","subscription_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/subscription","commits_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/commits{/sha}","git_commits_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/git/commits{/sha}","comments_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/comments{/number}","issue_comment_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/issues/comments{/number}","contents_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/contents/{+path}","compare_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/merges","archive_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/downloads","issues_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/issues{/number}","pulls_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/pulls{/number}","milestones_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/milestones{/number}","notifications_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/labels{/name}","releases_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/releases{/id}","deployments_url":"https://api.github.com/repos/ONSdigital/eq-survey-runner/deployments","created_at":"2016-01-07T13:15:26Z","updated_at":"2016-11-10T09:21:31Z","pushed_at":"2016-12-02T09:42:59Z","git_url":"git://github.com/ONSdigital/eq-survey-runner.git","ssh_url":"git@github.com:ONSdigital/eq-survey-runner.git","clone_url":"https://github.com/ONSdigital/eq-survey-runner.git","svn_url":"https://github.com/ONSdigital/eq-survey-runner","homepage":null,"size":8620,"stargazers_count":5,"watchers_count":5,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":22,"forks":2,"open_issues":22,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ONSdigital/eq-survey-runner/pulls/608"},"html":{"href":"https://github.com/ONSdigital/eq-survey-runner/pull/608"},"issue":{"href":"https://api.github.com/repos/ONSdigital/eq-survey-runner/issues/608"},"comments":{"href":"https://api.github.com/repos/ONSdigital/eq-survey-runner/issues/608/comments"},"review_comments":{"href":"https://api.github.com/repos/ONSdigital/eq-survey-runner/pulls/608/comments"},"review_comment":{"href":"https://api.github.com/repos/ONSdigital/eq-survey-runner/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ONSdigital/eq-survey-runner/pulls/608/commits"},"statuses":{"href":"https://api.github.com/repos/ONSdigital/eq-survey-runner/statuses/ddc09c7ab6a794067be33a137d26fd2828217226"}}}}
{"actor":{"display_login":"benjefferies"}}