diff --git a/ADSCitationCapture/forward.py b/ADSCitationCapture/forward.py index a99fbb0..2c2a27a 100644 --- a/ADSCitationCapture/forward.py +++ b/ADSCitationCapture/forward.py @@ -62,6 +62,7 @@ def build_record(app, citation_change, parsed_metadata, citations, db_versions, source = parsed_metadata.get('source', "Unknown") version = parsed_metadata.get('version', "") doctype = parsed_metadata.get('doctype', "software") + collections = parsed_metadata.get('database', ['general', 'astronomy']) # Clean abstract and title abstract = ''.join(BeautifulSoup(abstract, features="lxml").findAll(text=True)).replace('\n', ' ').replace('\r', '') title = ''.join(BeautifulSoup(title, features="lxml").findAll(text=True)).replace('\n', ' ').replace('\r', '') @@ -96,7 +97,7 @@ def build_record(app, citation_change, parsed_metadata, citations, db_versions, 'bibstem_facet': 'zndo', 'copyright': [], 'comment': [], - 'database': ['general', 'astronomy'], + 'database': collections, 'entry_date': date2solrstamp(entry_date), # date2solrstamp(get_date()), 'year': year, 'date': solr_date, # TODO: Why this date has to be 30 minutes in advance? This is based on ADSImportPipeline SolrAdapter diff --git a/ADSCitationCapture/tests/data/sample_bib_record.json b/ADSCitationCapture/tests/data/sample_bib_record.json index 722669e..b32e161 100644 --- a/ADSCitationCapture/tests/data/sample_bib_record.json +++ b/ADSCitationCapture/tests/data/sample_bib_record.json @@ -1 +1 @@ -{"abstract": "This is a citable release with a better name.", "aff": ["-", "-", "-", "-", "-", "-", "-", "-"], "author": ["Foreman-Mackey, Dan", "Price-Whelan, Adrian", "Ryan, Geoffrey", "Emily", "Smith, Michael", "Barbary, Kyle", "Hogg, David W.", "Brewer, Brendon J."], "author_count": 8, "author_facet": ["Foreman-Mackey, D", "Price-Whelan, A", "Ryan, G", "Emily", "Smith, M", "Barbary, K", "Hogg, D W", "Brewer, B J"], "author_facet_hier": ["0/Foreman-Mackey, D", "1/Foreman-Mackey, D/Foreman-Mackey, Dan", "0/Price-Whelan, A", "1/Price-Whelan, A/Price-Whelan, Adrian", "0/Ryan, G", "1/Ryan, G/Ryan, Geoffrey", "0/Emily", "1/Emily/Emily", "0/Smith, M", "1/Smith, M/Smith, Michael", "0/Barbary, K", "1/Barbary, K/Barbary, Kyle", "0/Hogg, D W", "1/Hogg, D W/Hogg, David W.", "0/Brewer, B J", "1/Brewer, B J/Brewer, Brendon J."], "author_norm": ["Foreman-Mackey, D", "Price-Whelan, A", "Ryan, G", "Emily", "Smith, M", "Barbary, K", "Hogg, D W", "Brewer, B J"], "bibcode": "2014zndo.....11020F", "bibstem": ["zndo"], "bibstem_facet": "zndo", "citation": [""], "citation_count": "1", "database": ["general", "astronomy"], "date": "2014-07-24T00:30:00.000000Z", "doctype": "software", "doctype_facet_hier": ["0/Non-Article", "1/Non-Article/Software"], "doi": ["10.5281/zenodo.11020"], "eid": "10.5281/zenodo.11020", "email": ["-", "-", "-", "-", "-", "-", "-", "-"], "first_author": "Foreman-Mackey, Dan", "first_author_facet_hier": ["0/Foreman-Mackey, D", "1/Foreman-Mackey, D/Foreman-Mackey, Dan"], "first_author_norm": "Foreman-Mackey, D", "identifier": ["2014zndo.....11020F", "10.5281/zenodo.11020"], "links_data": ["{\"access\": \"\", \"instances\": \"\", \"title\": \"\", \"type\": \"electr\", \"url\": \"https://doi.org/10.5281/zenodo.11020\"}"], "property": ["ESOURCE", "NONARTICLE", "NOT REFEREED", "PUB_OPENACCESS", "OPENACCESS"], "pub": "ZENODO", "pub_raw": "ZENODO", "pubdate": "2014-07-24", "title": ["triangle.py v0.1.1"], "year": "2014", "entry_date": "1970-01-01T00:00:00.000000Z", "data_count": 1, "esources": ["PUB_HTML"], "citation_count_norm": 0.125, "publisher": "ZENODO"} \ No newline at end of file +{"abstract": "This is a citable release with a better name.", "aff": ["-", "-", "-", "-", "-", "-", "-", "-"], "author": ["Foreman-Mackey, Dan", "Price-Whelan, Adrian", "Ryan, Geoffrey", "Emily", "Smith, Michael", "Barbary, Kyle", "Hogg, David W.", "Brewer, Brendon J."], "author_count": 8, "author_facet": ["Foreman-Mackey, D", "Price-Whelan, A", "Ryan, G", "Emily", "Smith, M", "Barbary, K", "Hogg, D W", "Brewer, B J"], "author_facet_hier": ["0/Foreman-Mackey, D", "1/Foreman-Mackey, D/Foreman-Mackey, Dan", "0/Price-Whelan, A", "1/Price-Whelan, A/Price-Whelan, Adrian", "0/Ryan, G", "1/Ryan, G/Ryan, Geoffrey", "0/Emily", "1/Emily/Emily", "0/Smith, M", "1/Smith, M/Smith, Michael", "0/Barbary, K", "1/Barbary, K/Barbary, Kyle", "0/Hogg, D W", "1/Hogg, D W/Hogg, David W.", "0/Brewer, B J", "1/Brewer, B J/Brewer, Brendon J."], "author_norm": ["Foreman-Mackey, D", "Price-Whelan, A", "Ryan, G", "Emily", "Smith, M", "Barbary, K", "Hogg, D W", "Brewer, B J"], "bibcode": "2014zndo.....11020F", "bibstem": ["zndo"], "bibstem_facet": "zndo", "citation": [""], "citation_count": "1", "database": ["astronomy"], "date": "2014-07-24T00:30:00.000000Z", "doctype": "software", "doctype_facet_hier": ["0/Non-Article", "1/Non-Article/Software"], "doi": ["10.5281/zenodo.11020"], "eid": "10.5281/zenodo.11020", "email": ["-", "-", "-", "-", "-", "-", "-", "-"], "first_author": "Foreman-Mackey, Dan", "first_author_facet_hier": ["0/Foreman-Mackey, D", "1/Foreman-Mackey, D/Foreman-Mackey, Dan"], "first_author_norm": "Foreman-Mackey, D", "identifier": ["2014zndo.....11020F", "10.5281/zenodo.11020"], "links_data": ["{\"access\": \"\", \"instances\": \"\", \"title\": \"\", \"type\": \"electr\", \"url\": \"https://doi.org/10.5281/zenodo.11020\"}"], "property": ["ESOURCE", "NONARTICLE", "NOT REFEREED", "PUB_OPENACCESS", "OPENACCESS"], "pub": "ZENODO", "pub_raw": "ZENODO", "pubdate": "2014-07-24", "title": ["triangle.py v0.1.1"], "year": "2014", "entry_date": "1970-01-01T00:00:00.000000Z", "data_count": 1, "esources": ["PUB_HTML"], "citation_count_norm": 0.125, "publisher": "ZENODO"} \ No newline at end of file diff --git a/ADSCitationCapture/tests/test_base.py b/ADSCitationCapture/tests/test_base.py index 7016d8a..160ed0b 100644 --- a/ADSCitationCapture/tests/test_base.py +++ b/ADSCitationCapture/tests/test_base.py @@ -87,6 +87,7 @@ def _init_mock_data(self): 'described_by': [], 'abstract': '

This is a citable release with a better name.

', 'versions': [], + 'database': ['astronomy'], 'doctype': 'software', 'forked_from': [], 'affiliations': ['', '', '', '', '', '', '', ''], diff --git a/ADSCitationCapture/tests/test_doi.py b/ADSCitationCapture/tests/test_doi.py index c617b11..f808fd8 100644 --- a/ADSCitationCapture/tests/test_doi.py +++ b/ADSCitationCapture/tests/test_doi.py @@ -20,6 +20,7 @@ def test_software_doi(self): doi_id = "10.5281/zenodo.11020" # software expected_response_content = self.mock_data[doi_id]['raw'] expected_parsed_response = self.mock_data[doi_id]['parsed'] + expected_parsed_response.pop("database") # We do this because the database is an augmentation to the metadata. httpretty.enable() # enable HTTPretty so that it will monkey patch the socket module httpretty.register_uri(httpretty.GET, self.app.conf['DOI_URL']+doi_id, body=expected_response_content) raw_metadata = doi.fetch_metadata(self.app.conf['DOI_URL'], self.app.conf['DATACITE_URL'], doi_id) diff --git a/ADSCitationCapture/tests/test_forward.py b/ADSCitationCapture/tests/test_forward.py index f04ebd8..a67ed30 100644 --- a/ADSCitationCapture/tests/test_forward.py +++ b/ADSCitationCapture/tests/test_forward.py @@ -88,5 +88,6 @@ def test_build_bib_record_associated_works(self): self.assertEqual(bib_record.toJSON(),expect_bib_record) self.assertEqual(nonbib_record.toJSON(),expect_nonbib_record) + if __name__ == '__main__': unittest.main()