{"action":"created","comment":{"url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/pulls/comments/73240779","id":73240779,"diff_hunk":"@@ -0,0 +1,305 @@\n+import logging\n+import unittest\n+\n+try:\n+    from unittest import mock\n+except ImportError:\n+    import mock\n+import psycopg2\n+import sqlalchemy\n+import testing.postgresql\n+\n+from pedsnetdcc.indexes import _indexes_sql, add_indexes, drop_indexes\n+from pedsnetdcc.utils import make_conn_str, stock_metadata\n+from pedsnetdcc import TRANSFORMS\n+from pedsnetdcc.db import Statement\n+\n+\n+logging.basicConfig(level=logging.DEBUG, filename=\"logfile\")\n+\n+\n+def setUpModule():\n+    # Generate a Postgresql class which caches the init-ed database across\n+    # multiple ephemeral database cluster instances.\n+    global Postgresql\n+    Postgresql = testing.postgresql.PostgresqlFactory(\n+        cache_intialized_db=True)\n+\n+\n+def tearDownModule():\n+    # Clear cached init-ed database at end of tests.\n+    Postgresql.clear_cache()\n+\n+\n+class IndexesTest(unittest.TestCase):\n+\n+    def setUp(self):\n+        self.model_version = '2.2.0'\n+\n+    def test_add_indexes(self):\n+        sql = _indexes_sql(self.model_version)\n+\n+        sample_expected = (\n+            'CREATE INDEX obs_otcn_89a4742c38ecb8ba35_ix ON observation (observation_type_concept_name)',\n+            'CREATE INDEX dea_s_4906dc6995505fc71431f_ix ON death (site)',\n+            'CREATE INDEX vis_vsaim_f1537dca8da9ab914_ix ON visit_occurrence (visit_start_age_in_months)',\n+        )\n+        for sample in sample_expected:\n+            self.assertIn(sample, sql)\n+\n+        sample_not_expected = (\n+            'CREATE INDEX idx_concept_vocabluary_id ON concept (vocabulary_id)',\n+        )\n+        for sample in sample_not_expected:\n+            self.assertNotIn(sample, sql)\n+\n+    def test_drop_indexes(self):\n+        sql = _indexes_sql(self.model_version, drop=True)\n+\n+        sample_expected = (\n+            'DROP INDEX obs_otcn_89a4742c38ecb8ba35_ix',\n+            'DROP INDEX dea_s_4906dc6995505fc71431f_ix',\n+            'DROP INDEX vis_vsaim_f1537dca8da9ab914_ix'\n+        )\n+        for sample in sample_expected:\n+            self.assertIn(sample, sql)\n+\n+        sample_not_expected = (\n+            'CREATE INDEX idx_concept_vocabluary_id ON concept (vocabulary_id)',","path":"pedsnetdcc/tests/indexes_test.py","position":51,"original_position":68,"commit_id":"1c165f00022108c1449b152a212396cd50d7a1b1","original_commit_id":"1c165f00022108c1449b152a212396cd50d7a1b1","user":{"login":"aaron0browne","id":3409975,"avatar_url":"https://avatars.githubusercontent.com/u/3409975?v=3","gravatar_id":"","url":"https://api.github.com/users/aaron0browne","html_url":"https://github.com/aaron0browne","followers_url":"https://api.github.com/users/aaron0browne/followers","following_url":"https://api.github.com/users/aaron0browne/following{/other_user}","gists_url":"https://api.github.com/users/aaron0browne/gists{/gist_id}","starred_url":"https://api.github.com/users/aaron0browne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aaron0browne/subscriptions","organizations_url":"https://api.github.com/users/aaron0browne/orgs","repos_url":"https://api.github.com/users/aaron0browne/repos","events_url":"https://api.github.com/users/aaron0browne/events{/privacy}","received_events_url":"https://api.github.com/users/aaron0browne/received_events","type":"User","site_admin":false},"body":"Should be a `DROP` statement.","created_at":"2016-08-02T21:25:10Z","updated_at":"2016-08-02T21:25:10Z","html_url":"https://github.com/PEDSnet/pedsnetdcc/pull/22#discussion_r73240779","pull_request_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/pulls/22","_links":{"self":{"href":"https://api.github.com/repos/PEDSnet/pedsnetdcc/pulls/comments/73240779"},"html":{"href":"https://github.com/PEDSnet/pedsnetdcc/pull/22#discussion_r73240779"},"pull_request":{"href":"https://api.github.com/repos/PEDSnet/pedsnetdcc/pulls/22"}}},"pull_request":{"url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/pulls/22","id":76038809,"html_url":"https://github.com/PEDSnet/pedsnetdcc/pull/22","diff_url":"https://github.com/PEDSnet/pedsnetdcc/pull/22.diff","patch_url":"https://github.com/PEDSnet/pedsnetdcc/pull/22.patch","issue_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/issues/22","number":22,"state":"open","locked":false,"title":"Issue 9 - add/drop indexes ","user":{"login":"murphyke","id":928642,"avatar_url":"https://avatars.githubusercontent.com/u/928642?v=3","gravatar_id":"","url":"https://api.github.com/users/murphyke","html_url":"https://github.com/murphyke","followers_url":"https://api.github.com/users/murphyke/followers","following_url":"https://api.github.com/users/murphyke/following{/other_user}","gists_url":"https://api.github.com/users/murphyke/gists{/gist_id}","starred_url":"https://api.github.com/users/murphyke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/murphyke/subscriptions","organizations_url":"https://api.github.com/users/murphyke/orgs","repos_url":"https://api.github.com/users/murphyke/repos","events_url":"https://api.github.com/users/murphyke/events{/privacy}","received_events_url":"https://api.github.com/users/murphyke/received_events","type":"User","site_admin":false},"body":"This isn't ready for merging because it needs to be integrated with the new statement executor.  Currently there is a top-level function:\r\n\r\n    indexes_sql(model_version, drop=False, vocabulary=False)\r\n\r\nthat can generate the index statements for the transformed data model. For now the transformations are defined in a list in pedsnetdcc/__init__.py.\r\n\r\n","created_at":"2016-07-01T21:28:06Z","updated_at":"2016-08-02T21:25:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ac30076dc846ee9a617b9ce259623f3cf5f8862b","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/pulls/22/commits","review_comments_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/pulls/22/comments","review_comment_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/pulls/comments{/number}","comments_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/issues/22/comments","statuses_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/statuses/1c165f00022108c1449b152a212396cd50d7a1b1","head":{"label":"PEDSnet:issue-9","ref":"issue-9","sha":"1c165f00022108c1449b152a212396cd50d7a1b1","user":{"login":"PEDSnet","id":7228066,"avatar_url":"https://avatars.githubusercontent.com/u/7228066?v=3","gravatar_id":"","url":"https://api.github.com/users/PEDSnet","html_url":"https://github.com/PEDSnet","followers_url":"https://api.github.com/users/PEDSnet/followers","following_url":"https://api.github.com/users/PEDSnet/following{/other_user}","gists_url":"https://api.github.com/users/PEDSnet/gists{/gist_id}","starred_url":"https://api.github.com/users/PEDSnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PEDSnet/subscriptions","organizations_url":"https://api.github.com/users/PEDSnet/orgs","repos_url":"https://api.github.com/users/PEDSnet/repos","events_url":"https://api.github.com/users/PEDSnet/events{/privacy}","received_events_url":"https://api.github.com/users/PEDSnet/received_events","type":"Organization","site_admin":false},"repo":{"id":61126517,"name":"pedsnetdcc","full_name":"PEDSnet/pedsnetdcc","owner":{"login":"PEDSnet","id":7228066,"avatar_url":"https://avatars.githubusercontent.com/u/7228066?v=3","gravatar_id":"","url":"https://api.github.com/users/PEDSnet","html_url":"https://github.com/PEDSnet","followers_url":"https://api.github.com/users/PEDSnet/followers","following_url":"https://api.github.com/users/PEDSnet/following{/other_user}","gists_url":"https://api.github.com/users/PEDSnet/gists{/gist_id}","starred_url":"https://api.github.com/users/PEDSnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PEDSnet/subscriptions","organizations_url":"https://api.github.com/users/PEDSnet/orgs","repos_url":"https://api.github.com/users/PEDSnet/repos","events_url":"https://api.github.com/users/PEDSnet/events{/privacy}","received_events_url":"https://api.github.com/users/PEDSnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/PEDSnet/pedsnetdcc","description":"CLI tool for PEDSnet data coordinating center ETL tasks","fork":false,"url":"https://api.github.com/repos/PEDSnet/pedsnetdcc","forks_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/forks","keys_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/teams","hooks_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/hooks","issue_events_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/issues/events{/number}","events_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/events","assignees_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/assignees{/user}","branches_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/branches{/branch}","tags_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/tags","blobs_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/git/refs{/sha}","trees_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/statuses/{sha}","languages_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/languages","stargazers_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/stargazers","contributors_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/contributors","subscribers_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/subscribers","subscription_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/subscription","commits_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/commits{/sha}","git_commits_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/git/commits{/sha}","comments_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/comments{/number}","issue_comment_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/issues/comments{/number}","contents_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/contents/{+path}","compare_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/merges","archive_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/downloads","issues_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/issues{/number}","pulls_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/pulls{/number}","milestones_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/milestones{/number}","notifications_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/labels{/name}","releases_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/releases{/id}","deployments_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/deployments","created_at":"2016-06-14T13:48:09Z","updated_at":"2016-06-20T20:46:28Z","pushed_at":"2016-08-02T15:57:14Z","git_url":"git://github.com/PEDSnet/pedsnetdcc.git","ssh_url":"git@github.com:PEDSnet/pedsnetdcc.git","clone_url":"https://github.com/PEDSnet/pedsnetdcc.git","svn_url":"https://github.com/PEDSnet/pedsnetdcc","homepage":null,"size":123,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":19,"forks":0,"open_issues":19,"watchers":0,"default_branch":"master"}},"base":{"label":"PEDSnet:master","ref":"master","sha":"f8b89776553c8fc96af3e503172771c2f196bf9f","user":{"login":"PEDSnet","id":7228066,"avatar_url":"https://avatars.githubusercontent.com/u/7228066?v=3","gravatar_id":"","url":"https://api.github.com/users/PEDSnet","html_url":"https://github.com/PEDSnet","followers_url":"https://api.github.com/users/PEDSnet/followers","following_url":"https://api.github.com/users/PEDSnet/following{/other_user}","gists_url":"https://api.github.com/users/PEDSnet/gists{/gist_id}","starred_url":"https://api.github.com/users/PEDSnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PEDSnet/subscriptions","organizations_url":"https://api.github.com/users/PEDSnet/orgs","repos_url":"https://api.github.com/users/PEDSnet/repos","events_url":"https://api.github.com/users/PEDSnet/events{/privacy}","received_events_url":"https://api.github.com/users/PEDSnet/received_events","type":"Organization","site_admin":false},"repo":{"id":61126517,"name":"pedsnetdcc","full_name":"PEDSnet/pedsnetdcc","owner":{"login":"PEDSnet","id":7228066,"avatar_url":"https://avatars.githubusercontent.com/u/7228066?v=3","gravatar_id":"","url":"https://api.github.com/users/PEDSnet","html_url":"https://github.com/PEDSnet","followers_url":"https://api.github.com/users/PEDSnet/followers","following_url":"https://api.github.com/users/PEDSnet/following{/other_user}","gists_url":"https://api.github.com/users/PEDSnet/gists{/gist_id}","starred_url":"https://api.github.com/users/PEDSnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PEDSnet/subscriptions","organizations_url":"https://api.github.com/users/PEDSnet/orgs","repos_url":"https://api.github.com/users/PEDSnet/repos","events_url":"https://api.github.com/users/PEDSnet/events{/privacy}","received_events_url":"https://api.github.com/users/PEDSnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/PEDSnet/pedsnetdcc","description":"CLI tool for PEDSnet data coordinating center ETL tasks","fork":false,"url":"https://api.github.com/repos/PEDSnet/pedsnetdcc","forks_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/forks","keys_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/teams","hooks_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/hooks","issue_events_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/issues/events{/number}","events_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/events","assignees_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/assignees{/user}","branches_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/branches{/branch}","tags_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/tags","blobs_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/git/refs{/sha}","trees_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/statuses/{sha}","languages_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/languages","stargazers_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/stargazers","contributors_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/contributors","subscribers_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/subscribers","subscription_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/subscription","commits_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/commits{/sha}","git_commits_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/git/commits{/sha}","comments_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/comments{/number}","issue_comment_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/issues/comments{/number}","contents_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/contents/{+path}","compare_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/merges","archive_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/downloads","issues_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/issues{/number}","pulls_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/pulls{/number}","milestones_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/milestones{/number}","notifications_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/labels{/name}","releases_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/releases{/id}","deployments_url":"https://api.github.com/repos/PEDSnet/pedsnetdcc/deployments","created_at":"2016-06-14T13:48:09Z","updated_at":"2016-06-20T20:46:28Z","pushed_at":"2016-08-02T15:57:14Z","git_url":"git://github.com/PEDSnet/pedsnetdcc.git","ssh_url":"git@github.com:PEDSnet/pedsnetdcc.git","clone_url":"https://github.com/PEDSnet/pedsnetdcc.git","svn_url":"https://github.com/PEDSnet/pedsnetdcc","homepage":null,"size":123,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":19,"forks":0,"open_issues":19,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/PEDSnet/pedsnetdcc/pulls/22"},"html":{"href":"https://github.com/PEDSnet/pedsnetdcc/pull/22"},"issue":{"href":"https://api.github.com/repos/PEDSnet/pedsnetdcc/issues/22"},"comments":{"href":"https://api.github.com/repos/PEDSnet/pedsnetdcc/issues/22/comments"},"review_comments":{"href":"https://api.github.com/repos/PEDSnet/pedsnetdcc/pulls/22/comments"},"review_comment":{"href":"https://api.github.com/repos/PEDSnet/pedsnetdcc/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/PEDSnet/pedsnetdcc/pulls/22/commits"},"statuses":{"href":"https://api.github.com/repos/PEDSnet/pedsnetdcc/statuses/1c165f00022108c1449b152a212396cd50d7a1b1"}}}}
{"actor":{"display_login":"aaron0browne"}}