{"action":"created","comment":{"url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/pulls/comments/130216839","pull_request_review_id":53072594,"id":130216839,"diff_hunk":"@@ -0,0 +1,99 @@\n+# -*- coding: utf-8 -*-\n+#\n+# This file is part of Invenio.\n+# Copyright (C) 2017 CERN.\n+#\n+# Invenio is free software; you can redistribute it\n+# and/or modify it under the terms of the GNU General Public License as\n+# published by the Free Software Foundation; either version 2 of the\n+# License, or (at your option) any later version.\n+#\n+# Invenio is distributed in the hope that it will be\n+# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of\n+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n+# General Public License for more details.\n+#\n+# You should have received a copy of the GNU General Public License\n+# along with Invenio; if not, write to the\n+# Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,\n+# MA 02111-1307, USA.\n+#\n+# In applying this license, CERN does not\n+# waive the privileges and immunities granted to it by virtue of its status\n+# as an Intergovernmental Organization or submit itself to any jurisdiction.\n+\n+\"\"\"pdf_grobid tests.\"\"\"\n+\n+from __future__ import absolute_import, print_function\n+\n+import importlib\n+import os\n+from io import open\n+from pkg_resources import EntryPoint\n+\n+from flask import url_for\n+\n+import pytest\n+from invenio_files_processor.processors import pdf_grobid\n+\n+\n+class MockEntryPoint(EntryPoint):\n+    \"\"\"Mocking of entrypoint.\"\"\"\n+\n+    def load(self):\n+        \"\"\"Mock load entry point.\"\"\"\n+        return importlib.import_module(self.module_name)\n+\n+\n+@pytest.yield_fixture()\n+def tei_xml():\n+    \"\"\"Provide pdf fixture.\"\"\"\n+    with open(os.path.join(os.path.dirname(__file__),\n+                           'fixtures', 'article.xml'), encoding='utf-8') as f:\n+        yield f.read()\n+\n+\n+def login_user(client, user):\n+    \"\"\"Log in a specified user.\"\"\"\n+    with client.session_transaction() as sess:\n+        sess['user_id'] = user.id if user else None\n+        sess['_fresh'] = True\n+\n+\n+def test_permission(mocker, client, users, pdf_obj):\n+    mocker.patch('pkg_resources.iter_entry_points',\n+                 return_value=[\n+                     MockEntryPoint(\n+                         'pdf_grobid',\n+                         'invenio_files_processor.processors.pdf_grobid')\n+                 ])\n+\n+    mocker.patch('invenio_files_processor.processors.pdf_grobid.process',\n+                 return_value={},\n+                 auto_spec=True)\n+\n+    login_user(client, users['read'])\n+    resp = client.post(\n+        '/fileprocessor/pdf_grobid/{}'.format(pdf_obj.version_id))\n+    assert resp.status_code == 200\n+\n+    login_user(client, users['non-read'])\n+    resp = client.post(\n+        '/fileprocessor/pdf_grobid/{}'.format(pdf_obj.version_id))\n+    # see invenio_files_rest.views.check_permission for the description of\n+    # error codes (401, 403 and 404)\n+    assert resp.status_code == 404\n+\n+\n+def test_can_process(pdf_obj, fits_obj):\n+    assert pdf_grobid.can_process(pdf_obj)\n+    assert not pdf_grobid.can_process(fits_obj)\n+\n+\n+def test_process(mocker, pdf_obj, tei_xml):\n+    mocker.patch('invenio_grobid.api.process_pdf_stream',","path":"tests/test_pdf_grobid.py","position":94,"original_position":94,"commit_id":"ca437f5687180b8b8899addd73c34461e1cb6738","original_commit_id":"ca437f5687180b8b8899addd73c34461e1cb6738","user":{"login":"xiaom","id":21000,"avatar_url":"https://avatars2.githubusercontent.com/u/21000?v=4","gravatar_id":"","url":"https://api.github.com/users/xiaom","html_url":"https://github.com/xiaom","followers_url":"https://api.github.com/users/xiaom/followers","following_url":"https://api.github.com/users/xiaom/following{/other_user}","gists_url":"https://api.github.com/users/xiaom/gists{/gist_id}","starred_url":"https://api.github.com/users/xiaom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiaom/subscriptions","organizations_url":"https://api.github.com/users/xiaom/orgs","repos_url":"https://api.github.com/users/xiaom/repos","events_url":"https://api.github.com/users/xiaom/events{/privacy}","received_events_url":"https://api.github.com/users/xiaom/received_events","type":"User","site_admin":false},"body":"For some reason, this mocker.patch does not work.\r\nI get the following error:\r\n\r\n```\r\n    def test_process(mocker, pdf_obj, tei_xml):\r\n        mocker.patch('invenio_grobid.api.process_pdf_stream',\r\n                     return_value=tei_xml[0],\r\n                     auto_spec=True)\r\n>       metadata = pdf_grobid.process(pdf_obj)\r\n\r\ntests/test_pdf_grobid.py:97:\r\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r\ninvenio_files_processor/processors/pdf_grobid.py:47: in process\r\n    xml = process_pdf_stream(pdf_file)\r\n../invenio-grobid/invenio_grobid/api.py:44: in process_pdf_stream\r\n    \"processFulltextDocument\"),\r\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r\n\r\na = None, p = ('processFulltextDocument',), path = None, b = 'processFulltextDocument'\r\n\r\n    def join(a, *p):\r\n        \"\"\"Join two or more pathname components, inserting '/' as needed.\r\n        If any component is an absolute path, all previous path components\r\n        will be discarded.  An empty last part will result in a path that\r\n        ends with a separator.\"\"\"\r\n        path = a\r\n        for b in p:\r\n            if b.startswith('/'):\r\n                path = b\r\n>           elif path == '' or path.endswith('/'):\r\nE           AttributeError: 'NoneType' object has no attribute 'endswith'\r\n\r\n/Users/xiaom/anaconda/envs/zenodo/lib/python2.7/posixpath.py:70: AttributeError\r\n```","created_at":"2017-07-29T08:43:34Z","updated_at":"2017-07-29T08:43:34Z","html_url":"https://github.com/inveniosoftware/invenio-files-processor/pull/3#discussion_r130216839","pull_request_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/pulls/comments/130216839"},"html":{"href":"https://github.com/inveniosoftware/invenio-files-processor/pull/3#discussion_r130216839"},"pull_request":{"href":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/pulls/3","id":133085878,"html_url":"https://github.com/inveniosoftware/invenio-files-processor/pull/3","diff_url":"https://github.com/inveniosoftware/invenio-files-processor/pull/3.diff","patch_url":"https://github.com/inveniosoftware/invenio-files-processor/pull/3.patch","issue_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/issues/3","number":3,"state":"open","locked":false,"title":"add unit test","user":{"login":"xiaom","id":21000,"avatar_url":"https://avatars2.githubusercontent.com/u/21000?v=4","gravatar_id":"","url":"https://api.github.com/users/xiaom","html_url":"https://github.com/xiaom","followers_url":"https://api.github.com/users/xiaom/followers","following_url":"https://api.github.com/users/xiaom/following{/other_user}","gists_url":"https://api.github.com/users/xiaom/gists{/gist_id}","starred_url":"https://api.github.com/users/xiaom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiaom/subscriptions","organizations_url":"https://api.github.com/users/xiaom/orgs","repos_url":"https://api.github.com/users/xiaom/repos","events_url":"https://api.github.com/users/xiaom/events{/privacy}","received_events_url":"https://api.github.com/users/xiaom/received_events","type":"User","site_admin":false},"body":"This is a WIP pull request.","created_at":"2017-07-29T08:41:41Z","updated_at":"2017-07-29T08:43:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"da130df6f568afc1520bb0973a1b7f22c2e090c6","assignee":null,"assignees":[],"requested_reviewers":[{"login":"krzysztof","id":656365,"avatar_url":"https://avatars0.githubusercontent.com/u/656365?v=4","gravatar_id":"","url":"https://api.github.com/users/krzysztof","html_url":"https://github.com/krzysztof","followers_url":"https://api.github.com/users/krzysztof/followers","following_url":"https://api.github.com/users/krzysztof/following{/other_user}","gists_url":"https://api.github.com/users/krzysztof/gists{/gist_id}","starred_url":"https://api.github.com/users/krzysztof/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krzysztof/subscriptions","organizations_url":"https://api.github.com/users/krzysztof/orgs","repos_url":"https://api.github.com/users/krzysztof/repos","events_url":"https://api.github.com/users/krzysztof/events{/privacy}","received_events_url":"https://api.github.com/users/krzysztof/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/pulls/3/commits","review_comments_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/pulls/3/comments","review_comment_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/pulls/comments{/number}","comments_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/issues/3/comments","statuses_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/statuses/ca437f5687180b8b8899addd73c34461e1cb6738","head":{"label":"xiaom:master","ref":"master","sha":"ca437f5687180b8b8899addd73c34461e1cb6738","user":{"login":"xiaom","id":21000,"avatar_url":"https://avatars2.githubusercontent.com/u/21000?v=4","gravatar_id":"","url":"https://api.github.com/users/xiaom","html_url":"https://github.com/xiaom","followers_url":"https://api.github.com/users/xiaom/followers","following_url":"https://api.github.com/users/xiaom/following{/other_user}","gists_url":"https://api.github.com/users/xiaom/gists{/gist_id}","starred_url":"https://api.github.com/users/xiaom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiaom/subscriptions","organizations_url":"https://api.github.com/users/xiaom/orgs","repos_url":"https://api.github.com/users/xiaom/repos","events_url":"https://api.github.com/users/xiaom/events{/privacy}","received_events_url":"https://api.github.com/users/xiaom/received_events","type":"User","site_admin":false},"repo":{"id":98614951,"name":"invenio-files-processor","full_name":"xiaom/invenio-files-processor","owner":{"login":"xiaom","id":21000,"avatar_url":"https://avatars2.githubusercontent.com/u/21000?v=4","gravatar_id":"","url":"https://api.github.com/users/xiaom","html_url":"https://github.com/xiaom","followers_url":"https://api.github.com/users/xiaom/followers","following_url":"https://api.github.com/users/xiaom/following{/other_user}","gists_url":"https://api.github.com/users/xiaom/gists{/gist_id}","starred_url":"https://api.github.com/users/xiaom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiaom/subscriptions","organizations_url":"https://api.github.com/users/xiaom/orgs","repos_url":"https://api.github.com/users/xiaom/repos","events_url":"https://api.github.com/users/xiaom/events{/privacy}","received_events_url":"https://api.github.com/users/xiaom/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/xiaom/invenio-files-processor","description":null,"fork":true,"url":"https://api.github.com/repos/xiaom/invenio-files-processor","forks_url":"https://api.github.com/repos/xiaom/invenio-files-processor/forks","keys_url":"https://api.github.com/repos/xiaom/invenio-files-processor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xiaom/invenio-files-processor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xiaom/invenio-files-processor/teams","hooks_url":"https://api.github.com/repos/xiaom/invenio-files-processor/hooks","issue_events_url":"https://api.github.com/repos/xiaom/invenio-files-processor/issues/events{/number}","events_url":"https://api.github.com/repos/xiaom/invenio-files-processor/events","assignees_url":"https://api.github.com/repos/xiaom/invenio-files-processor/assignees{/user}","branches_url":"https://api.github.com/repos/xiaom/invenio-files-processor/branches{/branch}","tags_url":"https://api.github.com/repos/xiaom/invenio-files-processor/tags","blobs_url":"https://api.github.com/repos/xiaom/invenio-files-processor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xiaom/invenio-files-processor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xiaom/invenio-files-processor/git/refs{/sha}","trees_url":"https://api.github.com/repos/xiaom/invenio-files-processor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xiaom/invenio-files-processor/statuses/{sha}","languages_url":"https://api.github.com/repos/xiaom/invenio-files-processor/languages","stargazers_url":"https://api.github.com/repos/xiaom/invenio-files-processor/stargazers","contributors_url":"https://api.github.com/repos/xiaom/invenio-files-processor/contributors","subscribers_url":"https://api.github.com/repos/xiaom/invenio-files-processor/subscribers","subscription_url":"https://api.github.com/repos/xiaom/invenio-files-processor/subscription","commits_url":"https://api.github.com/repos/xiaom/invenio-files-processor/commits{/sha}","git_commits_url":"https://api.github.com/repos/xiaom/invenio-files-processor/git/commits{/sha}","comments_url":"https://api.github.com/repos/xiaom/invenio-files-processor/comments{/number}","issue_comment_url":"https://api.github.com/repos/xiaom/invenio-files-processor/issues/comments{/number}","contents_url":"https://api.github.com/repos/xiaom/invenio-files-processor/contents/{+path}","compare_url":"https://api.github.com/repos/xiaom/invenio-files-processor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xiaom/invenio-files-processor/merges","archive_url":"https://api.github.com/repos/xiaom/invenio-files-processor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xiaom/invenio-files-processor/downloads","issues_url":"https://api.github.com/repos/xiaom/invenio-files-processor/issues{/number}","pulls_url":"https://api.github.com/repos/xiaom/invenio-files-processor/pulls{/number}","milestones_url":"https://api.github.com/repos/xiaom/invenio-files-processor/milestones{/number}","notifications_url":"https://api.github.com/repos/xiaom/invenio-files-processor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xiaom/invenio-files-processor/labels{/name}","releases_url":"https://api.github.com/repos/xiaom/invenio-files-processor/releases{/id}","deployments_url":"https://api.github.com/repos/xiaom/invenio-files-processor/deployments","created_at":"2017-07-28T06:12:07Z","updated_at":"2017-07-28T06:12:08Z","pushed_at":"2017-07-29T08:39:24Z","git_url":"git://github.com/xiaom/invenio-files-processor.git","ssh_url":"git@github.com:xiaom/invenio-files-processor.git","clone_url":"https://github.com/xiaom/invenio-files-processor.git","svn_url":"https://github.com/xiaom/invenio-files-processor","homepage":null,"size":38,"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":"inveniosoftware:master","ref":"master","sha":"3d344657f01101a6ff1abbd9dcdddda646d9b5ec","user":{"login":"inveniosoftware","id":1157480,"avatar_url":"https://avatars1.githubusercontent.com/u/1157480?v=4","gravatar_id":"","url":"https://api.github.com/users/inveniosoftware","html_url":"https://github.com/inveniosoftware","followers_url":"https://api.github.com/users/inveniosoftware/followers","following_url":"https://api.github.com/users/inveniosoftware/following{/other_user}","gists_url":"https://api.github.com/users/inveniosoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/inveniosoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inveniosoftware/subscriptions","organizations_url":"https://api.github.com/users/inveniosoftware/orgs","repos_url":"https://api.github.com/users/inveniosoftware/repos","events_url":"https://api.github.com/users/inveniosoftware/events{/privacy}","received_events_url":"https://api.github.com/users/inveniosoftware/received_events","type":"Organization","site_admin":false},"repo":{"id":95254369,"name":"invenio-files-processor","full_name":"inveniosoftware/invenio-files-processor","owner":{"login":"inveniosoftware","id":1157480,"avatar_url":"https://avatars1.githubusercontent.com/u/1157480?v=4","gravatar_id":"","url":"https://api.github.com/users/inveniosoftware","html_url":"https://github.com/inveniosoftware","followers_url":"https://api.github.com/users/inveniosoftware/followers","following_url":"https://api.github.com/users/inveniosoftware/following{/other_user}","gists_url":"https://api.github.com/users/inveniosoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/inveniosoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inveniosoftware/subscriptions","organizations_url":"https://api.github.com/users/inveniosoftware/orgs","repos_url":"https://api.github.com/users/inveniosoftware/repos","events_url":"https://api.github.com/users/inveniosoftware/events{/privacy}","received_events_url":"https://api.github.com/users/inveniosoftware/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/inveniosoftware/invenio-files-processor","description":null,"fork":false,"url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor","forks_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/forks","keys_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/teams","hooks_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/hooks","issue_events_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/issues/events{/number}","events_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/events","assignees_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/assignees{/user}","branches_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/branches{/branch}","tags_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/tags","blobs_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/git/refs{/sha}","trees_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/statuses/{sha}","languages_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/languages","stargazers_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/stargazers","contributors_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/contributors","subscribers_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/subscribers","subscription_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/subscription","commits_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/commits{/sha}","git_commits_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/git/commits{/sha}","comments_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/comments{/number}","issue_comment_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/issues/comments{/number}","contents_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/contents/{+path}","compare_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/merges","archive_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/downloads","issues_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/issues{/number}","pulls_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/pulls{/number}","milestones_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/milestones{/number}","notifications_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/labels{/name}","releases_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/releases{/id}","deployments_url":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/deployments","created_at":"2017-06-23T20:32:22Z","updated_at":"2017-07-28T08:28:13Z","pushed_at":"2017-07-29T08:41:41Z","git_url":"git://github.com/inveniosoftware/invenio-files-processor.git","ssh_url":"git@github.com:inveniosoftware/invenio-files-processor.git","clone_url":"https://github.com/inveniosoftware/invenio-files-processor.git","svn_url":"https://github.com/inveniosoftware/invenio-files-processor","homepage":null,"size":38,"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":2,"mirror_url":null,"open_issues_count":3,"forks":2,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/pulls/3"},"html":{"href":"https://github.com/inveniosoftware/invenio-files-processor/pull/3"},"issue":{"href":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/issues/3"},"comments":{"href":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/inveniosoftware/invenio-files-processor/statuses/ca437f5687180b8b8899addd73c34461e1cb6738"}}}}
{"actor":{"display_login":"xiaom"}}