{"action":"created","comment":{"url":"https://api.github.com/repos/elifesciences/lax/pulls/comments/118853207","pull_request_review_id":40683709,"id":118853207,"diff_hunk":"@@ -16,112 +18,35 @@ def sns_topic_arn(**overrides):\n     LOG.info(\"using topic arn: %s\", arn)\n     return arn\n \n-#\n-#\n-#\n-\n def event_bus_conn(**overrides):\n     sns = boto3.resource('sns')\n     return sns.Topic(sns_topic_arn(**overrides))\n \n-'''\n-# works, but no tests\n-import uuid\n-def _create_queue():\n-    sqs = boto3.resource('sqs')\n-    queue_name = \"lax-temp-listener-\" + str(uuid.uuid4())\n-    LOG.info(\"attempting to create queue %r\", queue_name)\n-    return sqs.create_queue(QueueName=queue_name)\n-\n-def get_message(queue):\n-    messages = []\n-    while not messages:\n-        messages = queue.receive_messages(\n-            MaxNumberOfMessages=1,\n-            VisibilityTimeout=60, # time allowed to call delete, can be increased\n-            WaitTimeSeconds=20 # maximum setting for long polling\n-        )\n-    message = messages[0]\n-    return message\n-\n-def listen(env):\n-    \"creates a temporary queue and subscription to topic (event bus) for given region. destroyed afterwards\"\n-    queue = subscription = perm_label = None\n-    try:\n-        topic = event_bus_conn(env=env)\n-        queue = _create_queue()\n-        queue_arn = queue.attributes['QueueArn']\n-        _bits = queue_arn.split(':')\n-        acc_id, qname = _bits[4], _bits[5]\n-\n-        # queue can receive messages from topic\n-        # this attaches a Policy to the queue that we can modify\n-        queue.add_permission(**{\n-            'Label': 'perm-%s-to-sns' % qname,\n-            'AWSAccountIds': [acc_id],\n-            'Actions': [\n-                '*',\n-            ]\n-        })\n-\n-        # policy ll:\n-        # {\"Version\":\"2008-10-17\",\"Id\":\"arn:aws:sqs:us-east-1:512686554592:lax-temp-listener-b37e2179-3b83-4c00-853d-ee541893ce8e/SQSDefaultPolicy\",\"Statement\":[{\"Sid\":\"perm-lax-temp-listener-b37e2179-3b83-4c00-853d-ee541893ce8e-to-sns\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::512686554592:root\"},\"Action\":\"SQS:*\",\"Resource\":\"arn:aws:sqs:us-east-1:512686554592:lax-temp-listener-b37e2179-3b83-4c00-853d-ee541893ce8e\"}]}\n-        policy = json.loads(queue.attributes['Policy'])\n-        policy['Statement'][0][\"Principal\"] = {\"AWS\": \"*\"}\n-        queue.set_attributes(Attributes={'Policy': json.dumps(policy)})\n-\n-        # topic allows subscription\n-        perm_label = 'perm-for-%s' % qname\n-        topic.add_permission(**{\n-            'Label': perm_label,\n-            'AWSAccountId': [acc_id],\n-            'ActionName': [\n-                'subscribe',\n-                'receive',\n-                'publish'\n-            ]})\n-\n-        subscription = topic.subscribe(Protocol='sqs', Endpoint=queue_arn)\n-\n-        message = get_message(queue)\n-        print 'message:', message\n-\n-        body = json.loads(message.body)\n-        print 'message body:', body\n-\n-        body_message = json.loads(body['Message'])\n-        print 'message body decoded:', body_message\n-\n-    except KeyboardInterrupt:\n-        pass\n-\n-    finally:\n-        # destroy subscription\n-        # destroy queue\n-        LOG.info(\"deleting queue\")\n-        if queue:\n-            queue.delete()\n-\n-        if subscription:\n-            subscription.delete()\n-\n-        if perm_label:\n-            topic.remove_permission(Label=perm_label)\n-'''","path":"src/publisher/aws_events.py","position":104,"original_position":104,"commit_id":"6ce513ca8b5ad96e306786eaf6cad2311085a340","original_commit_id":"c13143e80ae51bb9aca9771b1866151907f0f06e","user":{"login":"lsh-0","id":2142748,"avatar_url":"https://avatars3.githubusercontent.com/u/2142748?v=3","gravatar_id":"","url":"https://api.github.com/users/lsh-0","html_url":"https://github.com/lsh-0","followers_url":"https://api.github.com/users/lsh-0/followers","following_url":"https://api.github.com/users/lsh-0/following{/other_user}","gists_url":"https://api.github.com/users/lsh-0/gists{/gist_id}","starred_url":"https://api.github.com/users/lsh-0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsh-0/subscriptions","organizations_url":"https://api.github.com/users/lsh-0/orgs","repos_url":"https://api.github.com/users/lsh-0/repos","events_url":"https://api.github.com/users/lsh-0/events{/privacy}","received_events_url":"https://api.github.com/users/lsh-0/received_events","type":"User","site_admin":false},"body":"it was good code, but we have the infrastructure now to properly test and debug this without having to create adhoc topics and queues","created_at":"2017-05-29T00:17:00Z","updated_at":"2017-05-29T00:17:01Z","html_url":"https://github.com/elifesciences/lax/pull/200#discussion_r118853207","pull_request_url":"https://api.github.com/repos/elifesciences/lax/pulls/200","_links":{"self":{"href":"https://api.github.com/repos/elifesciences/lax/pulls/comments/118853207"},"html":{"href":"https://github.com/elifesciences/lax/pull/200#discussion_r118853207"},"pull_request":{"href":"https://api.github.com/repos/elifesciences/lax/pulls/200"}}},"pull_request":{"url":"https://api.github.com/repos/elifesciences/lax/pulls/200","id":122201785,"html_url":"https://github.com/elifesciences/lax/pull/200","diff_url":"https://github.com/elifesciences/lax/pull/200.diff","patch_url":"https://github.com/elifesciences/lax/pull/200.patch","issue_url":"https://api.github.com/repos/elifesciences/lax/issues/200","number":200,"state":"closed","locked":false,"title":"Sending events on related articles","user":{"login":"giorgiosironi","id":160299,"avatar_url":"https://avatars0.githubusercontent.com/u/160299?v=3","gravatar_id":"","url":"https://api.github.com/users/giorgiosironi","html_url":"https://github.com/giorgiosironi","followers_url":"https://api.github.com/users/giorgiosironi/followers","following_url":"https://api.github.com/users/giorgiosironi/following{/other_user}","gists_url":"https://api.github.com/users/giorgiosironi/gists{/gist_id}","starred_url":"https://api.github.com/users/giorgiosironi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/giorgiosironi/subscriptions","organizations_url":"https://api.github.com/users/giorgiosironi/orgs","repos_url":"https://api.github.com/users/giorgiosironi/repos","events_url":"https://api.github.com/users/giorgiosironi/events{/privacy}","received_events_url":"https://api.github.com/users/giorgiosironi/received_events","type":"User","site_admin":false},"body":"Relations are explicitly passed in, while in these tests they are normally removed. We add events for the related articles to be sent together with the main one being ingested/published, even if the related articles are stubs.\r\n\r\nTwo new fixtures are introduce, related Homo Naledi articles.","created_at":"2017-05-24T11:06:57Z","updated_at":"2017-05-29T00:17:01Z","closed_at":"2017-05-26T09:10:16Z","merged_at":"2017-05-26T09:10:16Z","merge_commit_sha":"c9d13e255a10570bca5110294bbb83aa0da181a7","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/elifesciences/lax/pulls/200/commits","review_comments_url":"https://api.github.com/repos/elifesciences/lax/pulls/200/comments","review_comment_url":"https://api.github.com/repos/elifesciences/lax/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elifesciences/lax/issues/200/comments","statuses_url":"https://api.github.com/repos/elifesciences/lax/statuses/6ce513ca8b5ad96e306786eaf6cad2311085a340","head":{"label":"elifesciences:sending_events_on_related_articles","ref":"sending_events_on_related_articles","sha":"6ce513ca8b5ad96e306786eaf6cad2311085a340","user":{"login":"elifesciences","id":1777367,"avatar_url":"https://avatars1.githubusercontent.com/u/1777367?v=3","gravatar_id":"","url":"https://api.github.com/users/elifesciences","html_url":"https://github.com/elifesciences","followers_url":"https://api.github.com/users/elifesciences/followers","following_url":"https://api.github.com/users/elifesciences/following{/other_user}","gists_url":"https://api.github.com/users/elifesciences/gists{/gist_id}","starred_url":"https://api.github.com/users/elifesciences/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elifesciences/subscriptions","organizations_url":"https://api.github.com/users/elifesciences/orgs","repos_url":"https://api.github.com/users/elifesciences/repos","events_url":"https://api.github.com/users/elifesciences/events{/privacy}","received_events_url":"https://api.github.com/users/elifesciences/received_events","type":"Organization","site_admin":false},"repo":{"id":38447230,"name":"lax","full_name":"elifesciences/lax","owner":{"login":"elifesciences","id":1777367,"avatar_url":"https://avatars1.githubusercontent.com/u/1777367?v=3","gravatar_id":"","url":"https://api.github.com/users/elifesciences","html_url":"https://github.com/elifesciences","followers_url":"https://api.github.com/users/elifesciences/followers","following_url":"https://api.github.com/users/elifesciences/following{/other_user}","gists_url":"https://api.github.com/users/elifesciences/gists{/gist_id}","starred_url":"https://api.github.com/users/elifesciences/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elifesciences/subscriptions","organizations_url":"https://api.github.com/users/elifesciences/orgs","repos_url":"https://api.github.com/users/elifesciences/repos","events_url":"https://api.github.com/users/elifesciences/events{/privacy}","received_events_url":"https://api.github.com/users/elifesciences/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/elifesciences/lax","description":null,"fork":false,"url":"https://api.github.com/repos/elifesciences/lax","forks_url":"https://api.github.com/repos/elifesciences/lax/forks","keys_url":"https://api.github.com/repos/elifesciences/lax/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elifesciences/lax/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elifesciences/lax/teams","hooks_url":"https://api.github.com/repos/elifesciences/lax/hooks","issue_events_url":"https://api.github.com/repos/elifesciences/lax/issues/events{/number}","events_url":"https://api.github.com/repos/elifesciences/lax/events","assignees_url":"https://api.github.com/repos/elifesciences/lax/assignees{/user}","branches_url":"https://api.github.com/repos/elifesciences/lax/branches{/branch}","tags_url":"https://api.github.com/repos/elifesciences/lax/tags","blobs_url":"https://api.github.com/repos/elifesciences/lax/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elifesciences/lax/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elifesciences/lax/git/refs{/sha}","trees_url":"https://api.github.com/repos/elifesciences/lax/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elifesciences/lax/statuses/{sha}","languages_url":"https://api.github.com/repos/elifesciences/lax/languages","stargazers_url":"https://api.github.com/repos/elifesciences/lax/stargazers","contributors_url":"https://api.github.com/repos/elifesciences/lax/contributors","subscribers_url":"https://api.github.com/repos/elifesciences/lax/subscribers","subscription_url":"https://api.github.com/repos/elifesciences/lax/subscription","commits_url":"https://api.github.com/repos/elifesciences/lax/commits{/sha}","git_commits_url":"https://api.github.com/repos/elifesciences/lax/git/commits{/sha}","comments_url":"https://api.github.com/repos/elifesciences/lax/comments{/number}","issue_comment_url":"https://api.github.com/repos/elifesciences/lax/issues/comments{/number}","contents_url":"https://api.github.com/repos/elifesciences/lax/contents/{+path}","compare_url":"https://api.github.com/repos/elifesciences/lax/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elifesciences/lax/merges","archive_url":"https://api.github.com/repos/elifesciences/lax/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elifesciences/lax/downloads","issues_url":"https://api.github.com/repos/elifesciences/lax/issues{/number}","pulls_url":"https://api.github.com/repos/elifesciences/lax/pulls{/number}","milestones_url":"https://api.github.com/repos/elifesciences/lax/milestones{/number}","notifications_url":"https://api.github.com/repos/elifesciences/lax/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elifesciences/lax/labels{/name}","releases_url":"https://api.github.com/repos/elifesciences/lax/releases{/id}","deployments_url":"https://api.github.com/repos/elifesciences/lax/deployments","created_at":"2015-07-02T17:35:26Z","updated_at":"2017-01-22T20:00:46Z","pushed_at":"2017-05-26T13:49:46Z","git_url":"git://github.com/elifesciences/lax.git","ssh_url":"git@github.com:elifesciences/lax.git","clone_url":"https://github.com/elifesciences/lax.git","svn_url":"https://github.com/elifesciences/lax","homepage":null,"size":1930,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"elifesciences:develop","ref":"develop","sha":"d0055b54a4b7ffe85e0ccdaa9ade13d093b66e80","user":{"login":"elifesciences","id":1777367,"avatar_url":"https://avatars1.githubusercontent.com/u/1777367?v=3","gravatar_id":"","url":"https://api.github.com/users/elifesciences","html_url":"https://github.com/elifesciences","followers_url":"https://api.github.com/users/elifesciences/followers","following_url":"https://api.github.com/users/elifesciences/following{/other_user}","gists_url":"https://api.github.com/users/elifesciences/gists{/gist_id}","starred_url":"https://api.github.com/users/elifesciences/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elifesciences/subscriptions","organizations_url":"https://api.github.com/users/elifesciences/orgs","repos_url":"https://api.github.com/users/elifesciences/repos","events_url":"https://api.github.com/users/elifesciences/events{/privacy}","received_events_url":"https://api.github.com/users/elifesciences/received_events","type":"Organization","site_admin":false},"repo":{"id":38447230,"name":"lax","full_name":"elifesciences/lax","owner":{"login":"elifesciences","id":1777367,"avatar_url":"https://avatars1.githubusercontent.com/u/1777367?v=3","gravatar_id":"","url":"https://api.github.com/users/elifesciences","html_url":"https://github.com/elifesciences","followers_url":"https://api.github.com/users/elifesciences/followers","following_url":"https://api.github.com/users/elifesciences/following{/other_user}","gists_url":"https://api.github.com/users/elifesciences/gists{/gist_id}","starred_url":"https://api.github.com/users/elifesciences/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elifesciences/subscriptions","organizations_url":"https://api.github.com/users/elifesciences/orgs","repos_url":"https://api.github.com/users/elifesciences/repos","events_url":"https://api.github.com/users/elifesciences/events{/privacy}","received_events_url":"https://api.github.com/users/elifesciences/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/elifesciences/lax","description":null,"fork":false,"url":"https://api.github.com/repos/elifesciences/lax","forks_url":"https://api.github.com/repos/elifesciences/lax/forks","keys_url":"https://api.github.com/repos/elifesciences/lax/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elifesciences/lax/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elifesciences/lax/teams","hooks_url":"https://api.github.com/repos/elifesciences/lax/hooks","issue_events_url":"https://api.github.com/repos/elifesciences/lax/issues/events{/number}","events_url":"https://api.github.com/repos/elifesciences/lax/events","assignees_url":"https://api.github.com/repos/elifesciences/lax/assignees{/user}","branches_url":"https://api.github.com/repos/elifesciences/lax/branches{/branch}","tags_url":"https://api.github.com/repos/elifesciences/lax/tags","blobs_url":"https://api.github.com/repos/elifesciences/lax/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elifesciences/lax/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elifesciences/lax/git/refs{/sha}","trees_url":"https://api.github.com/repos/elifesciences/lax/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elifesciences/lax/statuses/{sha}","languages_url":"https://api.github.com/repos/elifesciences/lax/languages","stargazers_url":"https://api.github.com/repos/elifesciences/lax/stargazers","contributors_url":"https://api.github.com/repos/elifesciences/lax/contributors","subscribers_url":"https://api.github.com/repos/elifesciences/lax/subscribers","subscription_url":"https://api.github.com/repos/elifesciences/lax/subscription","commits_url":"https://api.github.com/repos/elifesciences/lax/commits{/sha}","git_commits_url":"https://api.github.com/repos/elifesciences/lax/git/commits{/sha}","comments_url":"https://api.github.com/repos/elifesciences/lax/comments{/number}","issue_comment_url":"https://api.github.com/repos/elifesciences/lax/issues/comments{/number}","contents_url":"https://api.github.com/repos/elifesciences/lax/contents/{+path}","compare_url":"https://api.github.com/repos/elifesciences/lax/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elifesciences/lax/merges","archive_url":"https://api.github.com/repos/elifesciences/lax/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elifesciences/lax/downloads","issues_url":"https://api.github.com/repos/elifesciences/lax/issues{/number}","pulls_url":"https://api.github.com/repos/elifesciences/lax/pulls{/number}","milestones_url":"https://api.github.com/repos/elifesciences/lax/milestones{/number}","notifications_url":"https://api.github.com/repos/elifesciences/lax/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elifesciences/lax/labels{/name}","releases_url":"https://api.github.com/repos/elifesciences/lax/releases{/id}","deployments_url":"https://api.github.com/repos/elifesciences/lax/deployments","created_at":"2015-07-02T17:35:26Z","updated_at":"2017-01-22T20:00:46Z","pushed_at":"2017-05-26T13:49:46Z","git_url":"git://github.com/elifesciences/lax.git","ssh_url":"git@github.com:elifesciences/lax.git","clone_url":"https://github.com/elifesciences/lax.git","svn_url":"https://github.com/elifesciences/lax","homepage":null,"size":1930,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/elifesciences/lax/pulls/200"},"html":{"href":"https://github.com/elifesciences/lax/pull/200"},"issue":{"href":"https://api.github.com/repos/elifesciences/lax/issues/200"},"comments":{"href":"https://api.github.com/repos/elifesciences/lax/issues/200/comments"},"review_comments":{"href":"https://api.github.com/repos/elifesciences/lax/pulls/200/comments"},"review_comment":{"href":"https://api.github.com/repos/elifesciences/lax/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elifesciences/lax/pulls/200/commits"},"statuses":{"href":"https://api.github.com/repos/elifesciences/lax/statuses/6ce513ca8b5ad96e306786eaf6cad2311085a340"}}}}
{"actor":{"display_login":"lsh-0"}}