Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed the putcode to always be string and added a test #47

Merged
merged 2 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion orcid_service/app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import absolute_import
from werkzeug.serving import run_simple
from adsmutils import ADSFlask
from .views import bp
from orcid_service.views import bp
from flask_discoverer import Discoverer
from flask import Response

Expand Down
2 changes: 1 addition & 1 deletion orcid_service/cors.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import absolute_import

from flask_cors import CORS
from .app import create_app
from orcid_service.app import create_app

if __name__ == '__main__':
app = create_app()
Expand Down
3 changes: 3 additions & 0 deletions orcid_service/tests/test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ def request_empty_callback(request, uri, headers):
self.assertStatus(s, 200)
self.assertEqual(len(s.json), 9)
self.assertEqual(len(s.json['2015ApJ...810..149L']['source']),2)
for _, value in s.json.items():
putcode = value.get('putcode', None)
self.assertTrue(type(putcode), str)

httpretty.register_uri(
httpretty.GET, self.app.config['ORCID_API_ENDPOINT'] + '/0000-0001-8868-9743/record',
Expand Down
6 changes: 3 additions & 3 deletions orcid_service/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ def find_record(work):
id0 = d['external-id-value']
status = 'pending'
title = doc['title']['title']['value']
putcode = doc['put-code']
putcode = str(doc['put-code'])
try:
pubyear = doc['publication-date']['year']['value']
except TypeError:
Expand All @@ -628,7 +628,7 @@ def find_record(work):
# save off the metadata for a DOI record in case we can't find a bibcode later
status = 'pending'
title = doc['title']['title']['value']
putcode = doc['put-code']
putcode = str(doc['put-code'])
try:
pubyear = doc['publication-date']['year']['value']
except TypeError:
Expand All @@ -655,7 +655,7 @@ def find_record(work):
id0 = str(work['work-summary'][0]['put-code'])
status = 'not in ADS'
title = work['work-summary'][0]['title']['title']['value']
putcode = work['work-summary'][0]['put-code']
putcode = str(work['work-summary'][0]['put-code'])
try:
pubyear = work['work-summary'][0]['publication-date']['year']['value']
except TypeError:
Expand Down
Loading