Example #1
0
    def test_nonbarfing_emptiness(self):
        r = crossref.parse_crossref_output('')
        assert r['msg'] == 'crossref error', 'missing query should cause a crossref error'
        assert 'compendia' not in r, 'empty reply should have an empty compendia'

        r = crossref.query('pid', 'no match')
        assert r['msg'] == 'invalid doi parameter: no match'
    def test_nonbarfing_emptiness(self):
        r = crossref.parse_crossref_output('')
        assert r['msg'] == 'crossref error', 'missing query should cause a crossref error'
        assert 'compendia' not in r, 'empty reply should have an empty compendia'

        r = crossref.query('pid', 'no match')
        assert r['msg'] == 'invalid doi parameter: no match'
Example #3
0
def doi_crossref(request):
    """ Returns information based on crossref's doi query service

    request: The request is required to have a valid doi string. valid means TODO

    response: The response will contain a json dict of data with keys
    corresponding to attributes of the Article and Collaborator models. Any
    attributes we were unable to get from the crossref service will not be
    included in the dict.
    """

    if 'doi' not in request.POST:
        logger.debug("doi not in request %s", request.POST)
        return Response({"message": "missing DOI from request"}, status=status.HTTP_400_BAD_REQUEST)

    doi_data = crossref.query(settings.CROSSREF_PID, request.POST['doi'])
    return Response(doi_data)
def doi_crossref(request):
    """ Returns information based on crossref's doi query service

    request: The request is required to have a valid doi string. valid means TODO

    response: The response will contain a json dict of data with keys
    corresponding to attributes of the Article and Collaborator models. Any
    attributes we were unable to get from the crossref service will not be
    included in the dict.
    """

    if 'doi' not in request.POST:
        logger.debug("doi not in request %s", request.POST)
        return Response({"message": "missing DOI from request"},
                        status=status.HTTP_400_BAD_REQUEST)

    doi_data = crossref.query(settings.CROSSREF_PID, request.POST['doi'])
    return Response(doi_data)
Example #5
0
 def test_nonbarfing_invalid_param(self):
     r = crossref.query('pid', None)
     assert r['msg'] == 'invalid doi parameter: None'
     r = crossref.query('pid', 0)
     assert r['msg'] == 'invalid doi parameter: 0'
 def test_nonbarfing_invalid_param(self):
     r = crossref.query('pid', None)
     assert r['msg'] == 'invalid doi parameter: None'
     r = crossref.query('pid', 0)
     assert r['msg'] == 'invalid doi parameter: 0'