{"action":"created","comment":{"url":"https://api.github.com/repos/InkubatorTieto/melvil/pulls/comments/191193991","pull_request_review_id":123719911,"id":191193991,"diff_hunk":"@@ -1,8 +1,132 @@\n import pytest\n+from mimesis import Generic\n+\n from app import create_app\n+from app import db as _db\n+from app import mail as _mail\n+from sqlalchemy import event\n+from models import User, Book\n \n+g = Generic('en')\n \n-@pytest.fixture\n+\n+@pytest.fixture(scope='module')\n def app():\n+    \"\"\"\n+    Returns flask app with context for testing.\n+    \"\"\"\n     app = create_app()\n-    return app\n+    _mail.init_app(app)\n+    ctx = app.app_context()\n+    ctx.push()\n+\n+    yield app\n+\n+    ctx.pop()\n+\n+\n+@pytest.fixture\n+def client(app):\n+    with app.test_client() as client:\n+        return client\n+\n+\n+@pytest.fixture(scope=\"module\", autouse=True)\n+def db(app):\n+    \"\"\"\n+    Returns module-wide initialised database.\n+    \"\"\"\n+    _db.drop_all()\n+    _db.create_all()\n+\n+    yield _db\n+\n+    _db.drop_all()\n+\n+\n+@pytest.fixture(scope=\"module\")\n+def session(db):\n+    \"\"\"\n+    Returns module-scoped session.\n+    \"\"\"\n+    conn = db.engine.connect()\n+    txn = conn.begin()\n+\n+    options = dict(bind=conn, binds={})\n+    sess = db.create_scoped_session(options=options)\n+\n+    sess.begin_nested()\n+\n+    @event.listens_for(sess(), 'after_transaction_end')\n+    def restart_savepoint(sess2, trans):\n+        if trans.nested and not trans._parent.nested:\n+            sess2.expire_all()\n+            sess.begin_nested()\n+\n+    db.session = sess\n+    yield sess\n+\n+    sess.remove()\n+    txn.rollback()\n+    conn.close()\n+\n+\n+@pytest.fixture(scope='module')\n+def user(app):\n+    data = {\n+        'email': 'test1@test.com',\n+        'first_name': 'Testowy',\n+        'surname': 'test',\n+        'password': '5354'}\n+    yield data\n+\n+\n+@pytest.fixture(scope=\"function\")\n+def db_user(session):\n+    \"\"\"\n+    Creates and return function-scoped User database entry\n+    \"\"\"\n+    u = User(email=g.person.email(),\n+             first_name=g.person.name(),\n+             surname=g.person.surname(),\n+             password_hash=g.cryptographic.hash(),\n+             active=g.development.boolean(),\n+             roles=[])\n+    session.add(u)\n+    session.commit()\n+\n+    yield u\n+\n+    if User.query.get(u.id):\n+        session.delete(u)\n+        session.commit()\n+\n+\n+@pytest.fixture(scope=\"function\")\n+def db_book(session):\n+    \"\"\"\n+    Creates and return function-scoped Book database entry\n+    \"\"\"\n+    b = Book(isbn=g.code.isbn(),\n+             authors=[],\n+             title=' '.join(g.text.title().split(' ')[:5]),\n+             original_title=' '.join(g.text.title().split(' ')[:5]),\n+             publisher=g.business.company(),\n+             pub_date=g.datetime.datetime().date(),\n+             language=g.person.language(),\n+             tags=[],\n+             description=g.text.sentence())\n+    session.add(b)\n+    session.commit()\n+\n+    yield b\n+\n+    if Book.query.get(b.id):\n+        session.delete(b)\n+        session.commit()\n+\n+\n+@pytest.fixture\n+def mailbox(app):\n+    mailbox=_mail.record_messages()","path":"tests/conftest.py","position":133,"original_position":133,"commit_id":"cb0ee04225c35c0b8b1b4a7eea326012de7f980f","original_commit_id":"cb0ee04225c35c0b8b1b4a7eea326012de7f980f","user":{"login":"stickler-ci","id":16011037,"avatar_url":"https://avatars3.githubusercontent.com/u/16011037?v=4","gravatar_id":"","url":"https://api.github.com/users/stickler-ci","html_url":"https://github.com/stickler-ci","followers_url":"https://api.github.com/users/stickler-ci/followers","following_url":"https://api.github.com/users/stickler-ci/following{/other_user}","gists_url":"https://api.github.com/users/stickler-ci/gists{/gist_id}","starred_url":"https://api.github.com/users/stickler-ci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stickler-ci/subscriptions","organizations_url":"https://api.github.com/users/stickler-ci/orgs","repos_url":"https://api.github.com/users/stickler-ci/repos","events_url":"https://api.github.com/users/stickler-ci/events{/privacy}","received_events_url":"https://api.github.com/users/stickler-ci/received_events","type":"User","site_admin":false},"body":"E225 missing whitespace around operator","created_at":"2018-05-28T12:28:05Z","updated_at":"2018-05-28T12:28:08Z","html_url":"https://github.com/InkubatorTieto/melvil/pull/24#discussion_r191193991","pull_request_url":"https://api.github.com/repos/InkubatorTieto/melvil/pulls/24","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/InkubatorTieto/melvil/pulls/comments/191193991"},"html":{"href":"https://github.com/InkubatorTieto/melvil/pull/24#discussion_r191193991"},"pull_request":{"href":"https://api.github.com/repos/InkubatorTieto/melvil/pulls/24"}}},"pull_request":{"url":"https://api.github.com/repos/InkubatorTieto/melvil/pulls/24","id":190918049,"html_url":"https://github.com/InkubatorTieto/melvil/pull/24","diff_url":"https://github.com/InkubatorTieto/melvil/pull/24.diff","patch_url":"https://github.com/InkubatorTieto/melvil/pull/24.patch","issue_url":"https://api.github.com/repos/InkubatorTieto/melvil/issues/24","number":24,"state":"open","locked":false,"title":"Release/280518","user":{"login":"IzabelaMamrot","id":36516606,"avatar_url":"https://avatars1.githubusercontent.com/u/36516606?v=4","gravatar_id":"","url":"https://api.github.com/users/IzabelaMamrot","html_url":"https://github.com/IzabelaMamrot","followers_url":"https://api.github.com/users/IzabelaMamrot/followers","following_url":"https://api.github.com/users/IzabelaMamrot/following{/other_user}","gists_url":"https://api.github.com/users/IzabelaMamrot/gists{/gist_id}","starred_url":"https://api.github.com/users/IzabelaMamrot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IzabelaMamrot/subscriptions","organizations_url":"https://api.github.com/users/IzabelaMamrot/orgs","repos_url":"https://api.github.com/users/IzabelaMamrot/repos","events_url":"https://api.github.com/users/IzabelaMamrot/events{/privacy}","received_events_url":"https://api.github.com/users/IzabelaMamrot/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-05-28T12:27:55Z","updated_at":"2018-05-28T12:28:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"16e81d71abd12a9d95ee2716d35928e286613f4c","assignee":null,"assignees":[],"requested_reviewers":[{"login":"etude-ist","id":5578427,"avatar_url":"https://avatars1.githubusercontent.com/u/5578427?v=4","gravatar_id":"","url":"https://api.github.com/users/etude-ist","html_url":"https://github.com/etude-ist","followers_url":"https://api.github.com/users/etude-ist/followers","following_url":"https://api.github.com/users/etude-ist/following{/other_user}","gists_url":"https://api.github.com/users/etude-ist/gists{/gist_id}","starred_url":"https://api.github.com/users/etude-ist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/etude-ist/subscriptions","organizations_url":"https://api.github.com/users/etude-ist/orgs","repos_url":"https://api.github.com/users/etude-ist/repos","events_url":"https://api.github.com/users/etude-ist/events{/privacy}","received_events_url":"https://api.github.com/users/etude-ist/received_events","type":"User","site_admin":false},{"login":"tdiak","id":15943025,"avatar_url":"https://avatars3.githubusercontent.com/u/15943025?v=4","gravatar_id":"","url":"https://api.github.com/users/tdiak","html_url":"https://github.com/tdiak","followers_url":"https://api.github.com/users/tdiak/followers","following_url":"https://api.github.com/users/tdiak/following{/other_user}","gists_url":"https://api.github.com/users/tdiak/gists{/gist_id}","starred_url":"https://api.github.com/users/tdiak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tdiak/subscriptions","organizations_url":"https://api.github.com/users/tdiak/orgs","repos_url":"https://api.github.com/users/tdiak/repos","events_url":"https://api.github.com/users/tdiak/events{/privacy}","received_events_url":"https://api.github.com/users/tdiak/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/InkubatorTieto/melvil/pulls/24/commits","review_comments_url":"https://api.github.com/repos/InkubatorTieto/melvil/pulls/24/comments","review_comment_url":"https://api.github.com/repos/InkubatorTieto/melvil/pulls/comments{/number}","comments_url":"https://api.github.com/repos/InkubatorTieto/melvil/issues/24/comments","statuses_url":"https://api.github.com/repos/InkubatorTieto/melvil/statuses/cb0ee04225c35c0b8b1b4a7eea326012de7f980f","head":{"label":"InkubatorTieto:release/280518","ref":"release/280518","sha":"cb0ee04225c35c0b8b1b4a7eea326012de7f980f","user":{"login":"InkubatorTieto","id":38905594,"avatar_url":"https://avatars0.githubusercontent.com/u/38905594?v=4","gravatar_id":"","url":"https://api.github.com/users/InkubatorTieto","html_url":"https://github.com/InkubatorTieto","followers_url":"https://api.github.com/users/InkubatorTieto/followers","following_url":"https://api.github.com/users/InkubatorTieto/following{/other_user}","gists_url":"https://api.github.com/users/InkubatorTieto/gists{/gist_id}","starred_url":"https://api.github.com/users/InkubatorTieto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/InkubatorTieto/subscriptions","organizations_url":"https://api.github.com/users/InkubatorTieto/orgs","repos_url":"https://api.github.com/users/InkubatorTieto/repos","events_url":"https://api.github.com/users/InkubatorTieto/events{/privacy}","received_events_url":"https://api.github.com/users/InkubatorTieto/received_events","type":"Organization","site_admin":false},"repo":{"id":131816331,"name":"melvil","full_name":"InkubatorTieto/melvil","owner":{"login":"InkubatorTieto","id":38905594,"avatar_url":"https://avatars0.githubusercontent.com/u/38905594?v=4","gravatar_id":"","url":"https://api.github.com/users/InkubatorTieto","html_url":"https://github.com/InkubatorTieto","followers_url":"https://api.github.com/users/InkubatorTieto/followers","following_url":"https://api.github.com/users/InkubatorTieto/following{/other_user}","gists_url":"https://api.github.com/users/InkubatorTieto/gists{/gist_id}","starred_url":"https://api.github.com/users/InkubatorTieto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/InkubatorTieto/subscriptions","organizations_url":"https://api.github.com/users/InkubatorTieto/orgs","repos_url":"https://api.github.com/users/InkubatorTieto/repos","events_url":"https://api.github.com/users/InkubatorTieto/events{/privacy}","received_events_url":"https://api.github.com/users/InkubatorTieto/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/InkubatorTieto/melvil","description":null,"fork":false,"url":"https://api.github.com/repos/InkubatorTieto/melvil","forks_url":"https://api.github.com/repos/InkubatorTieto/melvil/forks","keys_url":"https://api.github.com/repos/InkubatorTieto/melvil/keys{/key_id}","collaborators_url":"https://api.github.com/repos/InkubatorTieto/melvil/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/InkubatorTieto/melvil/teams","hooks_url":"https://api.github.com/repos/InkubatorTieto/melvil/hooks","issue_events_url":"https://api.github.com/repos/InkubatorTieto/melvil/issues/events{/number}","events_url":"https://api.github.com/repos/InkubatorTieto/melvil/events","assignees_url":"https://api.github.com/repos/InkubatorTieto/melvil/assignees{/user}","branches_url":"https://api.github.com/repos/InkubatorTieto/melvil/branches{/branch}","tags_url":"https://api.github.com/repos/InkubatorTieto/melvil/tags","blobs_url":"https://api.github.com/repos/InkubatorTieto/melvil/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/InkubatorTieto/melvil/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/InkubatorTieto/melvil/git/refs{/sha}","trees_url":"https://api.github.com/repos/InkubatorTieto/melvil/git/trees{/sha}","statuses_url":"https://api.github.com/repos/InkubatorTieto/melvil/statuses/{sha}","languages_url":"https://api.github.com/repos/InkubatorTieto/melvil/languages","stargazers_url":"https://api.github.com/repos/InkubatorTieto/melvil/stargazers","contributors_url":"https://api.github.com/repos/InkubatorTieto/melvil/contributors","subscribers_url":"https://api.github.com/repos/InkubatorTieto/melvil/subscribers","subscription_url":"https://api.github.com/repos/InkubatorTieto/melvil/subscription","commits_url":"https://api.github.com/repos/InkubatorTieto/melvil/commits{/sha}","git_commits_url":"https://api.github.com/repos/InkubatorTieto/melvil/git/commits{/sha}","comments_url":"https://api.github.com/repos/InkubatorTieto/melvil/comments{/number}","issue_comment_url":"https://api.github.com/repos/InkubatorTieto/melvil/issues/comments{/number}","contents_url":"https://api.github.com/repos/InkubatorTieto/melvil/contents/{+path}","compare_url":"https://api.github.com/repos/InkubatorTieto/melvil/compare/{base}...{head}","merges_url":"https://api.github.com/repos/InkubatorTieto/melvil/merges","archive_url":"https://api.github.com/repos/InkubatorTieto/melvil/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/InkubatorTieto/melvil/downloads","issues_url":"https://api.github.com/repos/InkubatorTieto/melvil/issues{/number}","pulls_url":"https://api.github.com/repos/InkubatorTieto/melvil/pulls{/number}","milestones_url":"https://api.github.com/repos/InkubatorTieto/melvil/milestones{/number}","notifications_url":"https://api.github.com/repos/InkubatorTieto/melvil/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/InkubatorTieto/melvil/labels{/name}","releases_url":"https://api.github.com/repos/InkubatorTieto/melvil/releases{/id}","deployments_url":"https://api.github.com/repos/InkubatorTieto/melvil/deployments","created_at":"2018-05-02T07:46:34Z","updated_at":"2018-05-16T15:07:17Z","pushed_at":"2018-05-28T12:27:56Z","git_url":"git://github.com/InkubatorTieto/melvil.git","ssh_url":"git@github.com:InkubatorTieto/melvil.git","clone_url":"https://github.com/InkubatorTieto/melvil.git","svn_url":"https://github.com/InkubatorTieto/melvil","homepage":null,"size":15660,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":11,"license":null,"forks":1,"open_issues":11,"watchers":1,"default_branch":"master"}},"base":{"label":"InkubatorTieto:master","ref":"master","sha":"54dcdc7c344afd1ae0c84ad5a245696f1feecbd8","user":{"login":"InkubatorTieto","id":38905594,"avatar_url":"https://avatars0.githubusercontent.com/u/38905594?v=4","gravatar_id":"","url":"https://api.github.com/users/InkubatorTieto","html_url":"https://github.com/InkubatorTieto","followers_url":"https://api.github.com/users/InkubatorTieto/followers","following_url":"https://api.github.com/users/InkubatorTieto/following{/other_user}","gists_url":"https://api.github.com/users/InkubatorTieto/gists{/gist_id}","starred_url":"https://api.github.com/users/InkubatorTieto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/InkubatorTieto/subscriptions","organizations_url":"https://api.github.com/users/InkubatorTieto/orgs","repos_url":"https://api.github.com/users/InkubatorTieto/repos","events_url":"https://api.github.com/users/InkubatorTieto/events{/privacy}","received_events_url":"https://api.github.com/users/InkubatorTieto/received_events","type":"Organization","site_admin":false},"repo":{"id":131816331,"name":"melvil","full_name":"InkubatorTieto/melvil","owner":{"login":"InkubatorTieto","id":38905594,"avatar_url":"https://avatars0.githubusercontent.com/u/38905594?v=4","gravatar_id":"","url":"https://api.github.com/users/InkubatorTieto","html_url":"https://github.com/InkubatorTieto","followers_url":"https://api.github.com/users/InkubatorTieto/followers","following_url":"https://api.github.com/users/InkubatorTieto/following{/other_user}","gists_url":"https://api.github.com/users/InkubatorTieto/gists{/gist_id}","starred_url":"https://api.github.com/users/InkubatorTieto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/InkubatorTieto/subscriptions","organizations_url":"https://api.github.com/users/InkubatorTieto/orgs","repos_url":"https://api.github.com/users/InkubatorTieto/repos","events_url":"https://api.github.com/users/InkubatorTieto/events{/privacy}","received_events_url":"https://api.github.com/users/InkubatorTieto/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/InkubatorTieto/melvil","description":null,"fork":false,"url":"https://api.github.com/repos/InkubatorTieto/melvil","forks_url":"https://api.github.com/repos/InkubatorTieto/melvil/forks","keys_url":"https://api.github.com/repos/InkubatorTieto/melvil/keys{/key_id}","collaborators_url":"https://api.github.com/repos/InkubatorTieto/melvil/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/InkubatorTieto/melvil/teams","hooks_url":"https://api.github.com/repos/InkubatorTieto/melvil/hooks","issue_events_url":"https://api.github.com/repos/InkubatorTieto/melvil/issues/events{/number}","events_url":"https://api.github.com/repos/InkubatorTieto/melvil/events","assignees_url":"https://api.github.com/repos/InkubatorTieto/melvil/assignees{/user}","branches_url":"https://api.github.com/repos/InkubatorTieto/melvil/branches{/branch}","tags_url":"https://api.github.com/repos/InkubatorTieto/melvil/tags","blobs_url":"https://api.github.com/repos/InkubatorTieto/melvil/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/InkubatorTieto/melvil/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/InkubatorTieto/melvil/git/refs{/sha}","trees_url":"https://api.github.com/repos/InkubatorTieto/melvil/git/trees{/sha}","statuses_url":"https://api.github.com/repos/InkubatorTieto/melvil/statuses/{sha}","languages_url":"https://api.github.com/repos/InkubatorTieto/melvil/languages","stargazers_url":"https://api.github.com/repos/InkubatorTieto/melvil/stargazers","contributors_url":"https://api.github.com/repos/InkubatorTieto/melvil/contributors","subscribers_url":"https://api.github.com/repos/InkubatorTieto/melvil/subscribers","subscription_url":"https://api.github.com/repos/InkubatorTieto/melvil/subscription","commits_url":"https://api.github.com/repos/InkubatorTieto/melvil/commits{/sha}","git_commits_url":"https://api.github.com/repos/InkubatorTieto/melvil/git/commits{/sha}","comments_url":"https://api.github.com/repos/InkubatorTieto/melvil/comments{/number}","issue_comment_url":"https://api.github.com/repos/InkubatorTieto/melvil/issues/comments{/number}","contents_url":"https://api.github.com/repos/InkubatorTieto/melvil/contents/{+path}","compare_url":"https://api.github.com/repos/InkubatorTieto/melvil/compare/{base}...{head}","merges_url":"https://api.github.com/repos/InkubatorTieto/melvil/merges","archive_url":"https://api.github.com/repos/InkubatorTieto/melvil/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/InkubatorTieto/melvil/downloads","issues_url":"https://api.github.com/repos/InkubatorTieto/melvil/issues{/number}","pulls_url":"https://api.github.com/repos/InkubatorTieto/melvil/pulls{/number}","milestones_url":"https://api.github.com/repos/InkubatorTieto/melvil/milestones{/number}","notifications_url":"https://api.github.com/repos/InkubatorTieto/melvil/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/InkubatorTieto/melvil/labels{/name}","releases_url":"https://api.github.com/repos/InkubatorTieto/melvil/releases{/id}","deployments_url":"https://api.github.com/repos/InkubatorTieto/melvil/deployments","created_at":"2018-05-02T07:46:34Z","updated_at":"2018-05-16T15:07:17Z","pushed_at":"2018-05-28T12:27:56Z","git_url":"git://github.com/InkubatorTieto/melvil.git","ssh_url":"git@github.com:InkubatorTieto/melvil.git","clone_url":"https://github.com/InkubatorTieto/melvil.git","svn_url":"https://github.com/InkubatorTieto/melvil","homepage":null,"size":15660,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":11,"license":null,"forks":1,"open_issues":11,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/InkubatorTieto/melvil/pulls/24"},"html":{"href":"https://github.com/InkubatorTieto/melvil/pull/24"},"issue":{"href":"https://api.github.com/repos/InkubatorTieto/melvil/issues/24"},"comments":{"href":"https://api.github.com/repos/InkubatorTieto/melvil/issues/24/comments"},"review_comments":{"href":"https://api.github.com/repos/InkubatorTieto/melvil/pulls/24/comments"},"review_comment":{"href":"https://api.github.com/repos/InkubatorTieto/melvil/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/InkubatorTieto/melvil/pulls/24/commits"},"statuses":{"href":"https://api.github.com/repos/InkubatorTieto/melvil/statuses/cb0ee04225c35c0b8b1b4a7eea326012de7f980f"}},"author_association":"NONE"}}
{"actor":{"display_login":"stickler-ci"}}