diff options
| author | Bryan Newbold <bnewbold@robocracy.org> | 2018-07-18 19:05:52 -0700 | 
|---|---|---|
| committer | Bryan Newbold <bnewbold@robocracy.org> | 2018-07-18 19:05:54 -0700 | 
| commit | 7df8189fe0c234bbf391653e73cd7c122c3a3d4f (patch) | |
| tree | 19f2f4d2152b4e262902d6c6a0cadf75515b729d | |
| parent | 43dfad6579118a0a4f05b0eee4004bccd2886c75 (diff) | |
| download | fatcat-7df8189fe0c234bbf391653e73cd7c122c3a3d4f.tar.gz fatcat-7df8189fe0c234bbf391653e73cd7c122c3a3d4f.zip | |
fix orcid name parsing
And add test
| -rw-r--r-- | python/fatcat/orcid_importer.py | 2 | ||||
| -rw-r--r-- | python/tests/orcid.py | 10 | 
2 files changed, 11 insertions, 1 deletions
| diff --git a/python/fatcat/orcid_importer.py b/python/fatcat/orcid_importer.py index a480be16..69b184d5 100644 --- a/python/fatcat/orcid_importer.py +++ b/python/fatcat/orcid_importer.py @@ -32,7 +32,7 @@ class FatcatOrcidImporter(FatcatImporter):          if name is None:              return None          extra = None -        given = value_or_none(name.get('given-name')) +        given = value_or_none(name.get('given-names'))          sur = value_or_none(name.get('family-name'))          display = value_or_none(name.get('credit-name'))          if display is None: diff --git a/python/tests/orcid.py b/python/tests/orcid.py index d0e99cfc..00748972 100644 --- a/python/tests/orcid.py +++ b/python/tests/orcid.py @@ -1,4 +1,5 @@ +import json  import pytest  from fatcat.orcid_importer import FatcatOrcidImporter @@ -15,3 +16,12 @@ def test_orcid_importer_batch(orcid_importer):  def test_orcid_importer(orcid_importer):      with open('tests/files/0000-0001-8254-7103.json', 'r') as f:          orcid_importer.process_source(f) + +def test_orcid_dict_parse(orcid_importer): +    with open('tests/files/0000-0001-8254-7103.json', 'r') as f: +        raw = json.loads(f.readline()) +        c = orcid_importer.parse_orcid_dict(raw) +        assert c.given_name == "Man-Hui" +        assert c.surname == "Li" +        assert c.display_name == "Man-Hui Li" +        assert c.orcid == "0000-0001-8254-7103" | 
