Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ADSCitationCapture/forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -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', '')
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ADSCitationCapture/tests/data/sample_bib_record.json
Original file line number Diff line number Diff line change
@@ -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"}
{"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"}
1 change: 1 addition & 0 deletions ADSCitationCapture/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def _init_mock_data(self):
'described_by': [],
'abstract': '<p>This is a citable release with a better name.</p>',
'versions': [],
'database': ['astronomy'],
'doctype': 'software',
'forked_from': [],
'affiliations': ['', '', '', '', '', '', '', ''],
Expand Down
1 change: 1 addition & 0 deletions ADSCitationCapture/tests/test_doi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions ADSCitationCapture/tests/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()