예제 #1
0
 def setUp(self):
     self.app.extensions['registry']['format_templates'] = format_templates_registry()
     self.app.extensions['registry']['format_elements'] = format_elements_registry()
     self.app.extensions['registry']['output_formats_directories'] = output_formats_directories_registry()
     from invenio.modules.formatter.registry import output_formats
     output_formats.expunge()
     self.xml_text = '''<record>
 def tearDown(self):
     sys.path.pop()
     del self.app.extensions['registry']['output_formats_directories']
     from invenio.modules.formatter.registry import output_formats
     output_formats.expunge()
     from invenio.modules.formatter.registry import format_templates_lookup
     format_templates_lookup.expunge()
     del self.app.extensions['registry']['format_elements']
     #cfg['CFG_BIBFORMAT_ELEMENTS_IMPORT_PATH'] = self.old_import_path
     cfg['CFG_BIBFORMAT_TEMPLATES_PATH'] = self.old_templates_path
예제 #3
0
 def tearDown(self):
     sys.path.pop()
     del self.app.extensions['registry']['output_formats_directories']
     from invenio.modules.formatter.registry import output_formats
     output_formats.expunge()
     from invenio.modules.formatter.registry import format_templates_lookup
     format_templates_lookup.expunge()
     del self.app.extensions['registry']['format_elements']
     #cfg['CFG_BIBFORMAT_ELEMENTS_IMPORT_PATH'] = self.old_import_path
     cfg['CFG_BIBFORMAT_TEMPLATES_PATH'] = self.old_templates_path
 def setUp(self):
     self.app.extensions['registry'][
         'format_templates'] = format_templates_registry()
     self.app.extensions['registry'][
         'format_elements'] = format_elements_registry()
     self.app.extensions['registry'][
         'output_formats_directories'] = output_formats_directories_registry(
         )
     from invenio.modules.formatter.registry import output_formats
     output_formats.expunge()
     self.xml_text = '''<record>
예제 #5
0
    def test_format_with_format_template(self):
        """ bibformat - correct formatting with given template"""
        del self.app.extensions['registry']['output_formats_directories']
        from invenio.modules.formatter.registry import output_formats
        output_formats.expunge()
        list(output_formats)
        template = bibformat_engine.get_format_template("Test3.bft")
        result, no_cache = bibformat_engine.format_with_format_template(
                                        format_template_filename=None,
                                        bfo=self.bfo_1,
                                        verbose=0,
                                        format_template_code=template['code'])

        self.assertEqual(result, '''<h1>hi</h1> this is my template\ntest<bfe_non_existing_element must disappear/><test_1  non prefixed element must stay as any normal tag/>tfrgarbage\n<br/>test me!&lt;b&gt;ok&lt;/b&gt;a default valueeditor\n<br/>test me!<b>ok</b>a default valueeditor\n<br/>test me!&lt;b&gt;ok&lt;/b&gt;a default valueeditor\n99999''')
        self.assertEqual(no_cache, False)
    def test_format_with_format_template(self):
        """ bibformat - correct formatting with given template"""
        del self.app.extensions['registry']['output_formats_directories']
        from invenio.modules.formatter.registry import output_formats
        output_formats.expunge()
        list(output_formats)
        template = bibformat_engine.get_format_template("Test3.bft")
        result, no_cache = bibformat_engine.format_with_format_template(
            format_template_filename=None,
            bfo=self.bfo_1,
            verbose=0,
            format_template_code=template['code'])

        self.assertEqual(
            result,
            '''<h1>hi</h1> this is my template\ntest<bfe_non_existing_element must disappear/><test_1  non prefixed element must stay as any normal tag/>tfrgarbage\n<br/>test me!&lt;b&gt;ok&lt;/b&gt;a default valueeditor\n<br/>test me!<b>ok</b>a default valueeditor\n<br/>test me!&lt;b&gt;ok&lt;/b&gt;a default valueeditor\n99999'''
        )
        self.assertEqual(no_cache, False)
예제 #7
0
 def tearDown(self):
     from invenio.modules.formatter.registry import output_formats as ofs
     ofs.expunge()
     del self.app.extensions['registry']['output_formats_directories']
예제 #8
0
 def setUp(self):
     self.app.extensions['registry']['output_formats_directories'] = \
         output_formats_directories_registry()
     from invenio.modules.formatter.registry import output_formats as ofs
     ofs.expunge()
