{"action":"created","comment":{"url":"https://api.github.com/repos/ga4gh/server/pulls/comments/24366743","id":24366743,"diff_hunk":"@@ -84,61 +71,10 @@ def getInvalidValue(self, cls, fieldName):\n         Returns a value that should trigger a schema validation failure.\n         \"\"\"\n         field = self.getAvroSchema(cls, fieldName)\n-        typ = field.type\n-        if isinstance(typ, avro.schema.UnionSchema):\n-            typ = typ.schemas[1]\n-        if isinstance(typ, avro.schema.MapSchema):\n-            ret = [\"string\"]\n-        elif isinstance(typ, avro.schema.ArraySchema):\n-            ret = 42.0\n-        elif isinstance(typ, avro.schema.EnumSchema):\n-            ret = \"NO ENUM COULD HAVE THIS NAME\"\n-        elif isinstance(typ, avro.schema.RecordSchema):\n-            ret = 42\n-        elif typ.type in self.badValueMap:\n-            ret = self.badValueMap[typ.type]\n-        else:\n-            raise Exception(\"schema assumptions violated\")\n-        return ret\n-\n-    def getRandomValue(self, cls, fieldName):\n-        \"\"\"\n-        Returns a value randomly generated conforming to the schema.\n-        \"\"\"\n-        maxListSize = 10\n-        field = self.getAvroSchema(cls, fieldName)\n-        typ = field.type\n-        if isinstance(typ, avro.schema.UnionSchema):\n-            # TODO put in some probability that return None if\n-            # we have a union schema\n-            typ = typ.schemas[1]\n-        if isinstance(typ, avro.schema.MapSchema):\n-            ret = {}\n-            for j in range(random.randint(0, maxListSize)):\n-                randStr = [randomString() for _ in range(\n-                    random.randint(0, maxListSize))]\n-                ret[\"key{0}\".format(j)] = randStr\n-        elif isinstance(typ, avro.schema.ArraySchema):\n-            randInt = random.randint(0, maxListSize)\n-            if cls.isEmbeddedType(field.name):\n-                embeddedClass = cls.getEmbeddedType(field.name)\n-\n-                def getRandInst():\n-                    return self.getRandomInstance(embeddedClass)\n-            else:\n-                getRandInst = self.randomValueMap[typ.items.type]\n-            ret = [getRandInst() for j in range(randInt)]\n-        elif isinstance(typ, avro.schema.EnumSchema):\n-            ret = random.choice(typ.symbols)\n-        elif isinstance(typ, avro.schema.RecordSchema):\n-            self.assertTrue(cls.isEmbeddedType(fieldName))\n-            embeddedClass = cls.getEmbeddedType(fieldName)\n-            ret = self.getRandomInstance(embeddedClass)\n-        elif typ.type in self.randomValueMap:\n-            ret = self.randomValueMap[typ.type]()\n-        else:\n-            raise Exception(\"schema assumptions violated\")\n-        return ret\n+        t = field.type\n+        if isinstance(t, avro.schema.UnionSchema):\n+            t = t.schemas[1]","path":"tests/test_schemas.py","position":94,"original_position":94,"commit_id":"88ceaa61647a8812845b6d95d4b635b1b384731f","original_commit_id":"88ceaa61647a8812845b6d95d4b635b1b384731f","user":{"login":"Naburimannu","id":6696224,"avatar_url":"https://avatars.githubusercontent.com/u/6696224?v=3","gravatar_id":"","url":"https://api.github.com/users/Naburimannu","html_url":"https://github.com/Naburimannu","followers_url":"https://api.github.com/users/Naburimannu/followers","following_url":"https://api.github.com/users/Naburimannu/following{/other_user}","gists_url":"https://api.github.com/users/Naburimannu/gists{/gist_id}","starred_url":"https://api.github.com/users/Naburimannu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Naburimannu/subscriptions","organizations_url":"https://api.github.com/users/Naburimannu/orgs","repos_url":"https://api.github.com/users/Naburimannu/repos","events_url":"https://api.github.com/users/Naburimannu/events{/privacy}","received_events_url":"https://api.github.com/users/Naburimannu/received_events","type":"User","site_admin":false},"body":"Nit: this looks like it could be accidentally correct, but is probably good enough?\r\n(e.g. starting with a union (Int, String), we'll try to generate an incorrect int, so we generate random other type, and our RNG selects a string?) ","created_at":"2015-02-09T21:24:58Z","updated_at":"2015-02-09T21:24:58Z","html_url":"https://github.com/ga4gh/server/pull/133#discussion_r24366743","pull_request_url":"https://api.github.com/repos/ga4gh/server/pulls/133","_links":{"self":{"href":"https://api.github.com/repos/ga4gh/server/pulls/comments/24366743"},"html":{"href":"https://github.com/ga4gh/server/pull/133#discussion_r24366743"},"pull_request":{"href":"https://api.github.com/repos/ga4gh/server/pulls/133"}}},"pull_request":{"url":"https://api.github.com/repos/ga4gh/server/pulls/133","id":28843339,"html_url":"https://github.com/ga4gh/server/pull/133","diff_url":"https://github.com/ga4gh/server/pull/133.diff","patch_url":"https://github.com/ga4gh/server/pull/133.patch","issue_url":"https://api.github.com/repos/ga4gh/server/issues/133","number":133,"state":"open","locked":false,"title":"Add a suite of generators for avro schemas.","user":{"login":"pashields","id":170202,"avatar_url":"https://avatars.githubusercontent.com/u/170202?v=3","gravatar_id":"","url":"https://api.github.com/users/pashields","html_url":"https://github.com/pashields","followers_url":"https://api.github.com/users/pashields/followers","following_url":"https://api.github.com/users/pashields/following{/other_user}","gists_url":"https://api.github.com/users/pashields/gists{/gist_id}","starred_url":"https://api.github.com/users/pashields/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pashields/subscriptions","organizations_url":"https://api.github.com/users/pashields/orgs","repos_url":"https://api.github.com/users/pashields/repos","events_url":"https://api.github.com/users/pashields/events{/privacy}","received_events_url":"https://api.github.com/users/pashields/received_events","type":"User","site_admin":false},"body":"These can be used by tests to generate random instances of classes, both valid and invalid. This mostly pulls out some work started by @jeromekelleher and tries to make it a little less hairy looking.\r\n\r\nThere are lots of directions to take this in (mostly adding more tweakability and an actual test script for longer scale generative testing), but I think it's useful enough as it is here to get it in.\r\n\r\nLet me know if y'all think this is useful.","created_at":"2015-02-06T21:26:36Z","updated_at":"2015-02-09T21:24:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3918759d446b4fa16e40e02dcdab83eac36f5c07","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ga4gh/server/pulls/133/commits","review_comments_url":"https://api.github.com/repos/ga4gh/server/pulls/133/comments","review_comment_url":"https://api.github.com/repos/ga4gh/server/pulls/comments/{number}","comments_url":"https://api.github.com/repos/ga4gh/server/issues/133/comments","statuses_url":"https://api.github.com/repos/ga4gh/server/statuses/88ceaa61647a8812845b6d95d4b635b1b384731f","head":{"label":"pashields:generative","ref":"generative","sha":"88ceaa61647a8812845b6d95d4b635b1b384731f","user":{"login":"pashields","id":170202,"avatar_url":"https://avatars.githubusercontent.com/u/170202?v=3","gravatar_id":"","url":"https://api.github.com/users/pashields","html_url":"https://github.com/pashields","followers_url":"https://api.github.com/users/pashields/followers","following_url":"https://api.github.com/users/pashields/following{/other_user}","gists_url":"https://api.github.com/users/pashields/gists{/gist_id}","starred_url":"https://api.github.com/users/pashields/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pashields/subscriptions","organizations_url":"https://api.github.com/users/pashields/orgs","repos_url":"https://api.github.com/users/pashields/repos","events_url":"https://api.github.com/users/pashields/events{/privacy}","received_events_url":"https://api.github.com/users/pashields/received_events","type":"User","site_admin":false},"repo":{"id":26657812,"name":"server","full_name":"pashields/server","owner":{"login":"pashields","id":170202,"avatar_url":"https://avatars.githubusercontent.com/u/170202?v=3","gravatar_id":"","url":"https://api.github.com/users/pashields","html_url":"https://github.com/pashields","followers_url":"https://api.github.com/users/pashields/followers","following_url":"https://api.github.com/users/pashields/following{/other_user}","gists_url":"https://api.github.com/users/pashields/gists{/gist_id}","starred_url":"https://api.github.com/users/pashields/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pashields/subscriptions","organizations_url":"https://api.github.com/users/pashields/orgs","repos_url":"https://api.github.com/users/pashields/repos","events_url":"https://api.github.com/users/pashields/events{/privacy}","received_events_url":"https://api.github.com/users/pashields/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pashields/server","description":"A reference implementation of the APIs defined in the schemas repository.","fork":true,"url":"https://api.github.com/repos/pashields/server","forks_url":"https://api.github.com/repos/pashields/server/forks","keys_url":"https://api.github.com/repos/pashields/server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pashields/server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pashields/server/teams","hooks_url":"https://api.github.com/repos/pashields/server/hooks","issue_events_url":"https://api.github.com/repos/pashields/server/issues/events{/number}","events_url":"https://api.github.com/repos/pashields/server/events","assignees_url":"https://api.github.com/repos/pashields/server/assignees{/user}","branches_url":"https://api.github.com/repos/pashields/server/branches{/branch}","tags_url":"https://api.github.com/repos/pashields/server/tags","blobs_url":"https://api.github.com/repos/pashields/server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pashields/server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pashields/server/git/refs{/sha}","trees_url":"https://api.github.com/repos/pashields/server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pashields/server/statuses/{sha}","languages_url":"https://api.github.com/repos/pashields/server/languages","stargazers_url":"https://api.github.com/repos/pashields/server/stargazers","contributors_url":"https://api.github.com/repos/pashields/server/contributors","subscribers_url":"https://api.github.com/repos/pashields/server/subscribers","subscription_url":"https://api.github.com/repos/pashields/server/subscription","commits_url":"https://api.github.com/repos/pashields/server/commits{/sha}","git_commits_url":"https://api.github.com/repos/pashields/server/git/commits{/sha}","comments_url":"https://api.github.com/repos/pashields/server/comments{/number}","issue_comment_url":"https://api.github.com/repos/pashields/server/issues/comments/{number}","contents_url":"https://api.github.com/repos/pashields/server/contents/{+path}","compare_url":"https://api.github.com/repos/pashields/server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pashields/server/merges","archive_url":"https://api.github.com/repos/pashields/server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pashields/server/downloads","issues_url":"https://api.github.com/repos/pashields/server/issues{/number}","pulls_url":"https://api.github.com/repos/pashields/server/pulls{/number}","milestones_url":"https://api.github.com/repos/pashields/server/milestones{/number}","notifications_url":"https://api.github.com/repos/pashields/server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pashields/server/labels{/name}","releases_url":"https://api.github.com/repos/pashields/server/releases{/id}","created_at":"2014-11-14T21:14:29Z","updated_at":"2015-02-06T21:08:54Z","pushed_at":"2015-02-09T21:06:27Z","git_url":"git://github.com/pashields/server.git","ssh_url":"git@github.com:pashields/server.git","clone_url":"https://github.com/pashields/server.git","svn_url":"https://github.com/pashields/server","homepage":null,"size":446,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"ga4gh:master","ref":"master","sha":"b5dd8b99ad7c9c8c5237b5ce8bdeca8f195a31a8","user":{"login":"ga4gh","id":6921777,"avatar_url":"https://avatars.githubusercontent.com/u/6921777?v=3","gravatar_id":"","url":"https://api.github.com/users/ga4gh","html_url":"https://github.com/ga4gh","followers_url":"https://api.github.com/users/ga4gh/followers","following_url":"https://api.github.com/users/ga4gh/following{/other_user}","gists_url":"https://api.github.com/users/ga4gh/gists{/gist_id}","starred_url":"https://api.github.com/users/ga4gh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ga4gh/subscriptions","organizations_url":"https://api.github.com/users/ga4gh/orgs","repos_url":"https://api.github.com/users/ga4gh/repos","events_url":"https://api.github.com/users/ga4gh/events{/privacy}","received_events_url":"https://api.github.com/users/ga4gh/received_events","type":"Organization","site_admin":false},"repo":{"id":22882621,"name":"server","full_name":"ga4gh/server","owner":{"login":"ga4gh","id":6921777,"avatar_url":"https://avatars.githubusercontent.com/u/6921777?v=3","gravatar_id":"","url":"https://api.github.com/users/ga4gh","html_url":"https://github.com/ga4gh","followers_url":"https://api.github.com/users/ga4gh/followers","following_url":"https://api.github.com/users/ga4gh/following{/other_user}","gists_url":"https://api.github.com/users/ga4gh/gists{/gist_id}","starred_url":"https://api.github.com/users/ga4gh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ga4gh/subscriptions","organizations_url":"https://api.github.com/users/ga4gh/orgs","repos_url":"https://api.github.com/users/ga4gh/repos","events_url":"https://api.github.com/users/ga4gh/events{/privacy}","received_events_url":"https://api.github.com/users/ga4gh/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ga4gh/server","description":"A reference implementation of the APIs defined in the schemas repository.","fork":false,"url":"https://api.github.com/repos/ga4gh/server","forks_url":"https://api.github.com/repos/ga4gh/server/forks","keys_url":"https://api.github.com/repos/ga4gh/server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ga4gh/server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ga4gh/server/teams","hooks_url":"https://api.github.com/repos/ga4gh/server/hooks","issue_events_url":"https://api.github.com/repos/ga4gh/server/issues/events{/number}","events_url":"https://api.github.com/repos/ga4gh/server/events","assignees_url":"https://api.github.com/repos/ga4gh/server/assignees{/user}","branches_url":"https://api.github.com/repos/ga4gh/server/branches{/branch}","tags_url":"https://api.github.com/repos/ga4gh/server/tags","blobs_url":"https://api.github.com/repos/ga4gh/server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ga4gh/server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ga4gh/server/git/refs{/sha}","trees_url":"https://api.github.com/repos/ga4gh/server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ga4gh/server/statuses/{sha}","languages_url":"https://api.github.com/repos/ga4gh/server/languages","stargazers_url":"https://api.github.com/repos/ga4gh/server/stargazers","contributors_url":"https://api.github.com/repos/ga4gh/server/contributors","subscribers_url":"https://api.github.com/repos/ga4gh/server/subscribers","subscription_url":"https://api.github.com/repos/ga4gh/server/subscription","commits_url":"https://api.github.com/repos/ga4gh/server/commits{/sha}","git_commits_url":"https://api.github.com/repos/ga4gh/server/git/commits{/sha}","comments_url":"https://api.github.com/repos/ga4gh/server/comments{/number}","issue_comment_url":"https://api.github.com/repos/ga4gh/server/issues/comments/{number}","contents_url":"https://api.github.com/repos/ga4gh/server/contents/{+path}","compare_url":"https://api.github.com/repos/ga4gh/server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ga4gh/server/merges","archive_url":"https://api.github.com/repos/ga4gh/server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ga4gh/server/downloads","issues_url":"https://api.github.com/repos/ga4gh/server/issues{/number}","pulls_url":"https://api.github.com/repos/ga4gh/server/pulls{/number}","milestones_url":"https://api.github.com/repos/ga4gh/server/milestones{/number}","notifications_url":"https://api.github.com/repos/ga4gh/server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ga4gh/server/labels{/name}","releases_url":"https://api.github.com/repos/ga4gh/server/releases{/id}","created_at":"2014-08-12T15:31:49Z","updated_at":"2015-02-09T17:41:39Z","pushed_at":"2015-02-09T17:41:39Z","git_url":"git://github.com/ga4gh/server.git","ssh_url":"git@github.com:ga4gh/server.git","clone_url":"https://github.com/ga4gh/server.git","svn_url":"https://github.com/ga4gh/server","homepage":null,"size":1713,"stargazers_count":21,"watchers_count":21,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":22,"mirror_url":null,"open_issues_count":39,"forks":22,"open_issues":39,"watchers":21,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ga4gh/server/pulls/133"},"html":{"href":"https://github.com/ga4gh/server/pull/133"},"issue":{"href":"https://api.github.com/repos/ga4gh/server/issues/133"},"comments":{"href":"https://api.github.com/repos/ga4gh/server/issues/133/comments"},"review_comments":{"href":"https://api.github.com/repos/ga4gh/server/pulls/133/comments"},"review_comment":{"href":"https://api.github.com/repos/ga4gh/server/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/ga4gh/server/pulls/133/commits"},"statuses":{"href":"https://api.github.com/repos/ga4gh/server/statuses/88ceaa61647a8812845b6d95d4b635b1b384731f"}}}}