First this brings a change to the paper API: the terminology of bibdata and bibentry is clarified: now bibentry is a dictionary of the form {citekey: bibdata} where bibdata corresponds to the actual dictionary of bibliographic fields and values {author: ..., year: ...}. Now bibentry is an attribute of the paper object that is generated from citekey and bibdata. This commit fixes all tests in particular an issue with citekey in bibentry not updated. Also removes prints in tests and deprecated assertEquals. Usecase tests now fail if the command ask for unexpected inputs. Removes queries for user input in attach and add commands (for deletion of a copied document file). The input was not coherent with tests and is annoying.
37 lines
983 B
Python
37 lines
983 B
Python
# -*- coding: utf-8 -*-
|
|
import os
|
|
import unittest
|
|
import copy
|
|
|
|
import dotdot
|
|
from pubs import bibstruct
|
|
|
|
import fixtures
|
|
|
|
|
|
class TestGenerateCitekey(unittest.TestCase):
|
|
|
|
def test_fails_on_empty_paper(self):
|
|
with self.assertRaises(ValueError):
|
|
bibstruct.generate_citekey(None)
|
|
|
|
def test_escapes_chars(self):
|
|
doe_bibentry = copy.deepcopy(fixtures.doe_bibentry)
|
|
citekey, bibdata = bibstruct.get_entry(doe_bibentry)
|
|
bibdata['author'] = [u'Zôu\\@/ , John']
|
|
key = bibstruct.generate_citekey(doe_bibentry)
|
|
self.assertEqual(key, 'Zou2013')
|
|
|
|
def test_simple(self):
|
|
bibentry = copy.deepcopy(fixtures.doe_bibentry)
|
|
key = bibstruct.generate_citekey(bibentry)
|
|
self.assertEqual(key, 'Doe2013')
|
|
|
|
bibentry = copy.deepcopy(fixtures.franny_bibentry)
|
|
key = bibstruct.generate_citekey(bibentry)
|
|
self.assertEqual(key, 'Salinger1961')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|