예제 #9
0
    def setUp(self):
        # pylint: disable=C0103
        """ bibformat - prepare BibRecord objects"""
        sys.path.append('%s' % cfg['CFG_TMPDIR'])

        self.xml_text_1 = '''
        <record>
        <controlfield tag="001">33</controlfield>
        <datafield tag="980" ind1="" ind2="">
        <subfield code="a">thesis</subfield>
        </datafield>
        <datafield tag="950" ind1="" ind2="">
        <subfield code="b">Doe1, John</subfield>
        </datafield>
        <datafield tag="100" ind1="" ind2="">
        <subfield code="a">Doe2, John</subfield>
        <subfield code="b">editor</subfield>
        </datafield>
        <datafield tag="245" ind1="" ind2="1">
        <subfield code="a">On the foo and bar1</subfield>
        </datafield>
        <datafield tag="245" ind1="" ind2="2">
        <subfield code="a">On the foo and bar2</subfield>
        </datafield>
        <datafield tag="088" ind1="" ind2="">
        <subfield code="a">99999</subfield>
        </datafield>
        </record>
        '''

        #rec_1 = bibrecord.create_record(self.xml_text_1)
        self.bfo_1 = bibformat_engine.BibFormatObject(
            recID=None, ln='fr', xml_record=self.xml_text_1)

        self.xml_text_2 = '''
        <record>
        <controlfield tag="001">33</controlfield>
        <datafield tag="980" ind1="" ind2="">
        <subfield code="b">thesis </subfield>
        </datafield>
        <datafield tag="950" ind1="" ind2="">
        <subfield code="b">Doe1, John</subfield>
        </datafield>
        <datafield tag="100" ind1="" ind2="">
        <subfield code="a">Doe2, John</subfield>
        <subfield code="b">editor</subfield>
        </datafield>
        <datafield tag="245" ind1="" ind2="1">
        <subfield code="b">On the foo and bar1</subfield>
        </datafield>
        <datafield tag="245" ind1="" ind2="2">
        <subfield code="b">On the foo and bar2</subfield>
        </datafield>
        </record>
        '''
        #self.rec_2 = bibrecord.create_record(xml_text_2)
        self.bfo_2 = bibformat_engine.BibFormatObject(
            recID=None, ln='fr', xml_record=self.xml_text_2)

        self.xml_text_3 = '''
        <record>
        <controlfield tag="001">33</controlfield>
        <datafield tag="041" ind1="" ind2="">
        <subfield code="a">eng</subfield>
        </datafield>
        <datafield tag="100" ind1="" ind2="">
        <subfield code="a">Doe1, John</subfield>
        </datafield>
        <datafield tag="100" ind1="" ind2="">
        <subfield code="a">Doe2, John</subfield>
        <subfield code="b">editor</subfield>
        </datafield>
        <datafield tag="245" ind1="" ind2="1">
        <subfield code="a">On the foo and bar1</subfield>
        </datafield>
        <datafield tag="245" ind1="" ind2="2">
        <subfield code="a">On the foo and bar2</subfield>
        </datafield>
        <datafield tag="980" ind1="" ind2="">
        <subfield code="a">article</subfield>
        </datafield>
        </record>
        '''
        #self.rec_3 = bibrecord.create_record(xml_text_3)
        self.bfo_3 = bibformat_engine.BibFormatObject(
            recID=None, ln='fr', xml_record=self.xml_text_3)

        self.empty_record_xml = '''
        <record>
        <controlfield tag="001">555</controlfield>
        </record>'''

        self.no_001_record_xml = '''
        <record>
        <datafield tag="041" ind1="" ind2="">
        <subfield code="a">eng</subfield>
        </datafield>
        <datafield tag="100" ind1="" ind2="">
        <subfield code="a">Doe1, John</subfield>
        </datafield>'''
        self.app.extensions['registry']['output_formats_directories'] = \
            output_formats_directories_registry()
        from invenio.modules.formatter.registry import output_formats as ofs
        ofs.expunge()
예제 #10
0
 def tearDown(self):
     from invenio.modules.formatter.registry import output_formats
     output_formats.expunge()
     del self.app.extensions['registry']['output_formats_directories']
     del self.app.extensions['registry']['format_templates']
     del self.app.extensions['registry']['format_elements']
예제 #11
0
 def tearDown(self):
     from invenio.modules.formatter.registry import output_formats as ofs
     ofs.expunge()
     del self.app.extensions['registry']['output_formats_directories']
