Esempio n. 1
0
 def setUp(self):
     data = pybtex.database.BibliographyData({
         'hongquin1997':
         pybtex.database.Entry(
             'article',
             fields={
                 'language': u'english',
                 'title':
                 u'Predicting the Diffusion Coefficient in Supercritical Fluids',
                 'journal': u'Ind. Eng. Chem. Res.',
                 'volume': u'36',
                 'year': u'1997',
                 'pages': u'888-895',
             },
             persons={
                 'author': [
                     pybtex.database.Person(u'Liu, Hongquin'),
                     pybtex.database.Person(u'Ruckenstein, Eli')
                 ]
             },
         )
     })
     style = pybtex.plugin.find_plugin('pybtex.style.formatting', 'plain')()
     self.backend = Backend()
     entries = list(style.format_entries(six.itervalues(data.entries)))
     self.entry = entries[0]
     self.document = docutils.utils.new_document('test.rst')
Esempio n. 2
0
def test_citation_reference_use_label(entry, document):
    node = Backend().citation_reference(entry,
                                        document,
                                        use_key_as_label=False)
    assert str(node) == (
        '<citation_reference ids="id1" refname="hongquin1997">'
        '1'
        '</citation_reference>')
Esempio n. 3
0
def test_footnote(entry, document):
    node = Backend().footnote(entry, document)
    assert str(node) == (
        '<footnote auto="1" ids="hongquin1997" names="hongquin1997">'
        '<paragraph>'
        'Hongquin Liu and Eli Ruckenstein. '
        'Predicting the diffusion coefficient in supercritical fluids. '
        '<emphasis>Ind. Eng. Chem. Res.</emphasis>, '
        '36:888–895, 1997.'
        '</paragraph>'
        '</footnote>')
Esempio n. 4
0
def test_citation_use_label(entry, document):
    node = Backend().citation(entry, document, use_key_as_label=False)
    assert str(node) == (
        '<citation ids="hongquin1997" names="hongquin1997">'
        '<label>1</label>'
        '<paragraph>'
        'Hongquin Liu and Eli Ruckenstein. '
        'Predicting the diffusion coefficient in supercritical fluids. '
        '<emphasis>Ind. Eng. Chem. Res.</emphasis>, '
        '36:888–895, 1997.'
        '</paragraph>'
        '</citation>')
 def setUp(self):
     data = pybtex.database.BibliographyData({
         'hongquin1997': pybtex.database.Entry(
             'article',
             fields={
                 'language': u'english',
                 'title': u'Predicting the Diffusion Coefficient in Supercritical Fluids',
                 'journal': u'Ind. Eng. Chem. Res.',
                 'volume': u'36',
                 'year': u'1997',
                 'pages': u'888-895',
             },
             persons={'author': [
                 pybtex.database.Person(u'Liu, Hongquin'),
                 pybtex.database.Person(u'Ruckenstein, Eli')]},
             )})
     style = pybtex.plugin.find_plugin('pybtex.style.formatting', 'plain')()
     self.backend = Backend()
     entries = list(style.format_entries(six.itervalues(data.entries)))
     self.entry = entries[0]
     self.document = docutils.utils.new_document('test.rst')
Esempio n. 6
0
def test_write_entry():
    with pytest.raises(NotImplementedError):
        Backend().write_entry(None, None, None)
Esempio n. 7
0
def test_footnote_reference(entry, document):
    node = Backend().footnote_reference(entry, document)
    assert str(node) == ('<footnote_reference auto="1" ids="[\'id1\']" '
                         'refname="hongquin1997"/>')
Esempio n. 8
0
def test_text():
    assert Backend().format_text('hi') == Backend().format_str('hi')
Esempio n. 9
0
def test_citation_reference(entry, document):
    node = Backend().citation_reference(entry, document)
    assert str(node) == (
        '<citation_reference ids="id1" refname="hongquin1997">'
        'hongquin1997'
        '</citation_reference>')
Esempio n. 10
0
def render_str(richtext):
    return "".join(str(node) for node in richtext.render(Backend()))
