Пример #1
0
def make_robotupload_marcxml(url, marcxml, mode, **kwargs):
    """Make a robotupload request."""
    from invenio_utils.url import make_user_agent_string
    from inspire.utils.text import clean_xml

    from invenio_base.globals import cfg
    headers = {
        "User-agent": make_user_agent_string("inspire"),
        "Content-Type": "application/marcxml+xml",
    }
    if url is None:
        base_url = cfg.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,
    )
Пример #2
0
    def test_unicode_clean_xml(self):
        """Test proper handling when bad MARCXML is sent."""
        from inspire.utils.text import clean_xml

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