How to use the arxiv.status function in arxiv

To help you get started, we’ve selected a few arxiv examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github arXiv / arxiv-browse / browse / controllers / tb_page / tests.py View on Github external
'foo': 'bar'
        })
        with self.assertRaises(BadRequest):
            tb_page.get_recent_tb_page(form_data)

        form_data = MultiDict({
            'views': 'baz'
        })
        with self.assertRaises(BadRequest):
            tb_page.get_recent_tb_page(form_data)

        form_data = MultiDict({
            'views': '25'
        })
        response_data, code, headers = tb_page.get_recent_tb_page(form_data)
        self.assertEqual(code, status.HTTP_200_OK, 'Response should be OK.')
        self.assertIn('max_trackbacks', response_data,
                      "Response data should include 'max_trackbacks'")
        self.assertEqual(response_data['max_trackbacks'], 25,
                         "'max_trackbacks' should equal value from form")
        self.assertIn('recent_trackback_pings', response_data,
                      "Response data should include 'recent_trackback_pings'")
        self.assertIn('article_map', response_data,
                      "Response data should include 'article_map'")
github arXiv / arxiv-search / search / controllers / advanced / tests.py View on Github external
def test_invalid_data(self, mock_index):
        """Form data are invalid."""
        request_data = MultiDict({
            'advanced': True,
            'date-past_12': True,
            'date-specific_year': True,
            'date-year': '2012'
        })
        response_data, code, headers = advanced.search(request_data)
        self.assertEqual(code, status.HTTP_200_OK, "Response should be OK.")

        self.assertIn('form', response_data, "Response should include form.")

        self.assertEqual(mock_index.search.call_count, 0,
                         "No search should be attempted")
github arXiv / arxiv-browse / tests / test_exceptions.py View on Github external
response = self.client.get(path)
            self.assertEqual(response.status_code,
                             status.HTTP_404_NOT_FOUND,
                             f'should get 404 for {path}')
            self.assertIn('text/html', response.content_type)

        response = self.client.get('/abs/1307.0001v999')
        self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND,
                         f'should get 404 for known paper ID with '
                         'nonexistent version')
        response = self.client.get('/abs/alg-geom/07059999')
        self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND,
                         f'should get 404 for valid old paper ID '
                         'with nonexistent paper number affix')
        response = self.client.get('/abs/astro-ph/0110242')
        self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND,
                         f'should get 404 for known deleted paper')
        response = self.client.get('/abs/foo-bar/11223344')
        self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND,
                         f'should get 404 for bad paper ID')
github arXiv / arxiv-browse / browse / controllers / tb_page / __init__.py View on Github external
arxiv_identifier = Identifier(arxiv_id=arxiv_id)
        redirect = check_supplied_identifier(arxiv_identifier,
                                             'browse.tb')
        if redirect:
            return redirect
        response_data['arxiv_identifier'] = arxiv_identifier
        abs_meta = metadata.get_abs(arxiv_identifier.id)
        if abs_meta:
            response_data['abs_meta'] = abs_meta
        trackback_pings = get_paper_trackback_pings(arxiv_identifier.id)
        response_data['trackback_pings'] = trackback_pings
        if len(trackback_pings) > 0:
            response_data['author_links'] = \
                split_long_author_list(queries_for_authors(
                    abs_meta.authors.raw), truncate_author_list_size)
        response_status = status.HTTP_200_OK

    except AbsNotFoundException:
        raise TrackbackNotFound(data={'arxiv_id': arxiv_id, 'not_found': True})
    except (AbsException, IdentifierException):
        raise TrackbackNotFound(data={'arxiv_id': arxiv_id})
    except Exception as ex:
        logger.warning(f'Error getting trackbacks: {ex}')
        raise InternalServerError from ex

    return response_data, response_status, response_headers
github arXiv / arxiv-browse / browse / controllers / list_page / __init__.py View on Github external
shown = default_show
    else:
        shown = min(int(show), max_show)

    if_mod_since = request.headers.get('If-Modified-Since', None)

    response_data: Dict[str, Any] = {}
    response_headers: Dict[str, Any] = {}

    if time_period == 'new':
        list_type = 'new'
        new_resp = listing_service.list_new_articles(
            subject_or_category, skipn, shown, if_mod_since)
        response_headers.update(_expires_headers(new_resp))
        if _not_modified(new_resp):
            return {}, status.HTTP_304_NOT_MODIFIED, response_headers
        listings = new_resp['listings']
        count = new_resp['new_count'] + \
            new_resp['rep_count'] + new_resp['cross_count']
        response_data['announced'] = new_resp['announced']
        response_data['submitted'] = new_resp['submitted']
        response_data.update(
            index_for_types(new_resp, subject_or_category, time_period, skipn, shown))
        response_data.update(sub_sections_for_types(new_resp, skipn, shown))

    elif time_period in ['pastweek', 'recent']:
        list_type = 'recent'
        rec_resp = listing_service.list_pastweek_articles(
            subject_or_category, skipn, shown, if_mod_since)
        response_headers.update(_expires_headers(rec_resp))
        if _not_modified(rec_resp):
            return {}, status.HTTP_304_NOT_MODIFIED, response_headers
github arXiv / arxiv-search / search / controllers / __init__.py View on Github external
Returns
    -------
    dict
        Search result response data.
    int
        HTTP status code.
    dict
        Headers to add to the response.

    """
    try:
        document_set = index.SearchSession.search(  # type: ignore
            SimpleQuery(search_field="all", value="theory")
        )
    except Exception:
        return "DOWN", status.HTTP_500_INTERNAL_SERVER_ERROR, {}
    if document_set["results"]:
        return "OK", status.HTTP_200_OK, {}
    return "DOWN", status.HTTP_500_INTERNAL_SERVER_ERROR, {}
github arXiv / arxiv-browse / browse / routes / ui.py View on Github external
def home() -> Response:
    """Home page view."""
    response, code, headers = home_page.get_home_page()
    if code == status.HTTP_200_OK:
        return render_template('home/home.html', **response), code, headers  # type: ignore

    raise InternalServerError('Unexpected error')