From e4adb3b3c05529d057180e9dc189913c429c4686 Mon Sep 17 00:00:00 2001 From: golnazads <28757512+golnazads@users.noreply.github.com> Date: Fri, 17 Jan 2020 07:42:53 -0500 Subject: [PATCH 1/2] revert back to aff --- .../tests/unittests/stubdata/solrdata.py | 430 ++++++++---------- .../unittests/test_author_affiliation.py | 117 +---- authoraffsrv/utils.py | 2 +- authoraffsrv/views.py | 50 +- 4 files changed, 226 insertions(+), 373 deletions(-) diff --git a/authoraffsrv/tests/unittests/stubdata/solrdata.py b/authoraffsrv/tests/unittests/stubdata/solrdata.py index b3705e3..c882704 100644 --- a/authoraffsrv/tests/unittests/stubdata/solrdata.py +++ b/authoraffsrv/tests/unittests/stubdata/solrdata.py @@ -10,7 +10,7 @@ "q":"*:*", "start":"0", "wt":"json", - "fl":"author,aff_raw,pubdate" + "fl":"author,aff,pubdate" } }, "response":{ @@ -18,7 +18,7 @@ "numFound":190, "docs":[ { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -51,7 +51,7 @@ ] }, { - "aff_raw":[ + "aff":[ "NASA Goddard Space Flight Ctr. (United States)", "Smithsonian Astrophysical Observatory (United States)", "Smithsonian Astrophysical Observatory (United States)", @@ -92,7 +92,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -115,7 +115,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -148,7 +148,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Center for Astrophysics, Cambridge, USA" ], "pubdate":"2015-12-00", @@ -157,7 +157,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -184,7 +184,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Smithsonian Astrophysical Observatory", "Smithsonian Astrophysical Observatory", "Smithsonian Astrophysical Observatory" @@ -197,7 +197,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Smithsonian Astrophysical Observatory" ], "pubdate":"2015-08-00", @@ -206,7 +206,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Smithsonian Astrophysical Observatory", "Smithsonian Astrophysical Observatory", "Smithsonian Astrophysical Observatory", @@ -233,7 +233,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Center for Astrophysics, Cambridge, USA", "Harvard-Smithsonian Center for Astrophysics, Cambridge, USA", "Harvard-Smithsonian Center for Astrophysics, Cambridge, USA", @@ -258,7 +258,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -283,7 +283,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -310,7 +310,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Center for Astrophysics, USA", "Harvard-Smithsonian Center for Astrophysics, USA", "SAO/NASA Astrophysics Data System, USA", @@ -331,7 +331,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -356,7 +356,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-" @@ -369,7 +369,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard Smithsonian, CfA", "Harvard Smithsonian, CfA", "Harvard Smithsonian, CfA", @@ -394,7 +394,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Smithsonian Astrophysical Observatory", "Smithsonian Astrophysical Observatory", "Smithsonian Astrophysical Observatory", @@ -413,7 +413,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -432,7 +432,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard Smithsonian, CfA", "Harvard Smithsonian, CfA", "Harvard Smithsonian, CfA", @@ -455,7 +455,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Astrophysics Source Code Library", "Smithsonian Astrophysical Observatory", "Infrared Processing and Analysis Center, California Institute of Technology", @@ -486,7 +486,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -509,7 +509,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Center for Astrophysics, 60 Garden Street, Cambridge, MA 02138, USA", "Department of Physics & Astronomy, The Johns Hopkins University, 3400 North Charles Street, Baltimore, MD 21218, USA", "Centre for Astrophysics & Supercomputing, Swinburne University of Technology, 1 Alfred Street, Hawthorn, 3122, Australia", @@ -532,7 +532,7 @@ ] }, { - "aff_raw":[ + "aff":[ "University of Glasgow, United Kingdom", "Harvard-Smithsonian Center for Astrophysics", "Harvard-Smithsonian Center for Astrophysics", @@ -553,7 +553,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard Smithsonian, CfA", "Harvard Smithsonian, CfA", "Harvard Smithsonian, CfA", @@ -576,7 +576,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Smithsonian Astrophysical Observatory, Cambridge, MA, USA;", "Smithsonian Astrophysical Observatory, Cambridge, MA, USA;" ], @@ -587,7 +587,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Smithsonian Astrophysical Observatory (United States)", "Smithsonian Astrophysical Observatory (United States)", "Smithsonian Astrophysical Observatory (United States)", @@ -602,7 +602,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-" ], @@ -613,7 +613,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -628,7 +628,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Center for Astrophysics, USA", "Harvard-Smithsonian Center for Astrophysics, USA", "Harvard-Smithsonian Center for Astrophysics, USA" @@ -641,7 +641,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -666,7 +666,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -681,7 +681,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Springer", "Springer", "Smithsonian Astrophysical Observatory" @@ -694,7 +694,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard Smithsonian Center for Astrophysics", "Harvard Smithsonian Center for Astrophysics", "Harvard Smithsonian Center for Astrophysics", @@ -719,7 +719,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Center for Astrophysics" ], "pubdate":"2011-00-00", @@ -728,7 +728,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Center for Astrophysics" ], "pubdate":"2011-00-00", @@ -737,7 +737,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Center for Astrophysics", "Harvard-Smithsonian Center for Astrophysics", "Harvard-Smithsonian Center for Astrophysics", @@ -762,7 +762,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Smithsonian Astrophysical Observatory", "Smithsonian Astrophysical Observatory", "Smithsonian Astrophysical Observatory", @@ -787,7 +787,7 @@ ] }, { - "aff_raw":[ + "aff":[ "STScI", "LCOGT", "ADS", @@ -802,7 +802,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -819,7 +819,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-" ], "pubdate":"2010-10-00", @@ -828,7 +828,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Center for Astrophysics, 60 Garden Street, Cambridge, MA 02138, USA", "Harvard-Smithsonian Center for Astrophysics, 60 Garden Street, Cambridge, MA 02138, USA", "Harvard-Smithsonian Center for Astrophysics, 60 Garden Street, Cambridge, MA 02138, USA", @@ -851,7 +851,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Smithsonian Astrophysical Observatory, Cambridge, MA, USA", "Smithsonian Astrophysical Observatory, Cambridge, MA, USA", "Smithsonian Astrophysical Observatory, Cambridge, MA, USA", @@ -874,7 +874,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -899,7 +899,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -926,7 +926,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -947,7 +947,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -968,7 +968,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -1157,7 +1157,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Smithsonian Astrophysical Observatory", "University of Washington, Department of Biology", "Smithsonian Astrophysical Observatory", @@ -1182,7 +1182,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard Smithsonian Center for Astrophysics", "Harvard Smithsonian Center for Astrophysics", "Harvard Smithsonian Center for Astrophysics", @@ -1203,7 +1203,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-" @@ -1216,7 +1216,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -1243,7 +1243,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-" @@ -1256,7 +1256,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -1289,7 +1289,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -1316,7 +1316,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian, CfA", "Harvard-Smithsonian, CfA", "Harvard-Smithsonian, CfA", @@ -1341,7 +1341,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Smithsonian Astrophysical Observatory", "Smithsonian Astrophysical Observatory", "Smithsonian Astrophysical Observatory", @@ -1360,7 +1360,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard Smithsonian Center for Astrophysics", "Harvard Smithsonian Center for Astrophysics", "Harvard Smithsonian Center for Astrophysics", @@ -1381,7 +1381,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138, USA", "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138, USA", "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138, USA", @@ -1400,7 +1400,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Smithsonian Astrophysical Observatory", "Smithsonian Astrophysical Observatory", "Smithsonian Astrophysical Observatory", @@ -1421,7 +1421,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-" @@ -1434,7 +1434,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -1459,7 +1459,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -1480,7 +1480,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -1501,7 +1501,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -1524,7 +1524,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -1547,7 +1547,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -1568,7 +1568,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -1591,7 +1591,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard Smithsonian Center for Astrophysics, 60 Garden Street, MS-67, Cambridge, MA02138, USA", "Harvard Smithsonian Center for Astrophysics, 60 Garden Street, MS-67, Cambridge, MA02138, USA", "Harvard Smithsonian Center for Astrophysics, 60 Garden Street, MS-67, Cambridge, MA02138, USA", @@ -1612,7 +1612,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -1635,7 +1635,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -1658,7 +1658,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Smithsonian Astrophysical Observatory", "Smithsonian Astrophysical Observatory", "Smithsonian Astrophysical Observatory", @@ -1685,7 +1685,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian, CfA", "Harvard-Smithsonian, CfA", "Harvard-Smithsonian, CfA", @@ -1708,7 +1708,7 @@ ] }, { - "aff_raw":[ + "aff":[ "SAO", "SAO", "SAO", @@ -1729,7 +1729,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Smithsonian Astrophysical Obs.", "Smithsonian Astrophysical Obs.", "Smithsonian Astrophysical Obs.", @@ -1752,7 +1752,7 @@ ] }, { - "aff_raw":[ + "aff":[ "SAO", "SAO", "SAO", @@ -1773,7 +1773,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Smithsonian Astrophysical Observatory, 60 Garden Street, Cambridge, MA 02138", "Smithsonian Astrophysical Observatory, 60 Garden Street, Cambridge, MA 02138", "Smithsonian Astrophysical Observatory, 60 Garden Street, Cambridge, MA 02138", @@ -1794,7 +1794,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -1813,7 +1813,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -1834,7 +1834,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -1857,7 +1857,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Center for Astrophysics, 60 Garden Street MS-31, Cambridge, MA 02138, USA", "Harvard-Smithsonian Center for Astrophysics, 60 Garden Street MS-31, Cambridge, MA 02138, USA", "Harvard-Smithsonian Center for Astrophysics, 60 Garden Street MS-31, Cambridge, MA 02138, USA", @@ -1878,7 +1878,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Center for Astrophysics", "Harvard-Smithsonian Center for Astrophysics", "Harvard-Smithsonian Center for Astrophysics", @@ -1901,7 +1901,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Center for Astrophysics", "Harvard-Smithsonian Center for Astrophysics", "Harvard-Smithsonian Center for Astrophysics", @@ -1922,7 +1922,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian CfA", "Harvard-Smithsonian CfA", "Harvard-Smithsonian CfA", @@ -1943,7 +1943,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -1964,7 +1964,7 @@ ] }, { - "aff_raw":[ + "aff":[ "EUROPEAN SOUTHERN OBSERVATORY, Garching bei M\u00fcnchen, Germany", "EUROPEAN SOUTHERN OBSERVATORY, Garching bei M\u00fcnchen, Germany", "EUROPEAN SOUTHERN OBSERVATORY, Garching bei M\u00fcnchen, Germany", @@ -1981,7 +1981,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -2002,7 +2002,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138 USA", "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138 USA", "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138 USA", @@ -2025,7 +2025,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138 USA", "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138 USA", "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138 USA", @@ -2044,7 +2044,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -2063,7 +2063,7 @@ ] }, { - "aff_raw":[ + "aff":[ "CfA", "CfA", "CfA", @@ -2082,7 +2082,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Center for Astrophysics, 60 Garden Street MS-31, Cambridge, MA 02138, USA", "Harvard-Smithsonian Center for Astrophysics, 60 Garden Street MS-31, Cambridge, MA 02138, USA", "Harvard-Smithsonian Center for Astrophysics, 60 Garden Street MS-31, Cambridge, MA 02138, USA", @@ -2101,7 +2101,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-" ], @@ -2112,7 +2112,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -2135,7 +2135,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -2156,7 +2156,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Univ Heidelbergm Bergheimer Str 58, Heidelberg, Germany", "Harvard-Smithsonian Center for Astrophysics, 60 Garden St., Cambridge, MA, USA", "-", @@ -2175,7 +2175,7 @@ ] }, { - "aff_raw":[ + "aff":[ "NASA HEASARC, Code 660.1, Greenbelt, MD 20771", "ADS SAO, Cambridge, MA 02138", "IRSA IPAC, Pasadena, CA 91125", @@ -2202,7 +2202,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138, USA", "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138, USA", "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138, USA", @@ -2219,7 +2219,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Center for Astrophysics, MS-31, 60 Garden Street, Cambridge, MA 02138, USA", "Harvard-Smithsonian Center for Astrophysics, MS-31, 60 Garden Street, Cambridge, MA 02138, USA", "Harvard-Smithsonian Center for Astrophysics, MS-31, 60 Garden Street, Cambridge, MA 02138, USA", @@ -2238,7 +2238,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian CfA.", "Harvard-Smithsonian CfA.", "Harvard-Smithsonian CfA.", @@ -2257,7 +2257,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian CfA", "Harvard-Smithsonian CfA", "Harvard-Smithsonian CfA", @@ -2280,7 +2280,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian CfA.", "Harvard-Smithsonian CfA.", "Harvard-Smithsonian CfA.", @@ -2299,7 +2299,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -2316,7 +2316,7 @@ ] }, { - "aff_raw":[ + "aff":[ "CfA, Cambridge, MA, USA", "CfA, Cambridge, MA, USA", "CfA, Cambridge, MA, USA", @@ -2335,7 +2335,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -2354,7 +2354,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -2373,7 +2373,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Center for Astrophysics", "Harvard-Smithsonian Center for Astrophysics", "Harvard-Smithsonian Center for Astrophysics", @@ -2390,7 +2390,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA", "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA", "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA", @@ -2409,7 +2409,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138, USA", "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138, USA", "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138, USA", @@ -2426,7 +2426,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138 USA", "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138 USA", "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138 USA", @@ -2443,7 +2443,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138 USA", "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138 USA", "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138 USA", @@ -2464,7 +2464,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -2481,7 +2481,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Center for Astrophysics", "Harvard-Smithsonian Center for Astrophysics", "Harvard-Smithsonian Center for Astrophysics", @@ -2500,7 +2500,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian CfA", "Harvard-Smithsonian CfA", "Harvard-Smithsonian CfA", @@ -2517,7 +2517,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian CfA", "Harvard-Smithsonian CfA", "Harvard-Smithsonian CfA", @@ -2534,7 +2534,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian CfA", "Harvard-Smithsonian CfA", "Harvard-Smithsonian CfA", @@ -2553,7 +2553,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Ctr. for Astrophysics, USA", "Harvard-Smithsonian Ctr. for Astrophysics, USA", "Harvard-Smithsonian Ctr. for Astrophysics, USA", @@ -2570,7 +2570,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Ctr. for Astrophysics, USA", "Harvard-Smithsonian Ctr. for Astrophysics, USA", "Harvard-Smithsonian Ctr. for Astrophysics, USA", @@ -2587,7 +2587,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138", "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138", "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138", @@ -2604,7 +2604,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Center for Astrophysics", "Harvard-Smithsonian Center for Astrophysics", "Harvard-Smithsonian Center for Astrophysics", @@ -2621,7 +2621,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian CfA", "Harvard-Smithsonian CfA", "Harvard-Smithsonian CfA", @@ -2640,7 +2640,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian CfA, MS-83 60 Garden Street, Cambridge, MA 02138, USA", "Harvard-Smithsonian CfA, MS-83 60 Garden Street, Cambridge, MA 02138, USA", "Harvard-Smithsonian CfA, MS-83 60 Garden Street, Cambridge, MA 02138, USA", @@ -2659,7 +2659,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA", "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA", "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA", @@ -2678,7 +2678,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -2697,7 +2697,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138", "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138", "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138", @@ -2714,7 +2714,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138, USA", "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138, USA", "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138, USA", @@ -2729,7 +2729,7 @@ ] }, { - "aff_raw":[ + "aff":[ "CfA", "CfA", "CfA", @@ -2748,7 +2748,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian CfA", "Harvard-Smithsonian CfA", "Harvard-Smithsonian CfA", @@ -2767,7 +2767,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian CfA", "Harvard-Smithsonian CfA", "Harvard-Smithsonian CfA", @@ -2786,7 +2786,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Center for Astrophysics", "Harvard-Smithsonian Center for Astrophysics", "Harvard-Smithsonian Center for Astrophysics", @@ -2805,7 +2805,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian CfA", "Harvard-Smithsonian CfA", "Harvard-Smithsonian CfA", @@ -2822,7 +2822,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -2839,7 +2839,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -2858,7 +2858,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Center for Astrophysics", "Harvard-Smithsonian Center for Astrophysics", "Harvard-Smithsonian Center for Astrophysics", @@ -2877,7 +2877,7 @@ ] }, { - "aff_raw":[ + "aff":[ "CfA", "CfA", "CfA", @@ -2896,7 +2896,7 @@ ] }, { - "aff_raw":[ + "aff":[ "SAO", "SAO", "SAO", @@ -2915,7 +2915,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138, USA", "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138, USA", "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138, USA", @@ -2932,7 +2932,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138, USA", "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138, USA", "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138, USA", @@ -2949,7 +2949,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138, USA", "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138, USA", "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138, USA", @@ -2966,7 +2966,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138, USA", "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138, USA", "Harvard-Smithsonian Center for Astrophysics, Cambridge, MA 02138, USA", @@ -2985,7 +2985,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -3004,7 +3004,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian CfA", "Harvard-Smithsonian CfA", "Harvard-Smithsonian CfA", @@ -3023,7 +3023,7 @@ ] }, { - "aff_raw":[ + "aff":[ "CfA", "CfA", "CfA", @@ -3042,7 +3042,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Center for Astrophysics Cambridge, MA 02138, USA", "Harvard-Smithsonian Center for Astrophysics Cambridge, MA 02138, USA", "Harvard-Smithsonian Center for Astrophysics Cambridge, MA 02138, USA", @@ -3061,7 +3061,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Alias|Wavefront Inc., Canada", "ISG Technologies, Inc., Canada", "ISG Technologies, Inc., Canada", @@ -3078,7 +3078,7 @@ ] }, { - "aff_raw":[ + "aff":[ "SAO", "SAO", "SAO", @@ -3097,7 +3097,7 @@ ] }, { - "aff_raw":[ + "aff":[ "SAO", "SAO", "SAO", @@ -3116,7 +3116,7 @@ ] }, { - "aff_raw":[ + "aff":[ "SAO", "SAO", "SAO", @@ -3133,7 +3133,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -3150,7 +3150,7 @@ ] }, { - "aff_raw":[ + "aff":[ "SAO", "SAO", "SAO", @@ -3167,7 +3167,7 @@ ] }, { - "aff_raw":[ + "aff":[ "SAO", "SAO", "SAO", @@ -3184,7 +3184,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Smithsonian Astrophysical Observatory", "Smithsonian Astrophysical Observatory", "Smithsonian Astrophysical Observatory", @@ -3199,7 +3199,7 @@ ] }, { - "aff_raw":[ + "aff":[ "SAO", "SAO", "SAO", @@ -3216,7 +3216,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -3233,7 +3233,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -3250,7 +3250,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Smithsonian Astrophysical Observatory, 60 Garden Street, Cambridge, MA 02138, USA", "Smithsonian Astrophysical Observatory, 60 Garden Street, Cambridge, MA 02138, USA", "Smithsonian Astrophysical Observatory, 60 Garden Street, Cambridge, MA 02138, USA", @@ -3265,7 +3265,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -3282,7 +3282,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -3299,7 +3299,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -3316,7 +3316,7 @@ ] }, { - "aff_raw":[ + "aff":[ "SAO", "SAO", "SAO", @@ -3331,7 +3331,7 @@ ] }, { - "aff_raw":[ + "aff":[ "SAO", "SAO", "SAO", @@ -3348,7 +3348,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Smithsonian Astrophysical Observatory, Cambridge, MA, USA", "Smithsonian Astrophysical Observatory, Cambridge, MA, USA", "Smithsonian Astrophysical Observatory, Cambridge, MA, USA", @@ -3363,7 +3363,7 @@ ] }, { - "aff_raw":[ + "aff":[ "SAO", "SAO", "SAO", @@ -3386,7 +3386,7 @@ ] }, { - "aff_raw":[ + "aff":[ "SAO", "SAO", "SAO", @@ -3409,7 +3409,7 @@ ] }, { - "aff_raw":[ + "aff":[ "SAO", "SAO", "SAO", @@ -3426,7 +3426,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -3443,7 +3443,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Smithsonian Astrophysical Observatory, 60 Garden Street, Cambridge, MA 02138", "-", "-", @@ -3460,7 +3460,7 @@ ] }, { - "aff_raw":[ + "aff":[ "SAO", "SAO", "SAO", @@ -3485,7 +3485,7 @@ ] }, { - "aff_raw":[ + "aff":[ "SAO", "SAO", "SAO", @@ -3502,7 +3502,7 @@ ] }, { - "aff_raw":[ + "aff":[ "SAO", "SAO", "SAO", @@ -3519,7 +3519,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Smithsonian Astrophysical Observatory, 60 Garden Street, Cambridge, MA 02138", "-", "-", @@ -3536,7 +3536,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Smithsonian Astrophysical Observatory, 60 Garden Street, Cambridge, MA 02138, USA", "-", "-", @@ -3553,7 +3553,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Smithsonian Astrophysical Observatory, Cambridge, MA 02138, USA", "Smithsonian Astrophysical Observatory, Cambridge, MA 02138, USA", "Smithsonian Astrophysical Observatory, Cambridge, MA 02138, USA", @@ -3570,7 +3570,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -3587,7 +3587,7 @@ ] }, { - "aff_raw":[ + "aff":[ "SAO", "SAO", "SAO", @@ -3604,7 +3604,7 @@ ] }, { - "aff_raw":[ + "aff":[ "SAO", "SAO", "SAO", @@ -3621,7 +3621,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -3638,7 +3638,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -3667,7 +3667,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Smithsonian Astrophysical Observatory, 60 Garden St., Cambridge, MA 02138", "-", "-", @@ -3684,7 +3684,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Smithsonian Astrophysical Observatory, 60 Garden St., Cambridge, MA 02138", "-", "-", @@ -3701,7 +3701,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Smithsonian Astrophysical Observatory, 60 Garden Street, Cambridge, MA 02138", "-", "-", @@ -3718,7 +3718,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Smithsonian Astrophysical Observatory, Cambridge, MA, U.S.A.", "Space Telescope - European Coordinating Facility, European Southern Observatory, Garching near Munich, Germany. (Affiliated to Astrophysics Division, Space Science Department, European Space Agency.)", "Space Telescope - European Coordinating Facility, European Southern Observatory, Garching near Munich, Germany" @@ -3731,7 +3731,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Smithsonian Astrophysical Observatory, Cambridge, MA 02138, USA", "Smithsonian Astrophysical Observatory, Cambridge, MA 02138, USA", "Smithsonian Astrophysical Observatory, Cambridge, MA 02138, USA", @@ -3748,7 +3748,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Smithsonian Astrophysical Observatory, 60 Garden Street, Cambridge, MA 02138, U.S.A.", "Smithsonian Astrophysical Observatory, 60 Garden Street, Cambridge, MA 02138, U.S.A.", "Smithsonian Astrophysical Observatory, 60 Garden Street, Cambridge, MA 02138, U.S.A.", @@ -3765,7 +3765,7 @@ ] }, { - "aff_raw":[ + "aff":[ "SAO", "SAO", "SAO", @@ -3782,7 +3782,7 @@ ] }, { - "aff_raw":[ + "aff":[ "SAO", "SAO", "SAO", @@ -3799,7 +3799,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Harvard-Smithsonian Ctr. for Astrophysics" ], "pubdate":"1992-05-00", @@ -3808,7 +3808,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -3823,7 +3823,7 @@ ] }, { - "aff_raw":[ + "aff":[ "Dipartimento di Fisica, Universit\u00e1 degli Studi di Milano", "Istituto di Fisica Cosmica e Tecnologie Relative, C.N.R.", "Dipartimento di Fisica, Universit\u00e1 degli Studi di Milano", @@ -3838,7 +3838,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -3853,7 +3853,7 @@ ] }, { - "aff_raw":[ + "aff":[ "-", "-", "-", @@ -3873,50 +3873,4 @@ } } -data2 = \ -{ - "responseHeader": { - "status": 1, - "QTime": 1, - "params": { - "sort": "date desc", - "fq": "{!bitset}", - "rows": "19", - "q": "*:*", - "start": "0", - "wt": "json", - "fl": "author,aff_raw,pubdate" - } - }, - "response": { - "start": 0, - "numFound": 2, - "docs": [ - { - "pubdate": "2017-09-00", - "author": [ - "Teplitz, H.", - "Groom, S.", - "Akeson, R.", - "Berriman, G. B.", - "Helou, G.", - "Imel, D.", - "Mazzarella, J. M.", - "Accomazzi, A.", - "McGlynn, T.", - "Smale, A.", - "White, R." - ] - }, - { - "aff_raw": [ - "NASA Goddard Space Flight Ctr. (United States)", - ], - "pubdate": "2016-07-00", - "author": [ - "McGlynn, Thomas", - ] - }, - ] - } -} + diff --git a/authoraffsrv/tests/unittests/test_author_affiliation.py b/authoraffsrv/tests/unittests/test_author_affiliation.py index 57cc4b2..950a1c9 100644 --- a/authoraffsrv/tests/unittests/test_author_affiliation.py +++ b/authoraffsrv/tests/unittests/test_author_affiliation.py @@ -14,27 +14,16 @@ class TestAuthorAffiliation(TestCase): def create_app(self): - """ - start the wsgi application - - """ + #Start the wsgi application return app.create_app() def test_formatted_data(self): - """ - general test - - """ # format the stubdata using the code formatted_data = Formatter(solrdata.data).get(0, 2017) # now compare it with an already formatted data that we know is correct assert(formatted_data == formatted.data) def test_solr_status_error(self): - """ - when solr returns error - - """ solr_data = { "responseHeader":{ "status":400, @@ -44,120 +33,72 @@ def test_solr_status_error(self): assert(formatted_data == None) def test_export_csv_format(self): - """ - csv format test - - """ # format the stubdata using the code exported_data = Export(export.form_data).format(EXPORT_FORMATS[0]) # now compare it with an already formatted data that we know is correct assert(exported_data == export.csv) def test_export_csv_div_format(self): - """ - csv with div format test - - """ # format the stubdata using the code exported_data = Export(export.form_data).format(EXPORT_FORMATS[1]) # now compare it with an already formatted data that we know is correct assert(exported_data == export.csv_div) def test_export_excel_format(self): - """ - excel format test - - """ # format the stubdata using the code exported_data = Export(export.form_data).format(EXPORT_FORMATS[2]) # now compare it with an already formatted data that we know is correct assert(len(exported_data) == 5632) def test_export_excel_div_format(self): - """ - excel with div format test - - """ # format the stubdata using the code exported_data = Export(export.form_data).format(EXPORT_FORMATS[3]) # now compare it with an already formatted data that we know is correct assert(len(exported_data) == 5632) def test_export_text_format(self): - """ - text format test - - """ # format the stubdata using the code exported_data = Export(export.form_data).format(EXPORT_FORMATS[4]) # now compare it with an already formatted data that we know is correct assert(exported_data == export.text) - def test_export_browser_format(self): - """ - browser format test - - """ + def test_export_text_format2(self): # format the stubdata using the code exported_data = Export(export.form_data).format(EXPORT_FORMATS[5]) # now compare it with an already formatted data that we know is correct assert(exported_data == export.text) def test_export_csv_get(self): - """ - test function `get` for csv format - - """ # format the stubdata using the code exported_data = Export(export.form_data).get(EXPORT_FORMATS[0]) # now check the status_code to be 200 assert (exported_data.status_code == 200) def test_export_csv_div_get(self): - """ - test function `get` for csv with div format - - """ # format the stubdata using the code exported_data = Export(export.form_data).get(EXPORT_FORMATS[1]) # now compare it with an already formatted data that we know is correct assert (exported_data.status_code == 200) def test_export_excel_get(self): - """ - test function `get` for excel format - - """ # format the stubdata using the code exported_data = Export(export.form_data).get(EXPORT_FORMATS[2]) # now compare it with an already formatted data that we know is correct assert (exported_data.status_code == 200) def test_export_excel_div_get(self): - """ - test function `get` for excel with div format - - """ # format the stubdata using the code exported_data = Export(export.form_data).get(EXPORT_FORMATS[3]) # now compare it with an already formatted data that we know is correct assert (exported_data.status_code == 200) def test_export_text_get(self): - """ - test function `get` for text format - - """ # format the stubdata using the code exported_data = Export(export.form_data).get(EXPORT_FORMATS[4]) # now compare it with an already formatted data that we know is correct assert (exported_data.status_code == 200) - def test_export_browser_get(self): - """ - test function `get` for browser format - - """ + def test_export_text_get2(self): # format the stubdata using the code exported_data = Export(export.form_data).get(EXPORT_FORMATS[5]) # now compare it with an already formatted data that we know is correct @@ -165,8 +106,7 @@ def test_export_browser_get(self): def test_search_no_payload(self): """ - ensure that if no payload is passed in, returns 400 - + Ensure that if no payload is passed in, returns 400 """ r = self.client.post('/search') status = r.status_code @@ -176,8 +116,7 @@ def test_search_no_payload(self): def test_export_no_payload(self): """ - ensure that if no payload is passed in, returns 400 - + Ensure that if no payload is passed in, returns 400 """ r = self.client.post('/export') status = r.status_code @@ -187,8 +126,7 @@ def test_export_no_payload(self): def test_search_no_payload_param(self): """ - ensure that if payload without all the needed params is passed in, returns 400 - + Ensure that if payload without all the needed params is passed in, returns 400 """ r = self.client.post('/search', data=dict({'missingParamsPayload': ''})) status = r.status_code @@ -198,8 +136,7 @@ def test_search_no_payload_param(self): def test_search_no_bibcode_payload(self): """ - ensure that if payload without all the needed params is passed in, returns 400 - + Ensure that if payload without all the needed params is passed in, returns 400 """ r = self.client.post('/search', data=dict({'bibcode': ''})) status = r.status_code @@ -209,8 +146,7 @@ def test_search_no_bibcode_payload(self): def test_export_no_payload_param(self): """ - ensure that if payload without all the needed params is passed in, returns 400 - + Ensure that if payload without all the needed params is passed in, returns 400 """ r = self.client.post('/export', data=dict({'missingParamsPayload': ''})) status = r.status_code @@ -220,8 +156,7 @@ def test_export_no_payload_param(self): def test_payload_param_error_max_author(self): """ - ensure that if payload without all the needed params is passed in, returns 400 - + Ensure that if payload without all the needed params is passed in, returns 400 """ payload = {'bibcode': ["1994AAS...185.4102A","1994AAS...185.4104E"], 'maxauthor':-1} r = self.client.post('/search', data=dict(payload)) @@ -233,8 +168,7 @@ def test_payload_param_error_max_author(self): def test_payload_param_error_cutoff_year(self): """ - ensure that if payload without all the needed params is passed in, returns 400 - + Ensure that if payload without all the needed params is passed in, returns 400 """ payload = {'bibcode': ["1994AAS...185.4102A", "1994AAS...185.4104E"], 'numyears':-1} r = self.client.post('/search', data=dict(payload)) @@ -246,8 +180,7 @@ def test_payload_param_error_cutoff_year(self): def test_payload_param_error_empty_selection(self): """ - ensure that if payload without all the needed params is passed in, returns 400 - + Ensure that if payload without all the needed params is passed in, returns 400 """ payload = {'selected': '', 'format':''} r = self.client.post('/export', data=dict(payload)) @@ -259,8 +192,7 @@ def test_payload_param_error_empty_selection(self): def test_payload_param_error_wrong_format(self): """ - ensure that if payload without all the needed params is passed in, returns 400 - + Ensure that if payload without all the needed params is passed in, returns 400 """ payload = {'selected': ["Accomazzi, A.||2017/09"], 'format':''} r = self.client.post('/export', data=dict(payload)) @@ -272,8 +204,7 @@ def test_payload_param_error_wrong_format(self): def test_payload_param_error_unrecognizable_format(self): """ - ensure that if payload without a correct format params is passed in, returns 400 - + Ensure that if payload without a correct format params is passed in, returns 400 """ payload = {'selected': ["Accomazzi, A.||2017/09"], 'format':'something wrong'} r = self.client.post('/export', data=dict(payload)) @@ -284,18 +215,13 @@ def test_payload_param_error_unrecognizable_format(self): def test_is_number(self): """ - ensure is_number behaves properly - + Ensure is_number behaves properly """ self.assertEqual(is_number('1'), True) self.assertEqual(is_number('-1'), True) self.assertEqual(is_number('notnumber'), False) def test_xml_status(self): - """ - ensure status is read properly - - """ solr_data = \ { "responseHeader":{ @@ -308,7 +234,7 @@ def test_xml_status(self): "q":"*:*", "start":"0", "wt":"json", - "fl":"author,aff_raw,pubdate" + "fl":"author,title,year,date,pub,pub_raw,issue,volume,page,page_range,aff,doi,abstract,citation_count,read_count,bibcode,identification,copyright,keyword,doctype,reference,comment,property,esources,data" } } } @@ -316,10 +242,6 @@ def test_xml_status(self): assert(formatted_data.get_status() == 0) def test_xml_no_num_docs(self): - """ - ensure if no `response` found in json num_docs is set to 0 - - """ solr_data = \ { "responseHeader":{ @@ -332,7 +254,7 @@ def test_xml_no_num_docs(self): "q":"*:*", "start":"0", "wt":"json", - "fl":"author,aff_raw,pubdate" + "fl":"author,title,year,date,pub,pub_raw,issue,volume,page,page_range,aff,doi,abstract,citation_count,read_count,bibcode,identification,copyright,keyword,doctype,reference,comment,property,esources,data" } } } @@ -340,12 +262,5 @@ def test_xml_no_num_docs(self): assert(formatted_data.get_num_docs() == 0) - def test_is_complete(self): - """ - ensure all necessary info was returned from solr - - """ - assert(Formatter(solrdata.data2).is_complete() == False) - if __name__ == '__main__': unittest.main() \ No newline at end of file diff --git a/authoraffsrv/utils.py b/authoraffsrv/utils.py index 42d23ac..f8cccc4 100644 --- a/authoraffsrv/utils.py +++ b/authoraffsrv/utils.py @@ -11,7 +11,7 @@ def get_solr_data(bibcodes, cutoff_year, start=0, sort='date desc'): query = 'year:' + str(cutoff_year) + '-3000' - fields = 'author,aff_raw,pubdate' + fields = 'author,aff,pubdate' params = { 'q': query, diff --git a/authoraffsrv/views.py b/authoraffsrv/views.py index 9a1ee74..7fa5b50 100644 --- a/authoraffsrv/views.py +++ b/authoraffsrv/views.py @@ -331,20 +331,6 @@ def get_num_docs(self): return 0 - def is_complete(self): - """ - - :return: - """ - # make sure all the records have all three necessary fields - if (self.get_num_docs() > 0): - for doc in self.from_solr['response'].get('docs', None): - if doc.get('author', None) is not None and \ - doc.get('aff_raw', None) is not None and \ - doc.get('pubdate', None) is not None: - return True - return False - def __get_list(self, num_authors, cutoff_year): """ get unique list of author affiliation @@ -355,19 +341,20 @@ def __get_list(self, num_authors, cutoff_year): author_aff = [] for index in range(self.get_num_docs()): a_doc = self.from_solr['response'].get('docs')[index] - if (int(a_doc['pubdate'][:4]) >= cutoff_year): - author_list = a_doc['author'] - aff_list = a_doc['aff_raw'] - if (num_authors != 0): - author_list = author_list[:num_authors] - aff_list = aff_list[:num_authors] - for author, aff in zip(author_list, aff_list): - idx = [idx for idx, elem in enumerate(author_aff) if elem[0] == author and elem[1] == aff] - if len(idx) > 0: - author_aff[idx[0]][2].update([a_doc['pubdate'][:4]]) - author_aff[idx[0]][3] = a_doc['pubdate'] if a_doc['pubdate'] > author_aff[idx[0]][3] else author_aff[idx[0]][3] - else: - author_aff.append([author, aff, set([a_doc['pubdate'][:4]]), a_doc['pubdate']]) + if 'author' in a_doc and 'aff' in a_doc and 'pubdate' in a_doc: + if (int(a_doc['pubdate'][:4]) >= cutoff_year): + author_list = a_doc['author'] + aff_list = a_doc['aff'] + if (num_authors != 0): + author_list = author_list[:num_authors] + aff_list = aff_list[:num_authors] + for author, aff in zip(author_list, aff_list): + idx = [idx for idx, elem in enumerate(author_aff) if elem[0] == author and elem[1] == aff] + if len(idx) > 0: + author_aff[idx[0]][2].update([a_doc['pubdate'][:4]]) + author_aff[idx[0]][3] = a_doc['pubdate'] if a_doc['pubdate'] > author_aff[idx[0]][3] else author_aff[idx[0]][3] + else: + author_aff.append([author, aff, set([a_doc['pubdate'][:4]]), a_doc['pubdate']]) return sorted(author_aff, key=lambda x: x[0]) return None @@ -524,12 +511,9 @@ def search(): from_solr = get_solr_data(bibcodes=bibcodes, cutoff_year=cutoff_year) if from_solr is not None: - formatter = Formatter(from_solr) - if formatter.is_complete(): - result = formatter.get(num_authors, cutoff_year) - if result is not None: - return return_response(result, 200) - return return_response({'error': 'solr data incomplete'}, 404) + result = Formatter(from_solr).get(num_authors, cutoff_year) + if result is not None: + return return_response(result, 200) return return_response({'error': 'no result from solr'}, 404) From 98c665124d2ffee766ae265935ce3e5c6c3cf3c5 Mon Sep 17 00:00:00 2001 From: golnazads <28757512+golnazads@users.noreply.github.com> Date: Fri, 17 Jan 2020 08:49:40 -0500 Subject: [PATCH 2/2] if no aff in data init to dash --- .../tests/unittests/stubdata/formatted.py | 3 +- .../tests/unittests/stubdata/solrdata.py | 76 +++++++++++++++++++ .../unittests/test_author_affiliation.py | 46 ++++++----- authoraffsrv/views.py | 4 +- 4 files changed, 108 insertions(+), 21 deletions(-) diff --git a/authoraffsrv/tests/unittests/stubdata/formatted.py b/authoraffsrv/tests/unittests/stubdata/formatted.py index 815192a..2103566 100644 --- a/authoraffsrv/tests/unittests/stubdata/formatted.py +++ b/authoraffsrv/tests/unittests/stubdata/formatted.py @@ -1 +1,2 @@ -data = {"data": [{"affiliations": {"lastActiveDate": "2017/09", "name": "-", "years": ["2017"]}, "authorName": "Accomazzi, A."}, {"affiliations": {"lastActiveDate": "2017/09", "name": "-", "years": ["2017"]}, "authorName": "Akeson, R."}, {"affiliations": {"lastActiveDate": "2017/09", "name": "-", "years": ["2017"]}, "authorName": "Berriman, G. B."}, {"affiliations": {"lastActiveDate": "2017/09", "name": "-", "years": ["2017"]}, "authorName": "Desai, V."}, {"affiliations": {"lastActiveDate": "2017/09", "name": "-", "years": ["2017"]}, "authorName": "Groom, S."}, {"affiliations": {"lastActiveDate": "2017/09", "name": "-", "years": ["2017"]}, "authorName": "Helou, G."}, {"affiliations": {"lastActiveDate": "2017/09", "name": "-", "years": ["2017"]}, "authorName": "Imel, D."}, {"affiliations": {"lastActiveDate": "2017/09", "name": "-", "years": ["2017"]}, "authorName": "Mazzarella, J. M."}, {"affiliations": {"lastActiveDate": "2017/09", "name": "-", "years": ["2017"]}, "authorName": "McGlynn, T."}, {"affiliations": {"lastActiveDate": "2017/09", "name": "-", "years": ["2017"]}, "authorName": "Rebull, L. M."}, {"affiliations": {"lastActiveDate": "2017/09", "name": "-", "years": ["2017"]}, "authorName": "Smale, A."}, {"affiliations": {"lastActiveDate": "2017/09", "name": "-", "years": ["2017"]}, "authorName": "Teplitz, H."}, {"affiliations": {"lastActiveDate": "2017/09", "name": "-", "years": ["2017"]}, "authorName": "White, R."}]} \ No newline at end of file +data = {"data": [{"affiliations": {"lastActiveDate": "2017/09", "name": "-", "years": ["2017"]}, "authorName": "Accomazzi, A."}, {"affiliations": {"lastActiveDate": "2017/09", "name": "-", "years": ["2017"]}, "authorName": "Akeson, R."}, {"affiliations": {"lastActiveDate": "2017/09", "name": "-", "years": ["2017"]}, "authorName": "Berriman, G. B."}, {"affiliations": {"lastActiveDate": "2017/09", "name": "-", "years": ["2017"]}, "authorName": "Desai, V."}, {"affiliations": {"lastActiveDate": "2017/09", "name": "-", "years": ["2017"]}, "authorName": "Groom, S."}, {"affiliations": {"lastActiveDate": "2017/09", "name": "-", "years": ["2017"]}, "authorName": "Helou, G."}, {"affiliations": {"lastActiveDate": "2017/09", "name": "-", "years": ["2017"]}, "authorName": "Imel, D."}, {"affiliations": {"lastActiveDate": "2017/09", "name": "-", "years": ["2017"]}, "authorName": "Mazzarella, J. M."}, {"affiliations": {"lastActiveDate": "2017/09", "name": "-", "years": ["2017"]}, "authorName": "McGlynn, T."}, {"affiliations": {"lastActiveDate": "2017/09", "name": "-", "years": ["2017"]}, "authorName": "Rebull, L. M."}, {"affiliations": {"lastActiveDate": "2017/09", "name": "-", "years": ["2017"]}, "authorName": "Smale, A."}, {"affiliations": {"lastActiveDate": "2017/09", "name": "-", "years": ["2017"]}, "authorName": "Teplitz, H."}, {"affiliations": {"lastActiveDate": "2017/09", "name": "-", "years": ["2017"]}, "authorName": "White, R."}]} +data2 = {'data': [{'affiliations': {'lastActiveDate': '2016/07', 'name': 'Smithsonian Astrophysical Observatory (United States)', 'years': ['2016']}, 'authorName': 'Accomazzi, Alberto'}, {'affiliations': {'lastActiveDate': '2016/01', 'name': '-', 'years': ['2016']}, 'authorName': 'Accomazzi, Alberto'}, {'affiliations': {'lastActiveDate': '2016/07', 'name': 'Space Telescope Science Institute (United States)', 'years': ['2016']}, 'authorName': 'Aloisi, Alessandra'}, {'affiliations': {'lastActiveDate': '2016/07', 'name': 'Infrared Processing and Analysis Ctr. (United States)', 'years': ['2016']}, 'authorName': 'Berriman, Graham B.'}, {'affiliations': {'lastActiveDate': '2016/01', 'name': '-', 'years': ['2016']}, 'authorName': 'Chyla, Roman'}, {'affiliations': {'lastActiveDate': '2016/07', 'name': 'Infrared Processing and Analysis Ctr. (United States)', 'years': ['2016']}, 'authorName': 'Desai, Vandana R.'}, {'affiliations': {'lastActiveDate': '2016/07', 'name': 'Space Telescope Science Institute (United States)', 'years': ['2016']}, 'authorName': 'Donaldson, Thomas'}, {'affiliations': {'lastActiveDate': '2016/07', 'name': 'Space Telescope Science Institute (United States)', 'years': ['2016']}, 'authorName': 'Dower, Theresa'}, {'affiliations': {'lastActiveDate': '2016/07', 'name': 'Infrared Processing and Analysis Ctr. (United States)', 'years': ['2016']}, 'authorName': 'Ebert, Rick'}, {'affiliations': {'lastActiveDate': '2016/01', 'name': '-', 'years': ['2016']}, 'authorName': 'Elliott, Jonathan'}, {'affiliations': {'lastActiveDate': '2016/07', 'name': 'Smithsonian Astrophysical Observatory (United States)', 'years': ['2016']}, 'authorName': 'Fabbiano, Giuseppina'}, {'affiliations': {'lastActiveDate': '2016/01', 'name': '-', 'years': ['2016']}, 'authorName': 'Grant, Carolyn S.'}, {'affiliations': {'lastActiveDate': '2016/07', 'name': 'Infrared Processing and Analysis Ctr. (United States)', 'years': ['2016']}, 'authorName': 'Groom, Steve L.'}, {'affiliations': {'lastActiveDate': '2016/01', 'name': '-', 'years': ['2016']}, 'authorName': 'Henneken, Edwin A.'}, {'affiliations': {'lastActiveDate': '2016/01', 'name': '-', 'years': ['2016']}, 'authorName': 'Holachek, Alexandra'}, {'affiliations': {'lastActiveDate': '2016/07', 'name': 'Infrared Processing and Analysis Ctr. (United States)', 'years': ['2016']}, 'authorName': 'Imel, David'}, {'affiliations': {'lastActiveDate': '2016/01', 'name': '-', 'years': ['2016']}, 'authorName': 'Kurtz, Michael J.'}, {'affiliations': {'lastActiveDate': '2016/07', 'name': 'Infrared Processing and Analysis Ctr. (United States)', 'years': ['2016']}, 'authorName': 'Landry, Walter'}, {'affiliations': {'lastActiveDate': '2016/07', 'name': 'Infrared Processing and Analysis Ctr. (United States)', 'years': ['2016']}, 'authorName': 'Mazzerella, Joseph M.'}, {'affiliations': {'lastActiveDate': '2016/07', 'name': 'NASA Goddard Space Flight Ctr. (United States)', 'years': ['2016']}, 'authorName': 'McGlynn, Thomas'}, {'affiliations': {'lastActiveDate': '2016/07', 'name': 'Infrared Processing and Analysis Ctr. (United States)', 'years': ['2016']}, 'authorName': 'Pevunova, Olga'}, {'affiliations': {'lastActiveDate': '2016/07', 'name': 'NASA Goddard Space Flight Ctr. (United States)', 'years': ['2016']}, 'authorName': 'Smale, Alan'}, {'affiliations': {'lastActiveDate': '2016/07', 'name': 'Infrared Processing and Analysis Ctr. (United States)', 'years': ['2016']}, 'authorName': 'Teplitz, Harry I.'}, {'affiliations': {'lastActiveDate': '2016/01', 'name': '-', 'years': ['2016']}, 'authorName': 'Thompson, Donna M.'}, {'affiliations': {'lastActiveDate': '2016/07', 'name': 'Space Telescope Science Institute (United States)', 'years': ['2016']}, 'authorName': 'White, Richard L.'}]} \ No newline at end of file diff --git a/authoraffsrv/tests/unittests/stubdata/solrdata.py b/authoraffsrv/tests/unittests/stubdata/solrdata.py index c882704..6a4f8ce 100644 --- a/authoraffsrv/tests/unittests/stubdata/solrdata.py +++ b/authoraffsrv/tests/unittests/stubdata/solrdata.py @@ -3874,3 +3874,79 @@ } +data2 = \ +{ + "responseHeader":{ + "status":0, + "QTime":1, + "params":{ + "sort":"date desc", + "fq":"{!bitset}", + "rows":"190", + "q":"*:*", + "start":"0", + "wt":"json", + "fl":"author,aff,pubdate" + } + }, + "response":{ + "start":0, + "numFound":2, + "docs":[ + { + "aff":[ + "NASA Goddard Space Flight Ctr. (United States)", + "Smithsonian Astrophysical Observatory (United States)", + "Smithsonian Astrophysical Observatory (United States)", + "NASA Goddard Space Flight Ctr. (United States)", + "Space Telescope Science Institute (United States)", + "Space Telescope Science Institute (United States)", + "Space Telescope Science Institute (United States)", + "Space Telescope Science Institute (United States)", + "Infrared Processing and Analysis Ctr. (United States)", + "Infrared Processing and Analysis Ctr. (United States)", + "Infrared Processing and Analysis Ctr. (United States)", + "Infrared Processing and Analysis Ctr. (United States)", + "Infrared Processing and Analysis Ctr. (United States)", + "Infrared Processing and Analysis Ctr. (United States)", + "Infrared Processing and Analysis Ctr. (United States)", + "Infrared Processing and Analysis Ctr. (United States)", + "Infrared Processing and Analysis Ctr. (United States)" + ], + "pubdate":"2016-07-00", + "author":[ + "McGlynn, Thomas", + "Fabbiano, Giuseppina", + "Accomazzi, Alberto", + "Smale, Alan", + "White, Richard L.", + "Donaldson, Thomas", + "Aloisi, Alessandra", + "Dower, Theresa", + "Mazzerella, Joseph M.", + "Ebert, Rick", + "Pevunova, Olga", + "Imel, David", + "Berriman, Graham B.", + "Teplitz, Harry I.", + "Groom, Steve L.", + "Desai, Vandana R.", + "Landry, Walter" + ] + }, + { + "pubdate":"2016-01-00", + "author":[ + "Accomazzi, Alberto", + "Kurtz, Michael J.", + "Henneken, Edwin A.", + "Grant, Carolyn S.", + "Thompson, Donna M.", + "Chyla, Roman", + "Holachek, Alexandra", + "Elliott, Jonathan" + ] + }, + ] + } +} \ No newline at end of file diff --git a/authoraffsrv/tests/unittests/test_author_affiliation.py b/authoraffsrv/tests/unittests/test_author_affiliation.py index 950a1c9..edd4886 100644 --- a/authoraffsrv/tests/unittests/test_author_affiliation.py +++ b/authoraffsrv/tests/unittests/test_author_affiliation.py @@ -21,7 +21,7 @@ def test_formatted_data(self): # format the stubdata using the code formatted_data = Formatter(solrdata.data).get(0, 2017) # now compare it with an already formatted data that we know is correct - assert(formatted_data == formatted.data) + self.assertEqual(formatted_data, formatted.data) def test_solr_status_error(self): solr_data = { @@ -30,79 +30,79 @@ def test_solr_status_error(self): } } formatted_data = Formatter(solr_data).get() - assert(formatted_data == None) + self.assertEqual(formatted_data, None) def test_export_csv_format(self): # format the stubdata using the code exported_data = Export(export.form_data).format(EXPORT_FORMATS[0]) # now compare it with an already formatted data that we know is correct - assert(exported_data == export.csv) + self.assertEqual(exported_data, export.csv) def test_export_csv_div_format(self): # format the stubdata using the code exported_data = Export(export.form_data).format(EXPORT_FORMATS[1]) # now compare it with an already formatted data that we know is correct - assert(exported_data == export.csv_div) + self.assertEqual(exported_data, export.csv_div) def test_export_excel_format(self): # format the stubdata using the code exported_data = Export(export.form_data).format(EXPORT_FORMATS[2]) # now compare it with an already formatted data that we know is correct - assert(len(exported_data) == 5632) + self.assertEqual(len(exported_data), 5632) def test_export_excel_div_format(self): # format the stubdata using the code exported_data = Export(export.form_data).format(EXPORT_FORMATS[3]) # now compare it with an already formatted data that we know is correct - assert(len(exported_data) == 5632) + self.assertEqual(len(exported_data), 5632) def test_export_text_format(self): # format the stubdata using the code exported_data = Export(export.form_data).format(EXPORT_FORMATS[4]) # now compare it with an already formatted data that we know is correct - assert(exported_data == export.text) + self.assertEqual(exported_data, export.text) def test_export_text_format2(self): # format the stubdata using the code exported_data = Export(export.form_data).format(EXPORT_FORMATS[5]) # now compare it with an already formatted data that we know is correct - assert(exported_data == export.text) + self.assertEqual(exported_data, export.text) def test_export_csv_get(self): # format the stubdata using the code exported_data = Export(export.form_data).get(EXPORT_FORMATS[0]) # now check the status_code to be 200 - assert (exported_data.status_code == 200) + self.assertEqual (exported_data.status_code, 200) def test_export_csv_div_get(self): # format the stubdata using the code exported_data = Export(export.form_data).get(EXPORT_FORMATS[1]) # now compare it with an already formatted data that we know is correct - assert (exported_data.status_code == 200) + self.assertEqual (exported_data.status_code, 200) def test_export_excel_get(self): # format the stubdata using the code exported_data = Export(export.form_data).get(EXPORT_FORMATS[2]) # now compare it with an already formatted data that we know is correct - assert (exported_data.status_code == 200) + self.assertEqual (exported_data.status_code, 200) def test_export_excel_div_get(self): # format the stubdata using the code exported_data = Export(export.form_data).get(EXPORT_FORMATS[3]) # now compare it with an already formatted data that we know is correct - assert (exported_data.status_code == 200) + self.assertEqual (exported_data.status_code, 200) def test_export_text_get(self): # format the stubdata using the code exported_data = Export(export.form_data).get(EXPORT_FORMATS[4]) # now compare it with an already formatted data that we know is correct - assert (exported_data.status_code == 200) + self.assertEqual (exported_data.status_code, 200) def test_export_text_get2(self): # format the stubdata using the code exported_data = Export(export.form_data).get(EXPORT_FORMATS[5]) # now compare it with an already formatted data that we know is correct - assert (exported_data.status_code == 200) + self.assertEqual (exported_data.status_code, 200) def test_search_no_payload(self): """ @@ -234,12 +234,12 @@ def test_xml_status(self): "q":"*:*", "start":"0", "wt":"json", - "fl":"author,title,year,date,pub,pub_raw,issue,volume,page,page_range,aff,doi,abstract,citation_count,read_count,bibcode,identification,copyright,keyword,doctype,reference,comment,property,esources,data" + "fl":"author,aff,pubdate" } } } formatted_data = Formatter(solr_data) - assert(formatted_data.get_status() == 0) + self.assertEqual(formatted_data.get_status(), 0) def test_xml_no_num_docs(self): solr_data = \ @@ -254,12 +254,22 @@ def test_xml_no_num_docs(self): "q":"*:*", "start":"0", "wt":"json", - "fl":"author,title,year,date,pub,pub_raw,issue,volume,page,page_range,aff,doi,abstract,citation_count,read_count,bibcode,identification,copyright,keyword,doctype,reference,comment,property,esources,data" + "fl":"author,aff,pubdate" } } } formatted_data = Formatter(solr_data) - assert(formatted_data.get_num_docs() == 0) + self.assertEqual(formatted_data.get_num_docs(), 0) + + def test_formatted_data_with_no_aff(self): + """ + test the case with missing affiliation from solr record + """ + # format the stubdata using the code + formatted_data = Formatter(solrdata.data2).get(0, 2016) + self.assertEqual(len(formatted_data), len(formatted.data)) + # now compare it with an already formatted data that we know is correct + self.assertEqual(formatted_data, formatted.data2) if __name__ == '__main__': diff --git a/authoraffsrv/views.py b/authoraffsrv/views.py index 7fa5b50..122f29d 100644 --- a/authoraffsrv/views.py +++ b/authoraffsrv/views.py @@ -341,10 +341,10 @@ def __get_list(self, num_authors, cutoff_year): author_aff = [] for index in range(self.get_num_docs()): a_doc = self.from_solr['response'].get('docs')[index] - if 'author' in a_doc and 'aff' in a_doc and 'pubdate' in a_doc: + if 'author' in a_doc and 'pubdate' in a_doc: if (int(a_doc['pubdate'][:4]) >= cutoff_year): author_list = a_doc['author'] - aff_list = a_doc['aff'] + aff_list = a_doc.get('aff', ['-']*len(author_list)) if (num_authors != 0): author_list = author_list[:num_authors] aff_list = aff_list[:num_authors]