Ejemplo n.º 1
0
    def test_get_xml_from_textmarc_success(self):
        textmarc = """100__ $$aDoe, J.$$uCERN
        245__ $$aPion production by 24 GeV/c protons in hydrogen
        260__ $$c1961
        300__ $$a15"""
        output = get_xml_from_textmarc(1, textmarc)
        self.assertEqual(output['resultMsg'], 'textmarc_parsing_success')

        xml_expected_output = """<record>
    <controlfield tag="001">1</controlfield>
        <datafield tag="100" ind1=" " ind2=" ">
            <subfield code="a">Doe, J.</subfield>
            <subfield code="u">CERN</subfield>
        </datafield>
        <datafield tag="245" ind1=" " ind2=" ">
            <subfield code="a">Pion production by 24 GeV/c protons in hydrogen</subfield>
        </datafield>
        <datafield tag="260" ind1=" " ind2=" ">
            <subfield code="c">1961</subfield>
        </datafield>
        <datafield tag="300" ind1=" " ind2=" ">
            <subfield code="a">15</subfield>
        </datafield>
</record>
        """
        self.assertEqual(re.sub("\s+", " ", output['resultXML'].strip()),
            re.sub("\s+", " ", xml_expected_output.strip()))
Ejemplo n.º 2
0
 def test_get_xml_from_textmarc_wrong_content(self):
     textmarc = """100__ $$a
     245__ $$aPion production by 24 GeV/c protons in hydrogen
     260__ $$c1961
     300__ $$a15"""
     output = get_xml_from_textmarc(1, textmarc)
     self.assertEqual(output['resultMsg'], 'textmarc_parsing_error')
Ejemplo n.º 3
0
    def test_get_xml_from_textmarc_success(self):
        textmarc = """100__ $$aDoe, J.$$uCERN
        245__ $$aPion production by 24 GeV/c protons in hydrogen
        260__ $$c1961
        300__ $$a15"""
        output = get_xml_from_textmarc(1, textmarc)
        self.assertEqual(output['resultMsg'], 'textmarc_parsing_success')

        xml_expected_output = """<record>
    <controlfield tag="001">1</controlfield>
        <datafield tag="100" ind1=" " ind2=" ">
            <subfield code="a">Doe, J.</subfield>
            <subfield code="u">CERN</subfield>
        </datafield>
        <datafield tag="245" ind1=" " ind2=" ">
            <subfield code="a">Pion production by 24 GeV/c protons in hydrogen</subfield>
        </datafield>
        <datafield tag="260" ind1=" " ind2=" ">
            <subfield code="c">1961</subfield>
        </datafield>
        <datafield tag="300" ind1=" " ind2=" ">
            <subfield code="a">15</subfield>
        </datafield>
</record>
        """
        self.assertEqual(re.sub("\s+", " ", output['resultXML'].strip()),
                         re.sub("\s+", " ", xml_expected_output.strip()))
Ejemplo n.º 4
0
 def test_get_xml_from_textmarc_wrong_content(self):
     textmarc = """100__ $$a
     245__ $$aPion production by 24 GeV/c protons in hydrogen
     260__ $$c1961
     300__ $$a15"""
     output = get_xml_from_textmarc(1, textmarc)
     self.assertEqual(output['resultMsg'], 'textmarc_parsing_error')
Ejemplo n.º 5
0
 def test_get_xml_from_textmarc_wrong_field(self):
     textmarc = """1sasd00__ $$aDoe, J.$$uCERN
     245__ $$aPion production by 24 GeV/c protons in hydrogen
     260__ $$c1961
     300__ $$a15"""
     output = get_xml_from_textmarc(1, textmarc)
     self.assertEqual(output['resultMsg'], 'textmarc_parsing_error')
     expected_error = [1, "1sasd00__ $$aDoe, J.$$uCERN"]
     self.assertEqual(output['parse_error'][:-1], expected_error)
Ejemplo n.º 6
0
 def test_get_xml_from_textmarc_wrong_field(self):
     textmarc = """1sasd00__ $$aDoe, J.$$uCERN
     245__ $$aPion production by 24 GeV/c protons in hydrogen
     260__ $$c1961
     300__ $$a15"""
     output = get_xml_from_textmarc(1, textmarc)
     self.assertEqual(output['resultMsg'], 'textmarc_parsing_error')
     expected_error = [1, "1sasd00__ $$aDoe, J.$$uCERN"]
     self.assertEqual(output['parse_error'][:-1], expected_error)
