def test_model_based_harvesting(self):
        """Test harvesting using model."""
        raw_xml = open(os.path.join(
            os.path.dirname(__file__), "data/sample_arxiv_response.xml"
        )).read()

        responses.add(
            responses.GET,
            'http://export.arxiv.org/oai2',
            body=raw_xml,
            content_type='text/xml'
        )

        _, records = get_records(['oai:arXiv.org:1507.03011'],
                                 name='arXiv')
        self.assertTrue(len(records) == 1)
Ejemplo n.º 2
0
    def test_get_from_identifiers_with_prefix(self):
        raw_xml = open(
            os.path.join(os.path.dirname(__file__),
                         "data/sample_arxiv_response.xml")).read()

        httpretty.register_uri(httpretty.GET,
                               'http://export.arxiv.org/oai2',
                               body=raw_xml,
                               content_type='text/xml')
        for rec in get_records(['oai:arXiv.org:1507.03011'],
                               metadata_prefix="arXiv",
                               url='http://export.arxiv.org/oai2'):
            identifier_in_request = rec.xml.xpath(
                "//arXiv:id",
                namespaces={"arXiv": "http://arxiv.org/OAI/arXiv/"})[0].text
            self.assertEqual(identifier_in_request, "1507.03011")
Ejemplo n.º 3
0
    def test_get_from_identifiers(self):
        raw_xml = open(
            os.path.join(os.path.dirname(__file__),
                         "data/sample_oai_dc_response.xml")).read()

        httpretty.register_uri(httpretty.GET,
                               'http://export.arxiv.org/oai2',
                               body=raw_xml,
                               content_type='text/xml')
        for rec in get_records(['oai:arXiv.org:1507.03011'],
                               url='http://export.arxiv.org/oai2'):
            identifier_in_request = rec.xml.xpath(
                "//dc:identifier",
                namespaces={"dc": "http://purl.org/dc/elements/1.1/"})[0].text
            self.assertEqual(identifier_in_request,
                             "http://arxiv.org/abs/1507.03011")
    def test_get_from_identifiers(self):
        raw_xml = open(os.path.join(
            os.path.dirname(__file__), "data/sample_oai_dc_response.xml"
        )).read()

        responses.add(
            responses.GET,
            'http://export.arxiv.org/oai2',
            body=raw_xml,
            content_type='text/xml'
        )
        for rec in get_records(['oai:arXiv.org:1507.03011'],
                               url='http://export.arxiv.org/oai2'):
            identifier_in_request = rec.xml.xpath(
                "//dc:identifier",
                namespaces={"dc": "http://purl.org/dc/elements/1.1/"}
            )[0].text
            self.assertEqual(identifier_in_request,
                             "http://arxiv.org/abs/1507.03011")
    def test_get_from_identifiers_with_prefix(self):
        raw_xml = open(os.path.join(
            os.path.dirname(__file__), "data/sample_arxiv_response.xml"
        )).read()

        responses.add(
            responses.GET,
            'http://export.arxiv.org/oai2',
            body=raw_xml,
            content_type='text/xml'
        )
        for rec in get_records(['oai:arXiv.org:1507.03011'],
                               metadata_prefix="arXiv",
                               url='http://export.arxiv.org/oai2'):
            identifier_in_request = rec.xml.xpath(
                "//arXiv:id",
                namespaces={"arXiv": "http://arxiv.org/OAI/arXiv/"}
            )[0].text
            self.assertEqual(identifier_in_request,
                             "1507.03011")