예제 #1
0
def make_robotupload_marcxml(url, marcxml, mode, **kwargs):
    """Make a robotupload request."""
    from inspirehep.utils.url import make_user_agent_string
    from inspirehep.utils.text import clean_xml

    headers = {
        "User-agent": make_user_agent_string("inspire"),
        "Content-Type": "application/marcxml+xml",
    }
    if url is None:
        base_url = current_app.config.get("LEGACY_ROBOTUPLOAD_URL")
    else:
        base_url = url

    if base_url:
        url = os.path.join(base_url, "batchuploader/robotupload", mode)
        return requests.post(
            url=url,
            data=str(clean_xml(marcxml)),
            headers=headers,
            params=kwargs,
        )
    else:
        raise ValueError(
            "Base URL missing for robotupload. "
            "Please check `LEGACY_ROBOTUPLOAD_URL` config."
        )
예제 #2
0
def make_robotupload_marcxml(url, marcxml, mode, **kwargs):
    """Make a robotupload request."""
    from inspirehep.utils.url import make_user_agent_string
    from inspirehep.utils.text import clean_xml

    headers = {
        "User-agent": make_user_agent_string("inspire"),
        "Content-Type": "application/marcxml+xml",
    }
    if url is None:
        base_url = current_app.config.get("CFG_ROBOTUPLOAD_SUBMISSION_BASEURL")
    else:
        base_url = url

    url = os.path.join(base_url, "batchuploader/robotupload", mode)
    return requests.post(
        url=url,
        data=str(clean_xml(marcxml)),
        headers=headers,
        params=kwargs,
    )
예제 #3
0
def make_robotupload_marcxml(url, marcxml, mode, **kwargs):
    """Make a robotupload request."""
    from inspirehep.utils.url import make_user_agent_string
    from inspirehep.utils.text import clean_xml

    headers = {
        "User-agent": make_user_agent_string("inspire"),
        "Content-Type": "application/marcxml+xml",
    }
    if url is None:
        base_url = current_app.config.get("CFG_ROBOTUPLOAD_SUBMISSION_BASEURL")
    else:
        base_url = url

    url = os.path.join(base_url, "batchuploader/robotupload", mode)
    return requests.post(
        url=url,
        data=str(clean_xml(marcxml)),
        headers=headers,
        params=kwargs,
    )
예제 #4
0
def test_unicode_clean_xml(unicode_xml, good_unicode_xml):
    """Test proper handling when bad MARCXML is sent."""
    from inspirehep.utils.text import clean_xml

    assert clean_xml(unicode_xml) == good_unicode_xml
예제 #5
0
def test_unicode_clean_xml(unicode_xml, good_unicode_xml):
    """Test proper handling when bad MARCXML is sent."""
    from inspirehep.utils.text import clean_xml

    assert clean_xml(unicode_xml) == good_unicode_xml
예제 #6
0
    def test_unicode_clean_xml(self):
        """Test proper handling when bad MARCXML is sent."""
        from inspirehep.utils.text import clean_xml

        self.assertEqual(clean_xml(self.unicode_xml), self.good_unicode_xml)