{"action":"created","comment":{"url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/pulls/comments/124035338","pull_request_review_id":46286505,"id":124035338,"diff_hunk":"@@ -0,0 +1,63 @@\n+import unittest\n+\n+import aiohttp\n+from aiohttp.client_exceptions import ClientConnectorError\n+import asynctest\n+\n+from publisher import get_default_publisher\n+from publisher import logger\n+from publisher import PublishError\n+\n+\n+class TestPublisher(unittest.TestCase):\n+\n+    def setUp(self):\n+        self.logger = logger\n+        self.pub = get_default_publisher(logger)\n+\n+    async def test_delete_if_sent(self):\n+        path = 'test.xlsx'\n+        pub_rem = getattr(self.pub, 'publish_remove_files')\n+        with asynctest.mock.patch(\"publisher.Publisher.publish\") as mock_publish:\n+            mock_publish.return_value = 200\n+            mock_ftp = asynctest.mock.Mock()\n+            await pub_rem(path, ftp_client=mock_ftp, http_session=None)\n+            mock_ftp.remove_file.assert_called_with()\n+\n+    async def test_not_delete_if_not_sent(self):\n+        path = 'test.xlsx'\n+        pub_rem = getattr(self.pub, 'publish_remove_files')\n+        with asynctest.mock.patch(\"publisher.Publisher.publish\") as mock_publish:\n+            mock_publish.return_value = 400\n+            mock_ftp = asynctest.mock.Mock()\n+            await pub_rem(path, ftp_client=mock_ftp, http_session=None)\n+            mock_ftp.remove_file.assert_not_called()\n+            self.assertRaises(PublishError)\n+\n+    async def test_publish_xlsx(self):\n+        path = 'test.xlsx'\n+        pub_rem = getattr(self.pub, 'publish_remove_files')\n+        with asynctest.mock.patch(\"publisher.Publisher.publish\") as mock_publish:\n+            mock_ftp = asynctest.mock.Mock()\n+            await pub_rem(path, ftp_client=mock_ftp, http_session=None)\n+            mock_publish.assert_called_with()\n+\n+    async def test_not_publish_xlsx(self):\n+        path = 'test.png'","path":"tests/test_publisher.py","position":46,"original_position":46,"commit_id":"8845dc988ab987c6efb96a69d5c6c7603d07c1e0","original_commit_id":"8845dc988ab987c6efb96a69d5c6c7603d07c1e0","user":{"login":"tundish","id":4272886,"avatar_url":"https://avatars1.githubusercontent.com/u/4272886?v=3","gravatar_id":"","url":"https://api.github.com/users/tundish","html_url":"https://github.com/tundish","followers_url":"https://api.github.com/users/tundish/followers","following_url":"https://api.github.com/users/tundish/following{/other_user}","gists_url":"https://api.github.com/users/tundish/gists{/gist_id}","starred_url":"https://api.github.com/users/tundish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tundish/subscriptions","organizations_url":"https://api.github.com/users/tundish/orgs","repos_url":"https://api.github.com/users/tundish/repos","events_url":"https://api.github.com/users/tundish/events{/privacy}","received_events_url":"https://api.github.com/users/tundish/received_events","type":"User","site_admin":false},"body":"' -> \"","created_at":"2017-06-26T15:08:12Z","updated_at":"2017-06-26T15:09:04Z","html_url":"https://github.com/ONSdigital/sdx-seft-publisher-service/pull/6#discussion_r124035338","pull_request_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/pulls/comments/124035338"},"html":{"href":"https://github.com/ONSdigital/sdx-seft-publisher-service/pull/6#discussion_r124035338"},"pull_request":{"href":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/pulls/6","id":127223984,"html_url":"https://github.com/ONSdigital/sdx-seft-publisher-service/pull/6","diff_url":"https://github.com/ONSdigital/sdx-seft-publisher-service/pull/6.diff","patch_url":"https://github.com/ONSdigital/sdx-seft-publisher-service/pull/6.patch","issue_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/issues/6","number":6,"state":"open","locked":false,"title":"Feature/publisher","user":{"login":"andrewmil","id":22077099,"avatar_url":"https://avatars0.githubusercontent.com/u/22077099?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewmil","html_url":"https://github.com/andrewmil","followers_url":"https://api.github.com/users/andrewmil/followers","following_url":"https://api.github.com/users/andrewmil/following{/other_user}","gists_url":"https://api.github.com/users/andrewmil/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewmil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewmil/subscriptions","organizations_url":"https://api.github.com/users/andrewmil/orgs","repos_url":"https://api.github.com/users/andrewmil/repos","events_url":"https://api.github.com/users/andrewmil/events{/privacy}","received_events_url":"https://api.github.com/users/andrewmil/received_events","type":"User","site_admin":false},"body":"Productionised the async code for full publisher service","created_at":"2017-06-23T14:50:12Z","updated_at":"2017-06-26T15:09:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c9b1a78120b258102de7ac60f26869e401e267f6","assignee":null,"assignees":[],"requested_reviewers":[{"login":"necrophonic","id":1521281,"avatar_url":"https://avatars0.githubusercontent.com/u/1521281?v=3","gravatar_id":"","url":"https://api.github.com/users/necrophonic","html_url":"https://github.com/necrophonic","followers_url":"https://api.github.com/users/necrophonic/followers","following_url":"https://api.github.com/users/necrophonic/following{/other_user}","gists_url":"https://api.github.com/users/necrophonic/gists{/gist_id}","starred_url":"https://api.github.com/users/necrophonic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/necrophonic/subscriptions","organizations_url":"https://api.github.com/users/necrophonic/orgs","repos_url":"https://api.github.com/users/necrophonic/repos","events_url":"https://api.github.com/users/necrophonic/events{/privacy}","received_events_url":"https://api.github.com/users/necrophonic/received_events","type":"User","site_admin":false},{"login":"JamesGardiner","id":9960163,"avatar_url":"https://avatars0.githubusercontent.com/u/9960163?v=3","gravatar_id":"","url":"https://api.github.com/users/JamesGardiner","html_url":"https://github.com/JamesGardiner","followers_url":"https://api.github.com/users/JamesGardiner/followers","following_url":"https://api.github.com/users/JamesGardiner/following{/other_user}","gists_url":"https://api.github.com/users/JamesGardiner/gists{/gist_id}","starred_url":"https://api.github.com/users/JamesGardiner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JamesGardiner/subscriptions","organizations_url":"https://api.github.com/users/JamesGardiner/orgs","repos_url":"https://api.github.com/users/JamesGardiner/repos","events_url":"https://api.github.com/users/JamesGardiner/events{/privacy}","received_events_url":"https://api.github.com/users/JamesGardiner/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/pulls/6/commits","review_comments_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/pulls/6/comments","review_comment_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/issues/6/comments","statuses_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/statuses/8845dc988ab987c6efb96a69d5c6c7603d07c1e0","head":{"label":"ONSdigital:feature/publisher","ref":"feature/publisher","sha":"8845dc988ab987c6efb96a69d5c6c7603d07c1e0","user":{"login":"ONSdigital","id":6865137,"avatar_url":"https://avatars3.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":90959846,"name":"sdx-seft-publisher-service","full_name":"ONSdigital/sdx-seft-publisher-service","owner":{"login":"ONSdigital","id":6865137,"avatar_url":"https://avatars3.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/sdx-seft-publisher-service","description":"Microservice for publishing SEFT files from internal to RAS","fork":false,"url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service","forks_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/forks","keys_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/teams","hooks_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/hooks","issue_events_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/issues/events{/number}","events_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/events","assignees_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/assignees{/user}","branches_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/branches{/branch}","tags_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/tags","blobs_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/git/refs{/sha}","trees_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/statuses/{sha}","languages_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/languages","stargazers_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/stargazers","contributors_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/contributors","subscribers_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/subscribers","subscription_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/subscription","commits_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/commits{/sha}","git_commits_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/git/commits{/sha}","comments_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/comments{/number}","issue_comment_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/issues/comments{/number}","contents_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/contents/{+path}","compare_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/merges","archive_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/downloads","issues_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/issues{/number}","pulls_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/pulls{/number}","milestones_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/milestones{/number}","notifications_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/labels{/name}","releases_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/releases{/id}","deployments_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/deployments","created_at":"2017-05-11T09:08:01Z","updated_at":"2017-05-15T12:58:58Z","pushed_at":"2017-06-23T15:25:44Z","git_url":"git://github.com/ONSdigital/sdx-seft-publisher-service.git","ssh_url":"git@github.com:ONSdigital/sdx-seft-publisher-service.git","clone_url":"https://github.com/ONSdigital/sdx-seft-publisher-service.git","svn_url":"https://github.com/ONSdigital/sdx-seft-publisher-service","homepage":null,"size":79,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"develop"}},"base":{"label":"ONSdigital:develop","ref":"develop","sha":"11be7b1cb9dce5ae4e2c43a69d6ae1a80fc7a541","user":{"login":"ONSdigital","id":6865137,"avatar_url":"https://avatars3.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":90959846,"name":"sdx-seft-publisher-service","full_name":"ONSdigital/sdx-seft-publisher-service","owner":{"login":"ONSdigital","id":6865137,"avatar_url":"https://avatars3.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/sdx-seft-publisher-service","description":"Microservice for publishing SEFT files from internal to RAS","fork":false,"url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service","forks_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/forks","keys_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/teams","hooks_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/hooks","issue_events_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/issues/events{/number}","events_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/events","assignees_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/assignees{/user}","branches_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/branches{/branch}","tags_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/tags","blobs_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/git/refs{/sha}","trees_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/statuses/{sha}","languages_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/languages","stargazers_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/stargazers","contributors_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/contributors","subscribers_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/subscribers","subscription_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/subscription","commits_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/commits{/sha}","git_commits_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/git/commits{/sha}","comments_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/comments{/number}","issue_comment_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/issues/comments{/number}","contents_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/contents/{+path}","compare_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/merges","archive_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/downloads","issues_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/issues{/number}","pulls_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/pulls{/number}","milestones_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/milestones{/number}","notifications_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/labels{/name}","releases_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/releases{/id}","deployments_url":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/deployments","created_at":"2017-05-11T09:08:01Z","updated_at":"2017-05-15T12:58:58Z","pushed_at":"2017-06-23T15:25:44Z","git_url":"git://github.com/ONSdigital/sdx-seft-publisher-service.git","ssh_url":"git@github.com:ONSdigital/sdx-seft-publisher-service.git","clone_url":"https://github.com/ONSdigital/sdx-seft-publisher-service.git","svn_url":"https://github.com/ONSdigital/sdx-seft-publisher-service","homepage":null,"size":79,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/pulls/6"},"html":{"href":"https://github.com/ONSdigital/sdx-seft-publisher-service/pull/6"},"issue":{"href":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/issues/6"},"comments":{"href":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/ONSdigital/sdx-seft-publisher-service/statuses/8845dc988ab987c6efb96a69d5c6c7603d07c1e0"}}}}
{"actor":{"display_login":"tundish"}}