예제 #12
0
 def setUp(self):
     self.app.extensions['registry']['output_formats_directories'] = \
         output_formats_directories_registry()
     from invenio.modules.formatter.registry import output_formats as ofs
     ofs.expunge()
예제 #13
0
    def setUp(self):
        # pylint: disable=C0103
        """ bibformat - prepare BibRecord objects"""
        sys.path.append('%s' % cfg['CFG_TMPDIR'])

        self.xml_text_1 = '''
        <record>
        <controlfield tag="001">33</controlfield>
        <datafield tag="980" ind1="" ind2="">
        <subfield code="a">thesis</subfield>
        </datafield>
        <datafield tag="950" ind1="" ind2="">
        <subfield code="b">Doe1, John</subfield>
        </datafield>
        <datafield tag="100" ind1="" ind2="">
        <subfield code="a">Doe2, John</subfield>
        <subfield code="b">editor</subfield>
        </datafield>
        <datafield tag="245" ind1="" ind2="1">
        <subfield code="a">On the foo and bar1</subfield>
        </datafield>
        <datafield tag="245" ind1="" ind2="2">
        <subfield code="a">On the foo and bar2</subfield>
        </datafield>
        <datafield tag="088" ind1="" ind2="">
        <subfield code="a">99999</subfield>
        </datafield>
        </record>
        '''

        #rec_1 = bibrecord.create_record(self.xml_text_1)
        self.bfo_1 = bibformat_engine.BibFormatObject(recID=None,
                                                      ln='fr',
                                                      xml_record=self.xml_text_1)

        self.xml_text_2 = '''
        <record>
        <controlfield tag="001">33</controlfield>
        <datafield tag="980" ind1="" ind2="">
        <subfield code="b">thesis </subfield>
        </datafield>
        <datafield tag="950" ind1="" ind2="">
        <subfield code="b">Doe1, John</subfield>
        </datafield>
        <datafield tag="100" ind1="" ind2="">
        <subfield code="a">Doe2, John</subfield>
        <subfield code="b">editor</subfield>
        </datafield>
        <datafield tag="245" ind1="" ind2="1">
        <subfield code="b">On the foo and bar1</subfield>
        </datafield>
        <datafield tag="245" ind1="" ind2="2">
        <subfield code="b">On the foo and bar2</subfield>
        </datafield>
        </record>
        '''
        #self.rec_2 = bibrecord.create_record(xml_text_2)
        self.bfo_2 = bibformat_engine.BibFormatObject(recID=None,
                                                      ln='fr',
                                                      xml_record=self.xml_text_2)


        self.xml_text_3 = '''
        <record>
        <controlfield tag="001">33</controlfield>
        <datafield tag="041" ind1="" ind2="">
        <subfield code="a">eng</subfield>
        </datafield>
        <datafield tag="100" ind1="" ind2="">
        <subfield code="a">Doe1, John</subfield>
        </datafield>
        <datafield tag="100" ind1="" ind2="">
        <subfield code="a">Doe2, John</subfield>
        <subfield code="b">editor</subfield>
        </datafield>
        <datafield tag="245" ind1="" ind2="1">
        <subfield code="a">On the foo and bar1</subfield>
        </datafield>
        <datafield tag="245" ind1="" ind2="2">
        <subfield code="a">On the foo and bar2</subfield>
        </datafield>
        <datafield tag="980" ind1="" ind2="">
        <subfield code="a">article</subfield>
        </datafield>
        </record>
        '''
        #self.rec_3 = bibrecord.create_record(xml_text_3)
        self.bfo_3 = bibformat_engine.BibFormatObject(recID=None,
                                                      ln='fr',
                                                      xml_record=self.xml_text_3)

        self.empty_record_xml = '''
        <record>
        <controlfield tag="001">555</controlfield>
        </record>'''

        self.no_001_record_xml = '''
        <record>
        <datafield tag="041" ind1="" ind2="">
        <subfield code="a">eng</subfield>
        </datafield>
        <datafield tag="100" ind1="" ind2="">
        <subfield code="a">Doe1, John</subfield>
        </datafield>'''
        self.app.extensions['registry']['output_formats_directories'] = \
            output_formats_directories_registry()
        from invenio.modules.formatter.registry import output_formats as ofs
        ofs.expunge()
예제 #14
0
 def tearDown(self):
     from invenio.modules.formatter.registry import output_formats
     output_formats.expunge()
     del self.app.extensions['registry']['output_formats_directories']
     del self.app.extensions['registry']['format_templates']
     del self.app.extensions['registry']['format_elements']