Skip to content

Commit

Permalink
changing putcode back to ints
Browse files Browse the repository at this point in the history
  • Loading branch information
femalves committed Aug 22, 2024
1 parent 7b7d917 commit ea96a2e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
8 changes: 2 additions & 6 deletions orcid_service/tests/test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

class TestServices(TestCaseDatabase):


@httpretty.activate
def test_exchangeOAuthCode(self):
client_id = self.app.config.get('ORCID_CLIENT_ID')
Expand Down Expand Up @@ -111,11 +110,8 @@ 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)

self.assertEqual(len(s.json['2015ApJ...810..149L']['source']), 2)

httpretty.register_uri(
httpretty.GET, self.app.config['ORCID_API_ENDPOINT'] + '/0000-0001-8868-9743/record',
content_type='application/json',
Expand Down
10 changes: 5 additions & 5 deletions orcid_service/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ def find_record(work):
tmp = work['external-ids']['external-id'][0]['external-id-type']
except IndexError:
# no ID is given, so get the putcode and the metadata from the first record
id0 = str(work['work-summary'][0]['put-code'])
id0 = work['work-summary'][0]['put-code']
status = 'not in ADS'
title = work['work-summary'][0]['title']['title']['value']
try:
Expand All @@ -585,7 +585,7 @@ def find_record(work):
for doc in docs:
sources.append(doc['source']['source-name']['value'])

return id0, {id0: {'identifier': id0,
return id0, {id0: {'identifier': str(id0),
'status': status,
'title': title,
'pubyear': pubyear,
Expand All @@ -609,7 +609,7 @@ def find_record(work):
id0 = d['external-id-value']
status = 'pending'
title = doc['title']['title']['value']
putcode = str(doc['put-code'])
putcode = 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 = str(doc['put-code'])
putcode = 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 = str(work['work-summary'][0]['put-code'])
putcode = work['work-summary'][0]['put-code']
try:
pubyear = work['work-summary'][0]['publication-date']['year']['value']
except TypeError:
Expand Down

0 comments on commit ea96a2e

Please sign in to comment.