Ejemplo n.º 7
0
    def test_accept_fft_tags_in_textmarc(self):
        textmarc = """100__ $$aDoe, J.$$uCERN
        FFT__ $$ahttp://scd-theses.u-strasbg.fr/1818/01/RICAUD_Helene_2008.pdf$$dFulltext"""
        output = get_xml_from_textmarc(1, textmarc)

        xml_expected_output = """<record>
        <controlfield tag="001">1</controlfield>
        <datafield tag="100" ind1=" " ind2=" ">
            <subfield code="a">Doe, J.</subfield>
            <subfield code="u">CERN</subfield>
        </datafield>
        <datafield tag="FFT" ind1=" " ind2=" ">
            <subfield code="a">http://scd-theses.u-strasbg.fr/1818/01/RICAUD_Helene_2008.pdf</subfield>
            <subfield code="d">Fulltext</subfield>
        </datafield>
        </record>"""

        self.assertEqual(re.sub("\s+", " ", output['resultXML'].strip()),
                         re.sub("\s+", " ", xml_expected_output.strip()))
Ejemplo n.º 8
0
    def test_accept_fft_tags_in_textmarc(self):
        textmarc = """100__ $$aDoe, J.$$uCERN
        FFT__ $$ahttp://scd-theses.u-strasbg.fr/1818/01/RICAUD_Helene_2008.pdf$$dFulltext"""
        output = get_xml_from_textmarc(1, textmarc)

        xml_expected_output = """<record>
        <controlfield tag="001">1</controlfield>
        <datafield tag="100" ind1=" " ind2=" ">
            <subfield code="a">Doe, J.</subfield>
            <subfield code="u">CERN</subfield>
        </datafield>
        <datafield tag="FFT" ind1=" " ind2=" ">
            <subfield code="a">http://scd-theses.u-strasbg.fr/1818/01/RICAUD_Helene_2008.pdf</subfield>
            <subfield code="d">Fulltext</subfield>
        </datafield>
        </record>"""

        self.assertEqual(re.sub("\s+", " ", output['resultXML'].strip()),
            re.sub("\s+", " ", xml_expected_output.strip()))
Ejemplo n.º 9
0
    def test_get_xml_from_textmarc_wrong_content(self):
        textmarc = """100__ $$a
        245__ $$aPion production by 24 GeV/c protons in hydrogen
        260__ $$c1961
        300__ $$a15"""
        output = get_xml_from_textmarc(1, textmarc)
        # We expect success now, ignoring empty field, see ticket:1269.
        # <http://invenio-software.org/ticket/1269>
        self.assertEqual(output['resultMsg'], 'textmarc_parsing_success')
        self.assertEqual(output['resultXML'], """<record>
   <controlfield tag="001">1</controlfield>
   <datafield tag="245" ind1=" " ind2=" ">
      <subfield code="a">Pion production by 24 GeV/c protons in hydrogen</subfield>
   </datafield>
   <datafield tag="260" ind1=" " ind2=" ">
      <subfield code="c">1961</subfield>
   </datafield>
   <datafield tag="300" ind1=" " ind2=" ">
      <subfield code="a">15</subfield>
   </datafield>
</record>
""")
Ejemplo n.º 10
0
    def test_get_xml_from_textmarc_wrong_content(self):
        textmarc = """100__ $$a
        245__ $$aPion production by 24 GeV/c protons in hydrogen
        260__ $$c1961
        300__ $$a15"""
        output = get_xml_from_textmarc(1, textmarc)
        # We expect success now, ignoring empty field, see ticket:1269.
        # <http://invenio-software.org/ticket/1269>
        self.assertEqual(output['resultMsg'], 'textmarc_parsing_success')
        self.assertEqual(output['resultXML'], """<record>
   <controlfield tag="001">1</controlfield>
   <datafield tag="245" ind1=" " ind2=" ">
      <subfield code="a">Pion production by 24 GeV/c protons in hydrogen</subfield>
   </datafield>
   <datafield tag="260" ind1=" " ind2=" ">
      <subfield code="c">1961</subfield>
   </datafield>
   <datafield tag="300" ind1=" " ind2=" ">
      <subfield code="a">15</subfield>
   </datafield>
</record>
""")