def test_find_fields(self):
     record = create_record(self.xml)
     record.add_subfield('10012b', 'not title')
     found_fields = record.find_fields('100__')
     expected_fields = [BibRecordField(ind1=' ', ind2=' ')]
     expected_fields[0].add_subfield('a', 'our title')
     self.assertEqual(found_fields, expected_fields)
 def test_add_subfield2(self):
     expected_record = create_record(self.xml)
     record = BibRecord()
     field = BibRecordField()
     record['100'] = [field]
     field.add_subfield('a', 'our title')
     self.assertEqual(record, expected_record)
 def test_add_subfield2(self):
     expected_record = create_record(self.xml)
     record = BibRecord()
     field = BibRecordField()
     record['100'] = [field]
     field.add_subfield('a', 'our title')
     self.assertEqual(record, expected_record)
 def test_find_fields(self):
     record = create_record(self.xml)
     record.add_subfield('10012b', 'not title')
     found_fields = record.find_fields('100__')
     expected_fields = [BibRecordField(ind1=' ', ind2=' ')]
     expected_fields[0].add_subfield('a', 'our title')
     self.assertEqual(found_fields, expected_fields)
Ejemplo n.º 5
0
def create_records_from_string(xml):
    """
    Wrapping function using docextract_record.create_record function to return a
    list of BibRecord structures.
    """
    from invenio.docextract_record import create_record
    return create_record(xml)
Ejemplo n.º 6
0
def create_records_from_file(path_to_file):
    """
    Wrapping function using docextract_record.create_record function to return a
    list of BibRecord structures.
    """
    fd_xml_file = open(path_to_file, "r")
    xml = fd_xml_file.read()
    fd_xml_file.close()

    return create_record(xml)
Ejemplo n.º 7
0
def create_records_from_file(path_to_file):
    """
    Wrapping function using docextract_record.create_record function to return a
    list of BibRecord structures.
    """
    fd_xml_file = open(path_to_file, "r")
    xml = fd_xml_file.read()
    fd_xml_file.close()

    return create_record(xml)
Ejemplo n.º 8
0
 def test_add_subfield(self):
     xml = """<record>
         <datafield tag="100" ind1=" " ind2=" ">
             <subfield code="a">our title</subfield>
         </datafield>
     </record>"""
     expected_record = create_record(xml)
     record = BibRecord()
     record.add_subfield('100__a', 'our title')
     self.assertEqual(record, expected_record)
 def test_add_subfield(self):
     xml = """<record>
         <datafield tag="100" ind1=" " ind2=" ">
             <subfield code="a">our title</subfield>
         </datafield>
     </record>"""
     expected_record = create_record(xml)
     record = BibRecord()
     record.add_subfield('100__a', 'our title')
     self.assertEqual(record, expected_record)
    def test_del_field(self):
        record = create_record(self.xml)
        record.add_subfield('101__b', 'not title')

        del record['100__']

        expected_record = BibRecord()
        expected_record.add_subfield('101__b', 'not title')

        self.assertEqual(record, expected_record)
    def test_del_field(self):
        record = create_record(self.xml)
        record.add_subfield('101__b', 'not title')

        del record['100__']

        expected_record = BibRecord()
        expected_record.add_subfield('101__b', 'not title')

        self.assertEqual(record, expected_record)
Ejemplo n.º 12
0
 def test_create_record(self):
     for dummy, xml in self.xml_cache.iteritems():
         record = create_record(xml)
         self.assertXmlEqual(record.to_xml(), xml)
 def test_create_record(self):
     for dummy, xml in self.xml_cache.iteritems():
         record = create_record(xml)
         self.assertXmlEqual(record.to_xml(), xml)
 def test_to_xml(self):
     record = create_record(self.xml)
     record2 = create_record(record.to_xml())
     self.assertEqual(record, record2)
 def test_find_subfields2(self):
     record = create_record(self.xml)
     record.add_subfield('10012b', 'not title')
     found_subfields = record.find_subfields('100__a')
     expected_subfields = [BibRecordSubField('a', 'our title')]
     self.assertEqual(found_subfields, expected_subfields)
 def test_len_record(self):
     record = create_record(self.xml)
     self.assertEqual(len(record), 1)
     record.add_subfield('100__a', 'our title2')
     self.assertEqual(len(record), 2)
 def test_record_equality(self):
     record1 = create_record(self.xml)
     record2 = create_record(self.xml)
     self.assertEqual(record1, record2)
 def test_record_equality(self):
     record1 = create_record(self.xml)
     record2 = create_record(self.xml)
     self.assertEqual(record1, record2)
 def test_add_subfield(self):
     expected_record = create_record(self.xml)
     record = BibRecord()
     record.add_subfield('100__a', 'our title')
     self.assertEqual(record, expected_record)
 def test_len_record(self):
     record = create_record(self.xml)
     self.assertEqual(len(record), 1)
     record.add_subfield('100__a', 'our title2')
     self.assertEqual(len(record), 2)
 def test_find_subfields2(self):
     record = create_record(self.xml)
     record.add_subfield('10012b', 'not title')
     found_subfields = record.find_subfields('100__a')
     expected_subfields = [BibRecordSubField('a', 'our title')]
     self.assertEqual(found_subfields, expected_subfields)
 def test_add_field(self):
     expected_record = create_record(self.xml)
     record = BibRecord()
     record.add_field('100__')
     record['100__'][0].add_subfield('a', 'our title')
     self.assertEqual(record, expected_record)
 def test_to_xml(self):
     record = create_record(self.xml)
     record2 = create_record(record.to_xml())
     self.assertEqual(record, record2)