{"action":"created","comment":{"url":"https://api.github.com/repos/decobots/python-twitter-bot/pulls/comments/171285421","pull_request_review_id":100106042,"id":171285421,"diff_hunk":"@@ -0,0 +1,77 @@\n+import psycopg2\n+import pytest\n+from psycopg2 import sql\n+\n+from src.data_base import DataBase\n+\n+\n+@pytest.fixture\n+def table_name():\n+    return \"test_data_base\"\n+\n+\n+@pytest.fixture\n+def db(table_name):\n+    database = DataBase(table_name)\n+    yield database\n+    database.connection.close()\n+\n+\n+@pytest.fixture\n+def test_ids():\n+    return \"42\", \"43\", \"44\"\n+\n+\n+def test_db_context_manager(table_name):\n+    with DataBase(table_name) as db:\n+        assert db.table_name == table_name\n+        assert isinstance(db.connection, psycopg2.extensions.connection)\n+        assert isinstance(db.cursor, psycopg2.extensions.cursor)\n+        assert db.cursor.closed is False\n+        assert db.connection.closed == 0\n+\n+    assert db.cursor.closed is True\n+    assert db.connection.closed == 1\n+\n+\n+def test_add_photo(db, table_name, test_ids):\n+    test_id = test_ids[0]\n+    db.add_photo(test_id)\n+    db.cursor.execute(sql.SQL(\"SELECT * FROM {} WHERE id = %s\").format(sql.Identifier(table_name)), (test_id,))\n+    assert db.cursor.fetchall() == [(test_id, False)]\n+\n+    db.add_photo(test_id)\n+    db.cursor.execute(sql.SQL(\"SELECT * FROM {} WHERE id = %s\").format(sql.Identifier(table_name)), (test_id,))\n+    assert db.cursor.fetchall() == [(test_id, False)]  # duplicate id's handled correctly\n+    for t_id in test_ids:\n+        db.add_photo(t_id)\n+    db.cursor.execute(sql.SQL(\"SELECT * FROM {}\").format(sql.Identifier(table_name)))\n+    assert db.cursor.fetchall() == [(p_id, False) for p_id in test_ids]\n+\n+\n+def test_post_photo(db, table_name, test_ids):\n+    db.post_photo(test_ids[0])\n+    db.cursor.execute(sql.SQL(\"SELECT * FROM {}\").format(sql.Identifier(table_name)))\n+    list_ids = [(p_id, False) for p_id in test_ids]\n+    list_ids[0] = (test_ids[0], True)\n+    assert set(db.cursor.fetchall()) == set(list_ids)\n+\n+\n+def test_unposted_photos(db, test_ids):","path":"tests/test_data_base.py","position":60,"original_position":60,"commit_id":"7dedc1032264bfd1c2c9dbff2ddf8994daef5ec6","original_commit_id":"7dedc1032264bfd1c2c9dbff2ddf8994daef5ec6","user":{"login":"livercat","id":24808776,"avatar_url":"https://avatars2.githubusercontent.com/u/24808776?v=4","gravatar_id":"","url":"https://api.github.com/users/livercat","html_url":"https://github.com/livercat","followers_url":"https://api.github.com/users/livercat/followers","following_url":"https://api.github.com/users/livercat/following{/other_user}","gists_url":"https://api.github.com/users/livercat/gists{/gist_id}","starred_url":"https://api.github.com/users/livercat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/livercat/subscriptions","organizations_url":"https://api.github.com/users/livercat/orgs","repos_url":"https://api.github.com/users/livercat/repos","events_url":"https://api.github.com/users/livercat/events{/privacy}","received_events_url":"https://api.github.com/users/livercat/received_events","type":"User","site_admin":false},"body":"Add prerequisites, don't rely on test execution order","created_at":"2018-02-28T15:39:17Z","updated_at":"2018-02-28T15:40:23Z","html_url":"https://github.com/decobots/python-twitter-bot/pull/32#discussion_r171285421","pull_request_url":"https://api.github.com/repos/decobots/python-twitter-bot/pulls/32","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/decobots/python-twitter-bot/pulls/comments/171285421"},"html":{"href":"https://github.com/decobots/python-twitter-bot/pull/32#discussion_r171285421"},"pull_request":{"href":"https://api.github.com/repos/decobots/python-twitter-bot/pulls/32"}}},"pull_request":{"url":"https://api.github.com/repos/decobots/python-twitter-bot/pulls/32","id":171983588,"html_url":"https://github.com/decobots/python-twitter-bot/pull/32","diff_url":"https://github.com/decobots/python-twitter-bot/pull/32.diff","patch_url":"https://github.com/decobots/python-twitter-bot/pull/32.patch","issue_url":"https://api.github.com/repos/decobots/python-twitter-bot/issues/32","number":32,"state":"open","locked":false,"title":"database moved to postgres","user":{"login":"decobots","id":5717390,"avatar_url":"https://avatars3.githubusercontent.com/u/5717390?v=4","gravatar_id":"","url":"https://api.github.com/users/decobots","html_url":"https://github.com/decobots","followers_url":"https://api.github.com/users/decobots/followers","following_url":"https://api.github.com/users/decobots/following{/other_user}","gists_url":"https://api.github.com/users/decobots/gists{/gist_id}","starred_url":"https://api.github.com/users/decobots/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/decobots/subscriptions","organizations_url":"https://api.github.com/users/decobots/orgs","repos_url":"https://api.github.com/users/decobots/repos","events_url":"https://api.github.com/users/decobots/events{/privacy}","received_events_url":"https://api.github.com/users/decobots/received_events","type":"User","site_admin":false},"body":"#8 #31","created_at":"2018-02-28T15:19:46Z","updated_at":"2018-02-28T15:40:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c3d1a811389742b8cbe3abb4debaa7128d0886bd","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/decobots/python-twitter-bot/pulls/32/commits","review_comments_url":"https://api.github.com/repos/decobots/python-twitter-bot/pulls/32/comments","review_comment_url":"https://api.github.com/repos/decobots/python-twitter-bot/pulls/comments{/number}","comments_url":"https://api.github.com/repos/decobots/python-twitter-bot/issues/32/comments","statuses_url":"https://api.github.com/repos/decobots/python-twitter-bot/statuses/7dedc1032264bfd1c2c9dbff2ddf8994daef5ec6","head":{"label":"decobots:move-to-postgres-database","ref":"move-to-postgres-database","sha":"7dedc1032264bfd1c2c9dbff2ddf8994daef5ec6","user":{"login":"decobots","id":5717390,"avatar_url":"https://avatars3.githubusercontent.com/u/5717390?v=4","gravatar_id":"","url":"https://api.github.com/users/decobots","html_url":"https://github.com/decobots","followers_url":"https://api.github.com/users/decobots/followers","following_url":"https://api.github.com/users/decobots/following{/other_user}","gists_url":"https://api.github.com/users/decobots/gists{/gist_id}","starred_url":"https://api.github.com/users/decobots/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/decobots/subscriptions","organizations_url":"https://api.github.com/users/decobots/orgs","repos_url":"https://api.github.com/users/decobots/repos","events_url":"https://api.github.com/users/decobots/events{/privacy}","received_events_url":"https://api.github.com/users/decobots/received_events","type":"User","site_admin":false},"repo":{"id":120771147,"name":"python-twitter-bot","full_name":"decobots/python-twitter-bot","owner":{"login":"decobots","id":5717390,"avatar_url":"https://avatars3.githubusercontent.com/u/5717390?v=4","gravatar_id":"","url":"https://api.github.com/users/decobots","html_url":"https://github.com/decobots","followers_url":"https://api.github.com/users/decobots/followers","following_url":"https://api.github.com/users/decobots/following{/other_user}","gists_url":"https://api.github.com/users/decobots/gists{/gist_id}","starred_url":"https://api.github.com/users/decobots/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/decobots/subscriptions","organizations_url":"https://api.github.com/users/decobots/orgs","repos_url":"https://api.github.com/users/decobots/repos","events_url":"https://api.github.com/users/decobots/events{/privacy}","received_events_url":"https://api.github.com/users/decobots/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/decobots/python-twitter-bot","description":null,"fork":false,"url":"https://api.github.com/repos/decobots/python-twitter-bot","forks_url":"https://api.github.com/repos/decobots/python-twitter-bot/forks","keys_url":"https://api.github.com/repos/decobots/python-twitter-bot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/decobots/python-twitter-bot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/decobots/python-twitter-bot/teams","hooks_url":"https://api.github.com/repos/decobots/python-twitter-bot/hooks","issue_events_url":"https://api.github.com/repos/decobots/python-twitter-bot/issues/events{/number}","events_url":"https://api.github.com/repos/decobots/python-twitter-bot/events","assignees_url":"https://api.github.com/repos/decobots/python-twitter-bot/assignees{/user}","branches_url":"https://api.github.com/repos/decobots/python-twitter-bot/branches{/branch}","tags_url":"https://api.github.com/repos/decobots/python-twitter-bot/tags","blobs_url":"https://api.github.com/repos/decobots/python-twitter-bot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/decobots/python-twitter-bot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/decobots/python-twitter-bot/git/refs{/sha}","trees_url":"https://api.github.com/repos/decobots/python-twitter-bot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/decobots/python-twitter-bot/statuses/{sha}","languages_url":"https://api.github.com/repos/decobots/python-twitter-bot/languages","stargazers_url":"https://api.github.com/repos/decobots/python-twitter-bot/stargazers","contributors_url":"https://api.github.com/repos/decobots/python-twitter-bot/contributors","subscribers_url":"https://api.github.com/repos/decobots/python-twitter-bot/subscribers","subscription_url":"https://api.github.com/repos/decobots/python-twitter-bot/subscription","commits_url":"https://api.github.com/repos/decobots/python-twitter-bot/commits{/sha}","git_commits_url":"https://api.github.com/repos/decobots/python-twitter-bot/git/commits{/sha}","comments_url":"https://api.github.com/repos/decobots/python-twitter-bot/comments{/number}","issue_comment_url":"https://api.github.com/repos/decobots/python-twitter-bot/issues/comments{/number}","contents_url":"https://api.github.com/repos/decobots/python-twitter-bot/contents/{+path}","compare_url":"https://api.github.com/repos/decobots/python-twitter-bot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/decobots/python-twitter-bot/merges","archive_url":"https://api.github.com/repos/decobots/python-twitter-bot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/decobots/python-twitter-bot/downloads","issues_url":"https://api.github.com/repos/decobots/python-twitter-bot/issues{/number}","pulls_url":"https://api.github.com/repos/decobots/python-twitter-bot/pulls{/number}","milestones_url":"https://api.github.com/repos/decobots/python-twitter-bot/milestones{/number}","notifications_url":"https://api.github.com/repos/decobots/python-twitter-bot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/decobots/python-twitter-bot/labels{/name}","releases_url":"https://api.github.com/repos/decobots/python-twitter-bot/releases{/id}","deployments_url":"https://api.github.com/repos/decobots/python-twitter-bot/deployments","created_at":"2018-02-08T14:23:04Z","updated_at":"2018-02-09T09:23:33Z","pushed_at":"2018-02-28T15:19:47Z","git_url":"git://github.com/decobots/python-twitter-bot.git","ssh_url":"git@github.com:decobots/python-twitter-bot.git","clone_url":"https://github.com/decobots/python-twitter-bot.git","svn_url":"https://github.com/decobots/python-twitter-bot","homepage":null,"size":225,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":5,"license":null,"forks":0,"open_issues":5,"watchers":0,"default_branch":"master"}},"base":{"label":"decobots:master","ref":"master","sha":"1e8a1e628fc07dadbd59d8f84c62f227e29d6052","user":{"login":"decobots","id":5717390,"avatar_url":"https://avatars3.githubusercontent.com/u/5717390?v=4","gravatar_id":"","url":"https://api.github.com/users/decobots","html_url":"https://github.com/decobots","followers_url":"https://api.github.com/users/decobots/followers","following_url":"https://api.github.com/users/decobots/following{/other_user}","gists_url":"https://api.github.com/users/decobots/gists{/gist_id}","starred_url":"https://api.github.com/users/decobots/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/decobots/subscriptions","organizations_url":"https://api.github.com/users/decobots/orgs","repos_url":"https://api.github.com/users/decobots/repos","events_url":"https://api.github.com/users/decobots/events{/privacy}","received_events_url":"https://api.github.com/users/decobots/received_events","type":"User","site_admin":false},"repo":{"id":120771147,"name":"python-twitter-bot","full_name":"decobots/python-twitter-bot","owner":{"login":"decobots","id":5717390,"avatar_url":"https://avatars3.githubusercontent.com/u/5717390?v=4","gravatar_id":"","url":"https://api.github.com/users/decobots","html_url":"https://github.com/decobots","followers_url":"https://api.github.com/users/decobots/followers","following_url":"https://api.github.com/users/decobots/following{/other_user}","gists_url":"https://api.github.com/users/decobots/gists{/gist_id}","starred_url":"https://api.github.com/users/decobots/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/decobots/subscriptions","organizations_url":"https://api.github.com/users/decobots/orgs","repos_url":"https://api.github.com/users/decobots/repos","events_url":"https://api.github.com/users/decobots/events{/privacy}","received_events_url":"https://api.github.com/users/decobots/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/decobots/python-twitter-bot","description":null,"fork":false,"url":"https://api.github.com/repos/decobots/python-twitter-bot","forks_url":"https://api.github.com/repos/decobots/python-twitter-bot/forks","keys_url":"https://api.github.com/repos/decobots/python-twitter-bot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/decobots/python-twitter-bot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/decobots/python-twitter-bot/teams","hooks_url":"https://api.github.com/repos/decobots/python-twitter-bot/hooks","issue_events_url":"https://api.github.com/repos/decobots/python-twitter-bot/issues/events{/number}","events_url":"https://api.github.com/repos/decobots/python-twitter-bot/events","assignees_url":"https://api.github.com/repos/decobots/python-twitter-bot/assignees{/user}","branches_url":"https://api.github.com/repos/decobots/python-twitter-bot/branches{/branch}","tags_url":"https://api.github.com/repos/decobots/python-twitter-bot/tags","blobs_url":"https://api.github.com/repos/decobots/python-twitter-bot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/decobots/python-twitter-bot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/decobots/python-twitter-bot/git/refs{/sha}","trees_url":"https://api.github.com/repos/decobots/python-twitter-bot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/decobots/python-twitter-bot/statuses/{sha}","languages_url":"https://api.github.com/repos/decobots/python-twitter-bot/languages","stargazers_url":"https://api.github.com/repos/decobots/python-twitter-bot/stargazers","contributors_url":"https://api.github.com/repos/decobots/python-twitter-bot/contributors","subscribers_url":"https://api.github.com/repos/decobots/python-twitter-bot/subscribers","subscription_url":"https://api.github.com/repos/decobots/python-twitter-bot/subscription","commits_url":"https://api.github.com/repos/decobots/python-twitter-bot/commits{/sha}","git_commits_url":"https://api.github.com/repos/decobots/python-twitter-bot/git/commits{/sha}","comments_url":"https://api.github.com/repos/decobots/python-twitter-bot/comments{/number}","issue_comment_url":"https://api.github.com/repos/decobots/python-twitter-bot/issues/comments{/number}","contents_url":"https://api.github.com/repos/decobots/python-twitter-bot/contents/{+path}","compare_url":"https://api.github.com/repos/decobots/python-twitter-bot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/decobots/python-twitter-bot/merges","archive_url":"https://api.github.com/repos/decobots/python-twitter-bot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/decobots/python-twitter-bot/downloads","issues_url":"https://api.github.com/repos/decobots/python-twitter-bot/issues{/number}","pulls_url":"https://api.github.com/repos/decobots/python-twitter-bot/pulls{/number}","milestones_url":"https://api.github.com/repos/decobots/python-twitter-bot/milestones{/number}","notifications_url":"https://api.github.com/repos/decobots/python-twitter-bot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/decobots/python-twitter-bot/labels{/name}","releases_url":"https://api.github.com/repos/decobots/python-twitter-bot/releases{/id}","deployments_url":"https://api.github.com/repos/decobots/python-twitter-bot/deployments","created_at":"2018-02-08T14:23:04Z","updated_at":"2018-02-09T09:23:33Z","pushed_at":"2018-02-28T15:19:47Z","git_url":"git://github.com/decobots/python-twitter-bot.git","ssh_url":"git@github.com:decobots/python-twitter-bot.git","clone_url":"https://github.com/decobots/python-twitter-bot.git","svn_url":"https://github.com/decobots/python-twitter-bot","homepage":null,"size":225,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":5,"license":null,"forks":0,"open_issues":5,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/decobots/python-twitter-bot/pulls/32"},"html":{"href":"https://github.com/decobots/python-twitter-bot/pull/32"},"issue":{"href":"https://api.github.com/repos/decobots/python-twitter-bot/issues/32"},"comments":{"href":"https://api.github.com/repos/decobots/python-twitter-bot/issues/32/comments"},"review_comments":{"href":"https://api.github.com/repos/decobots/python-twitter-bot/pulls/32/comments"},"review_comment":{"href":"https://api.github.com/repos/decobots/python-twitter-bot/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/decobots/python-twitter-bot/pulls/32/commits"},"statuses":{"href":"https://api.github.com/repos/decobots/python-twitter-bot/statuses/7dedc1032264bfd1c2c9dbff2ddf8994daef5ec6"}},"author_association":"OWNER"}}
{"actor":{"display_login":"livercat"}}