def _non_critical_abs_data(abs_meta: DocMetadata, arxiv_identifier: Identifier, response_data: Dict)->None: """Get additional non-essential data for the abs page.""" # The DBLP listing and trackback counts depend on the DB. response_data['dblp'] = _check_dblp(abs_meta) response_data['trackback_ping_count'] = count_trackback_pings( arxiv_identifier.id) if response_data['trackback_ping_count'] > 0: response_data['trackback_ping_latest'] = \ get_trackback_ping_latest_date(arxiv_identifier.id) # Include INSPIRE link in references & citations section response_data['include_inspire_link'] = include_inspire_link( abs_meta) # Ancillary files response_data['ancillary_files'] = \ metadata.get_ancillary_files(abs_meta) # Browse context _check_context(arxiv_identifier, abs_meta.primary_category, response_data) response_data['is_covid_match'] = _is_covid_match(abs_meta)
def test_include_inspire_link(self, mock_docmeta): """Tests for the include_inspire_link function.""" mock_docmeta.arxiv_identifier = Identifier('1201.0001') mock_docmeta.primary_category = Category('hep-th') self.assertTrue(include_inspire_link(mock_docmeta)) mock_docmeta.arxiv_identifier = Identifier('1212.0001') mock_docmeta.primary_category = Category('astro-ph.CO') self.assertFalse(include_inspire_link(mock_docmeta)) mock_docmeta.arxiv_identifier = Identifier('1301.0001') mock_docmeta.primary_category = Category('astro-ph.CO') self.assertTrue(include_inspire_link(mock_docmeta)) mock_docmeta.arxiv_identifier = Identifier('1806.01234') mock_docmeta.primary_category = Category('physics.ins-det') self.assertTrue(include_inspire_link(mock_docmeta)) mock_docmeta.arxiv_identifier = Identifier('1212.0002') mock_docmeta.primary_category = Category('physics.gen-ph') self.assertFalse(include_inspire_link(mock_docmeta))
def test_abs_without_inspire(self): f1 = ABS_FILES + '/ftp/math/papers/0202/0202001.abs' m = AbsMetaSession.parse_abs_file(filename=f1) assert_that(m, is_not(None)) assert_that(include_inspire_link(m), equal_to(False), 'math/0202001 should NOT get Insire link') rv = self.app.get('/abs/math/0202001') assert_that(rv.status_code, 200) assert_that(rv.data.decode('utf-8'), is_not(contains_string('INSPIRE HEP')), 'math/0202001 should NOT get INSPIRE link')
def test_abs_with_inspire(self): f1 = ABS_FILES + '/ftp/arxiv/papers/1108/1108.5926.abs' m = AbsMetaSession.parse_abs_file(filename=f1) assert_that(m, is_not(None)) assert_that(get_orig_publish_date(m.arxiv_identifier), equal_to(date(2011, 8, 1))) assert_that(m.primary_category, is_not(equal_to(None))) assert_that(include_inspire_link(m), is_not(equal_to(False)), '1108.5926v1 should get Insire link') rv = self.app.get('/abs/1108.5926v1') assert_that(rv.status_code, 200) assert_that(rv.data.decode('utf-8'), contains_string('INSPIRE HEP'), '1108.5926 should get INSPIRE link')