From ea96a2ed719449fa7c182f51757a928090626db6 Mon Sep 17 00:00:00 2001 From: femalves Date: Thu, 22 Aug 2024 12:48:04 -0400 Subject: [PATCH] changing putcode back to ints --- orcid_service/tests/test_service.py | 8 ++------ orcid_service/views.py | 10 +++++----- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/orcid_service/tests/test_service.py b/orcid_service/tests/test_service.py index d977f37..0f5baf4 100644 --- a/orcid_service/tests/test_service.py +++ b/orcid_service/tests/test_service.py @@ -11,7 +11,6 @@ class TestServices(TestCaseDatabase): - @httpretty.activate def test_exchangeOAuthCode(self): client_id = self.app.config.get('ORCID_CLIENT_ID') @@ -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', diff --git a/orcid_service/views.py b/orcid_service/views.py index 25617da..a63bb76 100644 --- a/orcid_service/views.py +++ b/orcid_service/views.py @@ -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: @@ -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, @@ -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: @@ -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: @@ -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: