|
|
@ -437,6 +437,17 @@ class TestAdd(URLContentTestCase):
|
|
|
|
self.execute_cmds(cmds)
|
|
|
|
self.execute_cmds(cmds)
|
|
|
|
self.assertEqual(cm.exception.code, 1)
|
|
|
|
self.assertEqual(cm.exception.code, 1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_add_excludes_bibtex_fields(self):
|
|
|
|
|
|
|
|
self.execute_cmds(['pubs init'])
|
|
|
|
|
|
|
|
config = conf.load_conf()
|
|
|
|
|
|
|
|
config['main']['bibtex_field_excludes'] = ['abstract', 'publisher']
|
|
|
|
|
|
|
|
conf.save_conf(config)
|
|
|
|
|
|
|
|
self.execute_cmds(['pubs add data/pagerank.bib'])
|
|
|
|
|
|
|
|
with FakeFileOpen(self.fs)(self.default_pubs_dir + '/bib/Page99.bib', 'r') as buf:
|
|
|
|
|
|
|
|
out = endecoder.EnDecoder().decode_bibdata(buf.read())
|
|
|
|
|
|
|
|
for bib in out.values():
|
|
|
|
|
|
|
|
self.assertFalse('abstract' in bib or 'publisher' in bib)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestList(DataCommandTestCase):
|
|
|
|
class TestList(DataCommandTestCase):
|
|
|
|
|
|
|
|
|
|
|
@ -829,6 +840,21 @@ class TestUsecase(DataCommandTestCase):
|
|
|
|
]
|
|
|
|
]
|
|
|
|
self.execute_cmds(cmds)
|
|
|
|
self.execute_cmds(cmds)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_editor_excludes_bibtex_field(self):
|
|
|
|
|
|
|
|
cmds = ['pubs init',
|
|
|
|
|
|
|
|
'pubs add data/pagerank.bib',
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
self.execute_cmds(cmds)
|
|
|
|
|
|
|
|
config = conf.load_conf()
|
|
|
|
|
|
|
|
config['main']['bibtex_field_excludes'] = ['author']
|
|
|
|
|
|
|
|
conf.save_conf(config)
|
|
|
|
|
|
|
|
cmds = [('pubs edit Page99', ['@misc{Page99, title="TTT", author="auth"}', 'n'])]
|
|
|
|
|
|
|
|
self.execute_cmds(cmds)
|
|
|
|
|
|
|
|
with FakeFileOpen(self.fs)(self.default_pubs_dir + '/bib/Page99.bib', 'r') as buf:
|
|
|
|
|
|
|
|
out = endecoder.EnDecoder().decode_bibdata(buf.read())
|
|
|
|
|
|
|
|
for bib in out.values():
|
|
|
|
|
|
|
|
self.assertFalse('author' in bib)
|
|
|
|
|
|
|
|
|
|
|
|
def test_add_aborts(self):
|
|
|
|
def test_add_aborts(self):
|
|
|
|
with self.assertRaises(FakeSystemExit):
|
|
|
|
with self.assertRaises(FakeSystemExit):
|
|
|
|
cmds = ['pubs init',
|
|
|
|
cmds = ['pubs init',
|
|
|
@ -908,6 +934,18 @@ class TestUsecase(DataCommandTestCase):
|
|
|
|
fixtures.page_bibentry, ignore_fields=['author', 'title'])
|
|
|
|
fixtures.page_bibentry, ignore_fields=['author', 'title'])
|
|
|
|
self.assertEqual(outs[2], expected + os.linesep)
|
|
|
|
self.assertEqual(outs[2], expected + os.linesep)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_export_excludes_bibtex_field(self):
|
|
|
|
|
|
|
|
cmds = ['pubs init',
|
|
|
|
|
|
|
|
'pubs add data/pagerank.bib'
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
self.execute_cmds(cmds)
|
|
|
|
|
|
|
|
config = conf.load_conf()
|
|
|
|
|
|
|
|
config['main']['bibtex_field_excludes'] = ['url']
|
|
|
|
|
|
|
|
conf.save_conf(config)
|
|
|
|
|
|
|
|
outs = self.execute_cmds(['pubs export Page99'])
|
|
|
|
|
|
|
|
for bib in endecoder.EnDecoder().decode_bibdata(outs[0]).values():
|
|
|
|
|
|
|
|
self.assertFalse('url' in bib)
|
|
|
|
|
|
|
|
|
|
|
|
def test_import(self):
|
|
|
|
def test_import(self):
|
|
|
|
cmds = ['pubs init',
|
|
|
|
cmds = ['pubs init',
|
|
|
|
'pubs import data/',
|
|
|
|
'pubs import data/',
|
|
|
@ -970,6 +1008,17 @@ class TestUsecase(DataCommandTestCase):
|
|
|
|
outs = self.execute_cmds(cmds)
|
|
|
|
outs = self.execute_cmds(cmds)
|
|
|
|
self.assertEqual(1 + 1, len(outs[-1].split('\n')))
|
|
|
|
self.assertEqual(1 + 1, len(outs[-1].split('\n')))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_import_excludes_bibtex_field(self):
|
|
|
|
|
|
|
|
self.execute_cmds(['pubs init'])
|
|
|
|
|
|
|
|
config = conf.load_conf()
|
|
|
|
|
|
|
|
config['main']['bibtex_field_excludes'] = ['abstract']
|
|
|
|
|
|
|
|
conf.save_conf(config)
|
|
|
|
|
|
|
|
self.execute_cmds(['pubs import data/ Page99'])
|
|
|
|
|
|
|
|
with FakeFileOpen(self.fs)(self.default_pubs_dir + '/bib/Page99.bib', 'r') as buf:
|
|
|
|
|
|
|
|
out = endecoder.EnDecoder().decode_bibdata(buf.read())
|
|
|
|
|
|
|
|
for bib in out.values():
|
|
|
|
|
|
|
|
self.assertFalse('abstract' in bib)
|
|
|
|
|
|
|
|
|
|
|
|
def test_update(self):
|
|
|
|
def test_update(self):
|
|
|
|
cmds = ['pubs init',
|
|
|
|
cmds = ['pubs init',
|
|
|
|
'pubs add data/pagerank.bib',
|
|
|
|
'pubs add data/pagerank.bib',
|
|
|
|