parent
dbb17426d0
commit
0b1a351485
@ -1,24 +1,47 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from pybtex.database import Person
|
from pybtex.database import Person
|
||||||
|
|
||||||
import testenv
|
import testenv
|
||||||
from pubs import endecoder
|
from pubs import endecoder
|
||||||
import str_fixtures
|
import str_fixtures
|
||||||
|
|
||||||
turing1950 = Paper()
|
coder = endecoder.EnDecoder()
|
||||||
turing1950.bibentry.fields['title'] = u'Computing machinery and intelligence.'
|
|
||||||
turing1950.bibentry.fields['year'] = u'1950'
|
franny_bib = """
|
||||||
turing1950.bibentry.persons['author'] = [Person(u'Alan Turing')]
|
@article{
|
||||||
turing1950.citekey = turing1950.generate_citekey()
|
Franny1961,
|
||||||
turing1950.tags = ['computer', 'AI']
|
author = "Salinger, J. D.",
|
||||||
|
title = "Franny and Zooey",
|
||||||
|
year = "1961",
|
||||||
|
}
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
doe_bib = """
|
||||||
|
@article{
|
||||||
|
Doe2013,
|
||||||
|
author = "Doe, John",
|
||||||
|
title = "Nice Title",
|
||||||
|
year = "2013",
|
||||||
|
}
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
franny_bibdata = coder.decode_bibdata(franny_bib)
|
||||||
|
doe_bibdata = coder.decode_bibdata(doe_bib)
|
||||||
|
|
||||||
|
|
||||||
|
# bibdata = coder.decode_bibdata(str_fixtures.bibtex_external0, fmt='bibtex')
|
||||||
|
# page99 = Paper(bibdata)
|
||||||
|
|
||||||
|
|
||||||
doe2013 = Paper()
|
|
||||||
doe2013.bibentry.fields['title'] = u'Nice title.'
|
|
||||||
doe2013.bibentry.fields['year'] = u'2013'
|
|
||||||
doe2013.bibentry.persons['author'] = [Person(u'John Doe')]
|
|
||||||
doe2013.citekey = doe2013.generate_citekey()
|
|
||||||
|
|
||||||
coder = endecoder.EnDecoder()
|
|
||||||
bibdata = coder.decode_bibdata(str_fixtures.bibtex_external0, fmt='bibtex')
|
|
||||||
page99 = Paper(bibdata)
|
|
||||||
|
|
||||||
|
# turing1950 = Paper()
|
||||||
|
# turing1950.bibentry.fields['title'] = u'Computing machinery and intelligence.'
|
||||||
|
# turing1950.bibentry.fields['year'] = u'1950'
|
||||||
|
# turing1950.bibentry.persons['author'] = [Person(u'Alan Turing')]
|
||||||
|
# turing1950.citekey = turing1950.generate_citekey()
|
||||||
|
# turing1950.tags = ['computer', 'AI']
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import os
|
||||||
|
import unittest
|
||||||
|
import copy
|
||||||
|
|
||||||
|
from pybtex.database import Person
|
||||||
|
|
||||||
|
import testenv
|
||||||
|
from pubs import bibstruct
|
||||||
|
|
||||||
|
import fixtures
|
||||||
|
|
||||||
|
|
||||||
|
class TestGenerateCitekey(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_escapes_chars(self):
|
||||||
|
doe_bibdata = copy.deepcopy(fixtures.doe_bibdata)
|
||||||
|
citekey, entry = bibstruct.get_entry(doe_bibdata)
|
||||||
|
entry.persons['author'] = [Person(string=u'Zôu\\@/ , John')]
|
||||||
|
key = bibstruct.generate_citekey(doe_bibdata)
|
||||||
|
|
||||||
|
def test_simple(self):
|
||||||
|
bibdata = copy.deepcopy(fixtures.doe_bibdata)
|
||||||
|
key = bibstruct.generate_citekey(bibdata)
|
||||||
|
self.assertEqual(key, 'Doe2013')
|
||||||
|
|
||||||
|
bibdata = copy.deepcopy(fixtures.franny_bibdata)
|
||||||
|
key = bibstruct.generate_citekey(bibdata)
|
||||||
|
self.assertEqual(key, 'Salinger1961')
|
Loading…
Reference in new issue