{"action":"created","comment":{"url":"https://api.github.com/repos/inspirehep/inspire-next/pulls/comments/134786838","pull_request_review_id":58120530,"id":134786838,"diff_hunk":"@@ -0,0 +1,118 @@\n+# -*- coding: utf-8 -*-\n+#\n+# This file is part of INSPIRE.\n+# Copyright (C) 2014-2017 CERN.\n+#\n+# INSPIRE is free software: you can redistribute it and/or modify\n+# it under the terms of the GNU General Public License as published by\n+# the Free Software Foundation, either version 3 of the License, or\n+# (at your option) any later version.\n+#\n+# INSPIRE is distributed in the hope that it will be useful,\n+# but WITHOUT ANY WARRANTY; without even the implied warranty of\n+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n+# GNU General Public License for more details.\n+#\n+# You should have received a copy of the GNU General Public License\n+# along with INSPIRE. If not, see <http://www.gnu.org/licenses/>.\n+#\n+# In applying this license, CERN does not waive the privileges and immunities\n+# granted to it by virtue of its status as an Intergovernmental Organization\n+# or submit itself to any jurisdiction.\n+\n+from __future__ import absolute_import, division, print_function\n+\n+import os\n+\n+import pkg_resources\n+import pytest\n+from flask_security.utils import encrypt_password\n+import requests_mock\n+\n+from invenio_accounts.models import SessionActivity, User\n+from invenio_accounts.testutils import login_user_via_session\n+from invenio_db import db\n+\n+\n+@pytest.fixture(scope='module')\n+def users(app):\n+    \"\"\"Create users needed in this test module.\"\"\"\n+    scientist = User(\n+        email='scientist@inspirehep.net',\n+        password=encrypt_password('scientist'),\n+        active=True,\n+    )\n+    db.session.add(scientist)\n+    db.session.commit()\n+\n+    yield\n+\n+    User.query.filter_by(email='scientist@inspirehep.net').delete()\n+    db.session.commit()\n+\n+\n+@pytest.fixture(scope='function')\n+def log_in_as_scientist(users, app_client):\n+    \"\"\"Ensure that we're logged in as an unprivileged user.\"\"\"\n+    login_user_via_session(app_client, email='scientist@inspirehep.net')\n+\n+    yield\n+\n+    SessionActivity.query.delete()\n+    db.session.commit()\n+\n+\n+def test_valid_arxiv(log_in_as_scientist, app_client):\n+    with requests_mock.Mocker() as requests_mocker:\n+\n+        requests_mocker.register_uri(\n+            'GET',\n+            'http://export.arxiv.org/oai2',\n+            text=pkg_resources.resource_string(\n+                __name__, os.path.join('fixtures', 'valid_response_message.xml')),\n+        )\n+\n+        assert app_client.get(\n+            '/arxiv/search?arxiv=1305.0014').status_code == 200\n+\n+\n+def test_malformed_arxiv(log_in_as_scientist, app_client):\n+    with requests_mock.Mocker() as requests_mocker:\n+\n+        requests_mocker.register_uri(\n+            'GET',\n+            'http://export.arxiv.org/oai2',\n+            text=pkg_resources.resource_string(\n+                __name__, os.path.join('fixtures', 'malformed_response_message.xml')),\n+        )\n+\n+        assert app_client.get(\n+            '/arxiv/search?arxiv=foo-bar-baz').status_code == 422","path":"tests/integration/arxiv/test_arxiv_views.py","position":90,"original_position":90,"commit_id":"0adf10e8120c55e1f0cf6f459125b803746ddb3d","original_commit_id":"0adf10e8120c55e1f0cf6f459125b803746ddb3d","user":{"login":"jacquerie","id":381280,"avatar_url":"https://avatars2.githubusercontent.com/u/381280?v=4","gravatar_id":"","url":"https://api.github.com/users/jacquerie","html_url":"https://github.com/jacquerie","followers_url":"https://api.github.com/users/jacquerie/followers","following_url":"https://api.github.com/users/jacquerie/following{/other_user}","gists_url":"https://api.github.com/users/jacquerie/gists{/gist_id}","starred_url":"https://api.github.com/users/jacquerie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacquerie/subscriptions","organizations_url":"https://api.github.com/users/jacquerie/orgs","repos_url":"https://api.github.com/users/jacquerie/repos","events_url":"https://api.github.com/users/jacquerie/events{/privacy}","received_events_url":"https://api.github.com/users/jacquerie/received_events","type":"User","site_admin":false},"body":"The same goes for the error messages (although I'm not sure if the JavaScript uses them to do stuff...)","created_at":"2017-08-23T15:30:52Z","updated_at":"2017-08-23T15:30:52Z","html_url":"https://github.com/inspirehep/inspire-next/pull/2670#discussion_r134786838","pull_request_url":"https://api.github.com/repos/inspirehep/inspire-next/pulls/2670","_links":{"self":{"href":"https://api.github.com/repos/inspirehep/inspire-next/pulls/comments/134786838"},"html":{"href":"https://github.com/inspirehep/inspire-next/pull/2670#discussion_r134786838"},"pull_request":{"href":"https://api.github.com/repos/inspirehep/inspire-next/pulls/2670"}}},"pull_request":{"url":"https://api.github.com/repos/inspirehep/inspire-next/pulls/2670","id":137245045,"html_url":"https://github.com/inspirehep/inspire-next/pull/2670","diff_url":"https://github.com/inspirehep/inspire-next/pull/2670.diff","patch_url":"https://github.com/inspirehep/inspire-next/pull/2670.patch","issue_url":"https://api.github.com/repos/inspirehep/inspire-next/issues/2670","number":2670,"state":"open","locked":false,"title":"Tests for the 'arxiv' module","user":{"login":"iulianav","id":20461142,"avatar_url":"https://avatars3.githubusercontent.com/u/20461142?v=4","gravatar_id":"","url":"https://api.github.com/users/iulianav","html_url":"https://github.com/iulianav","followers_url":"https://api.github.com/users/iulianav/followers","following_url":"https://api.github.com/users/iulianav/following{/other_user}","gists_url":"https://api.github.com/users/iulianav/gists{/gist_id}","starred_url":"https://api.github.com/users/iulianav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iulianav/subscriptions","organizations_url":"https://api.github.com/users/iulianav/orgs","repos_url":"https://api.github.com/users/iulianav/repos","events_url":"https://api.github.com/users/iulianav/events{/privacy}","received_events_url":"https://api.github.com/users/iulianav/received_events","type":"User","site_admin":false},"body":"<!--- Provide a general summary of your changes in the Title above -->\r\n\r\n## Description\r\n<!--- Describe your changes in detail -->\r\nI have written a series of integration tests for all the possible xml response messages that the 'arxiv' module might have to deal with.\r\n\r\n## Related Issue\r\n<!--- If suggesting a new feature or change, please discuss it in an issue first -->\r\n<!--- If fixing a bug, there should be an issue describing it with steps to reproduce -->\r\n<!--- Please link to the issue here: -->\r\nPreviously, this module was not tested at all. This is not good practice.\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\nFollowing TDD mantra prior to refactoring of the 'arxiv' module, i.e. reimplementing it with blueprints.\r\n\r\n## Checklist:\r\n<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->\r\n<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->\r\n- [ ] I have all the information that I need (if not, move to `RFC` and look for it).\r\n- [ ] I linked the related issue(s) in the corresponding commit logs.\r\n- [x] I wrote [good commit log messages](https://github.com/torvalds/subsurface-for-dirk/blob/5f15ad5a86ada3c5e574041a5f9d85235322dabb/README#L92-L119).\r\n- [x] My code follows the code style of this project.\r\n- [ ] I've added any new docs if API/utils methods were added.\r\n- [ ] I have updated the existing documentation accordingly.\r\n- [x] I have added tests to cover my changes.\r\n- [x] All new and existing tests passed.\r\n<!--- After this you can move the PR to `Needs Review` -->\r\n","created_at":"2017-08-23T15:13:04Z","updated_at":"2017-08-23T15:30:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"01be83ec6607f8d9fe22c9cd5a80f828f613cc16","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/inspirehep/inspire-next/pulls/2670/commits","review_comments_url":"https://api.github.com/repos/inspirehep/inspire-next/pulls/2670/comments","review_comment_url":"https://api.github.com/repos/inspirehep/inspire-next/pulls/comments{/number}","comments_url":"https://api.github.com/repos/inspirehep/inspire-next/issues/2670/comments","statuses_url":"https://api.github.com/repos/inspirehep/inspire-next/statuses/0adf10e8120c55e1f0cf6f459125b803746ddb3d","head":{"label":"iulianav:reimplement-arxiv-module-with-blueprints","ref":"reimplement-arxiv-module-with-blueprints","sha":"0adf10e8120c55e1f0cf6f459125b803746ddb3d","user":{"login":"iulianav","id":20461142,"avatar_url":"https://avatars3.githubusercontent.com/u/20461142?v=4","gravatar_id":"","url":"https://api.github.com/users/iulianav","html_url":"https://github.com/iulianav","followers_url":"https://api.github.com/users/iulianav/followers","following_url":"https://api.github.com/users/iulianav/following{/other_user}","gists_url":"https://api.github.com/users/iulianav/gists{/gist_id}","starred_url":"https://api.github.com/users/iulianav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iulianav/subscriptions","organizations_url":"https://api.github.com/users/iulianav/orgs","repos_url":"https://api.github.com/users/iulianav/repos","events_url":"https://api.github.com/users/iulianav/events{/privacy}","received_events_url":"https://api.github.com/users/iulianav/received_events","type":"User","site_admin":false},"repo":{"id":99801591,"name":"inspire-next","full_name":"iulianav/inspire-next","owner":{"login":"iulianav","id":20461142,"avatar_url":"https://avatars3.githubusercontent.com/u/20461142?v=4","gravatar_id":"","url":"https://api.github.com/users/iulianav","html_url":"https://github.com/iulianav","followers_url":"https://api.github.com/users/iulianav/followers","following_url":"https://api.github.com/users/iulianav/following{/other_user}","gists_url":"https://api.github.com/users/iulianav/gists{/gist_id}","starred_url":"https://api.github.com/users/iulianav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iulianav/subscriptions","organizations_url":"https://api.github.com/users/iulianav/orgs","repos_url":"https://api.github.com/users/iulianav/repos","events_url":"https://api.github.com/users/iulianav/events{/privacy}","received_events_url":"https://api.github.com/users/iulianav/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/iulianav/inspire-next","description":"The next version of INSPIRE","fork":true,"url":"https://api.github.com/repos/iulianav/inspire-next","forks_url":"https://api.github.com/repos/iulianav/inspire-next/forks","keys_url":"https://api.github.com/repos/iulianav/inspire-next/keys{/key_id}","collaborators_url":"https://api.github.com/repos/iulianav/inspire-next/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/iulianav/inspire-next/teams","hooks_url":"https://api.github.com/repos/iulianav/inspire-next/hooks","issue_events_url":"https://api.github.com/repos/iulianav/inspire-next/issues/events{/number}","events_url":"https://api.github.com/repos/iulianav/inspire-next/events","assignees_url":"https://api.github.com/repos/iulianav/inspire-next/assignees{/user}","branches_url":"https://api.github.com/repos/iulianav/inspire-next/branches{/branch}","tags_url":"https://api.github.com/repos/iulianav/inspire-next/tags","blobs_url":"https://api.github.com/repos/iulianav/inspire-next/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/iulianav/inspire-next/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/iulianav/inspire-next/git/refs{/sha}","trees_url":"https://api.github.com/repos/iulianav/inspire-next/git/trees{/sha}","statuses_url":"https://api.github.com/repos/iulianav/inspire-next/statuses/{sha}","languages_url":"https://api.github.com/repos/iulianav/inspire-next/languages","stargazers_url":"https://api.github.com/repos/iulianav/inspire-next/stargazers","contributors_url":"https://api.github.com/repos/iulianav/inspire-next/contributors","subscribers_url":"https://api.github.com/repos/iulianav/inspire-next/subscribers","subscription_url":"https://api.github.com/repos/iulianav/inspire-next/subscription","commits_url":"https://api.github.com/repos/iulianav/inspire-next/commits{/sha}","git_commits_url":"https://api.github.com/repos/iulianav/inspire-next/git/commits{/sha}","comments_url":"https://api.github.com/repos/iulianav/inspire-next/comments{/number}","issue_comment_url":"https://api.github.com/repos/iulianav/inspire-next/issues/comments{/number}","contents_url":"https://api.github.com/repos/iulianav/inspire-next/contents/{+path}","compare_url":"https://api.github.com/repos/iulianav/inspire-next/compare/{base}...{head}","merges_url":"https://api.github.com/repos/iulianav/inspire-next/merges","archive_url":"https://api.github.com/repos/iulianav/inspire-next/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/iulianav/inspire-next/downloads","issues_url":"https://api.github.com/repos/iulianav/inspire-next/issues{/number}","pulls_url":"https://api.github.com/repos/iulianav/inspire-next/pulls{/number}","milestones_url":"https://api.github.com/repos/iulianav/inspire-next/milestones{/number}","notifications_url":"https://api.github.com/repos/iulianav/inspire-next/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/iulianav/inspire-next/labels{/name}","releases_url":"https://api.github.com/repos/iulianav/inspire-next/releases{/id}","deployments_url":"https://api.github.com/repos/iulianav/inspire-next/deployments","created_at":"2017-08-09T11:37:52Z","updated_at":"2017-08-09T11:37:55Z","pushed_at":"2017-08-23T15:11:26Z","git_url":"git://github.com/iulianav/inspire-next.git","ssh_url":"git@github.com:iulianav/inspire-next.git","clone_url":"https://github.com/iulianav/inspire-next.git","svn_url":"https://github.com/iulianav/inspire-next","homepage":"https://labs.inspirehep.net","size":65285,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"inspirehep:master","ref":"master","sha":"f77070ef0db350cdd1700433a47a2fea41b8b758","user":{"login":"inspirehep","id":356664,"avatar_url":"https://avatars3.githubusercontent.com/u/356664?v=4","gravatar_id":"","url":"https://api.github.com/users/inspirehep","html_url":"https://github.com/inspirehep","followers_url":"https://api.github.com/users/inspirehep/followers","following_url":"https://api.github.com/users/inspirehep/following{/other_user}","gists_url":"https://api.github.com/users/inspirehep/gists{/gist_id}","starred_url":"https://api.github.com/users/inspirehep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inspirehep/subscriptions","organizations_url":"https://api.github.com/users/inspirehep/orgs","repos_url":"https://api.github.com/users/inspirehep/repos","events_url":"https://api.github.com/users/inspirehep/events{/privacy}","received_events_url":"https://api.github.com/users/inspirehep/received_events","type":"Organization","site_admin":false},"repo":{"id":15221515,"name":"inspire-next","full_name":"inspirehep/inspire-next","owner":{"login":"inspirehep","id":356664,"avatar_url":"https://avatars3.githubusercontent.com/u/356664?v=4","gravatar_id":"","url":"https://api.github.com/users/inspirehep","html_url":"https://github.com/inspirehep","followers_url":"https://api.github.com/users/inspirehep/followers","following_url":"https://api.github.com/users/inspirehep/following{/other_user}","gists_url":"https://api.github.com/users/inspirehep/gists{/gist_id}","starred_url":"https://api.github.com/users/inspirehep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inspirehep/subscriptions","organizations_url":"https://api.github.com/users/inspirehep/orgs","repos_url":"https://api.github.com/users/inspirehep/repos","events_url":"https://api.github.com/users/inspirehep/events{/privacy}","received_events_url":"https://api.github.com/users/inspirehep/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/inspirehep/inspire-next","description":"The next version of INSPIRE","fork":false,"url":"https://api.github.com/repos/inspirehep/inspire-next","forks_url":"https://api.github.com/repos/inspirehep/inspire-next/forks","keys_url":"https://api.github.com/repos/inspirehep/inspire-next/keys{/key_id}","collaborators_url":"https://api.github.com/repos/inspirehep/inspire-next/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/inspirehep/inspire-next/teams","hooks_url":"https://api.github.com/repos/inspirehep/inspire-next/hooks","issue_events_url":"https://api.github.com/repos/inspirehep/inspire-next/issues/events{/number}","events_url":"https://api.github.com/repos/inspirehep/inspire-next/events","assignees_url":"https://api.github.com/repos/inspirehep/inspire-next/assignees{/user}","branches_url":"https://api.github.com/repos/inspirehep/inspire-next/branches{/branch}","tags_url":"https://api.github.com/repos/inspirehep/inspire-next/tags","blobs_url":"https://api.github.com/repos/inspirehep/inspire-next/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/inspirehep/inspire-next/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/inspirehep/inspire-next/git/refs{/sha}","trees_url":"https://api.github.com/repos/inspirehep/inspire-next/git/trees{/sha}","statuses_url":"https://api.github.com/repos/inspirehep/inspire-next/statuses/{sha}","languages_url":"https://api.github.com/repos/inspirehep/inspire-next/languages","stargazers_url":"https://api.github.com/repos/inspirehep/inspire-next/stargazers","contributors_url":"https://api.github.com/repos/inspirehep/inspire-next/contributors","subscribers_url":"https://api.github.com/repos/inspirehep/inspire-next/subscribers","subscription_url":"https://api.github.com/repos/inspirehep/inspire-next/subscription","commits_url":"https://api.github.com/repos/inspirehep/inspire-next/commits{/sha}","git_commits_url":"https://api.github.com/repos/inspirehep/inspire-next/git/commits{/sha}","comments_url":"https://api.github.com/repos/inspirehep/inspire-next/comments{/number}","issue_comment_url":"https://api.github.com/repos/inspirehep/inspire-next/issues/comments{/number}","contents_url":"https://api.github.com/repos/inspirehep/inspire-next/contents/{+path}","compare_url":"https://api.github.com/repos/inspirehep/inspire-next/compare/{base}...{head}","merges_url":"https://api.github.com/repos/inspirehep/inspire-next/merges","archive_url":"https://api.github.com/repos/inspirehep/inspire-next/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/inspirehep/inspire-next/downloads","issues_url":"https://api.github.com/repos/inspirehep/inspire-next/issues{/number}","pulls_url":"https://api.github.com/repos/inspirehep/inspire-next/pulls{/number}","milestones_url":"https://api.github.com/repos/inspirehep/inspire-next/milestones{/number}","notifications_url":"https://api.github.com/repos/inspirehep/inspire-next/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/inspirehep/inspire-next/labels{/name}","releases_url":"https://api.github.com/repos/inspirehep/inspire-next/releases{/id}","deployments_url":"https://api.github.com/repos/inspirehep/inspire-next/deployments","created_at":"2013-12-16T09:11:58Z","updated_at":"2017-07-02T11:19:31Z","pushed_at":"2017-08-23T15:22:34Z","git_url":"git://github.com/inspirehep/inspire-next.git","ssh_url":"git@github.com:inspirehep/inspire-next.git","clone_url":"https://github.com/inspirehep/inspire-next.git","svn_url":"https://github.com/inspirehep/inspire-next","homepage":"https://labs.inspirehep.net","size":65630,"stargazers_count":27,"watchers_count":27,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":43,"mirror_url":null,"open_issues_count":272,"forks":43,"open_issues":272,"watchers":27,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/inspirehep/inspire-next/pulls/2670"},"html":{"href":"https://github.com/inspirehep/inspire-next/pull/2670"},"issue":{"href":"https://api.github.com/repos/inspirehep/inspire-next/issues/2670"},"comments":{"href":"https://api.github.com/repos/inspirehep/inspire-next/issues/2670/comments"},"review_comments":{"href":"https://api.github.com/repos/inspirehep/inspire-next/pulls/2670/comments"},"review_comment":{"href":"https://api.github.com/repos/inspirehep/inspire-next/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/inspirehep/inspire-next/pulls/2670/commits"},"statuses":{"href":"https://api.github.com/repos/inspirehep/inspire-next/statuses/0adf10e8120c55e1f0cf6f459125b803746ddb3d"}}}}
{"actor":{"display_login":"jacquerie"}}