Esempio n. 11
0
class TestCitation(TestCase):
    def setUp(self):
        data = pybtex.database.BibliographyData({
            'hongquin1997':
            pybtex.database.Entry(
                'article',
                fields={
                    'language': u'english',
                    'title':
                    u'Predicting the Diffusion Coefficient in Supercritical Fluids',
                    'journal': u'Ind. Eng. Chem. Res.',
                    'volume': u'36',
                    'year': u'1997',
                    'pages': u'888-895',
                },
                persons={
                    'author': [
                        pybtex.database.Person(u'Liu, Hongquin'),
                        pybtex.database.Person(u'Ruckenstein, Eli')
                    ]
                },
            )
        })
        style = pybtex.plugin.find_plugin('pybtex.style.formatting', 'plain')()
        self.backend = Backend()
        entries = list(style.format_entries(six.itervalues(data.entries)))
        self.entry = entries[0]
        self.document = docutils.utils.new_document('test.rst')

    def test_citation(self):
        node = self.backend.citation(self.entry, self.document)
        nose.tools.assert_equal(
            six.text_type(node),
            u'<citation ids="hongquin1997" names="hongquin1997">'
            u'<label>hongquin1997</label>'
            u'<paragraph>'
            u'Hongquin Liu and Eli Ruckenstein. '
            u'Predicting the diffusion coefficient in supercritical fluids. '
            u'<emphasis>Ind. Eng. Chem. Res.</emphasis>, '
            u'36:888–895, 1997.'
            u'</paragraph>'
            u'</citation>')

    def test_citation_reference(self):
        node = self.backend.citation_reference(self.entry, self.document)
        nose.tools.assert_equal(
            str(node), '<citation_reference ids="id1" refname="hongquin1997">'
            'hongquin1997'
            '</citation_reference>')

    def test_citation_use_label(self):
        node = self.backend.citation(self.entry,
                                     self.document,
                                     use_key_as_label=False)
        nose.tools.assert_equal(
            six.text_type(node),
            u'<citation ids="hongquin1997" names="hongquin1997">'
            u'<label>1</label>'
            u'<paragraph>'
            u'Hongquin Liu and Eli Ruckenstein. '
            u'Predicting the diffusion coefficient in supercritical fluids. '
            u'<emphasis>Ind. Eng. Chem. Res.</emphasis>, '
            u'36:888–895, 1997.'
            u'</paragraph>'
            u'</citation>')

    def test_citation_reference_use_label(self):
        node = self.backend.citation_reference(self.entry,
                                               self.document,
                                               use_key_as_label=False)
        nose.tools.assert_equal(
            str(node), '<citation_reference ids="id1" refname="hongquin1997">'
            '1'
            '</citation_reference>')

    def tearDown(self):
        del self.backend
        del self.entry
        del self.document
Esempio n. 12
0
def test_text():
    nose.tools.assert_equal(Backend().format_text('hi'),
                            Backend().format_str('hi'))
Esempio n. 13
0
def test_write_entry():
    Backend().write_entry(None, None, None)
Esempio n. 14
0
class TestCitation(TestCase):

    def setUp(self):
        data = pybtex.database.BibliographyData({
            'hongquin1997': pybtex.database.Entry(
                'article',
                fields={
                    'language': u'english',
                    'title': u'Predicting the Diffusion Coefficient in Supercritical Fluids',
                    'journal': u'Ind. Eng. Chem. Res.',
                    'volume': u'36',
                    'year': u'1997',
                    'pages': u'888-895',
                },
                persons={'author': [
                    pybtex.database.Person(u'Liu, Hongquin'),
                    pybtex.database.Person(u'Ruckenstein, Eli')]},
                )})
        style = pybtex.plugin.find_plugin('pybtex.style.formatting', 'plain')()
        self.backend = Backend()
        entries = list(style.format_entries(six.itervalues(data.entries)))
        self.entry = entries[0]
        self.document = docutils.utils.new_document('test.rst')

    def test_citation(self):
        node = self.backend.citation(self.entry, self.document)
        nose.tools.assert_equal(
            six.text_type(node),
            u'<citation ids="hongquin1997" names="hongquin1997">'
            u'<label>hongquin1997</label>'
            u'<paragraph>'
            u'Hongquin Liu and Eli Ruckenstein. '
            u'Predicting the diffusion coefficient in supercritical fluids. '
            u'<emphasis>Ind. Eng. Chem. Res.</emphasis>, '
            u'36:888–895, 1997.'
            u'</paragraph>'
            u'</citation>')

    def test_citation_reference(self):
        node = self.backend.citation_reference(self.entry, self.document)
        nose.tools.assert_equal(
            str(node),
            '<citation_reference ids="id1" refname="hongquin1997">'
            'hongquin1997'
            '</citation_reference>')

    def test_citation_use_label(self):
        node = self.backend.citation(
            self.entry, self.document, use_key_as_label=False)
        nose.tools.assert_equal(
            six.text_type(node),
            u'<citation ids="hongquin1997" names="hongquin1997">'
            u'<label>1</label>'
            u'<paragraph>'
            u'Hongquin Liu and Eli Ruckenstein. '
            u'Predicting the diffusion coefficient in supercritical fluids. '
            u'<emphasis>Ind. Eng. Chem. Res.</emphasis>, '
            u'36:888–895, 1997.'
            u'</paragraph>'
            u'</citation>')

    def test_citation_reference_use_label(self):
        node = self.backend.citation_reference(
            self.entry, self.document, use_key_as_label=False)
        nose.tools.assert_equal(
            str(node),
            '<citation_reference ids="id1" refname="hongquin1997">'
            '1'
            '</citation_reference>')

    def tearDown(self):
        del self.backend
        del self.entry
        del self.document