updated test_usecase + fixed bug in import_cmd
This commit is contained in:
parent
810525b4d0
commit
9243859294
@ -59,7 +59,7 @@ def many_from_path(bibpath):
|
|||||||
bibdata.entries[k] = b.entries[k]
|
bibdata.entries[k] = b.entries[k]
|
||||||
|
|
||||||
papers[k] = Paper(bibdata, citekey=k)
|
papers[k] = Paper(bibdata, citekey=k)
|
||||||
p.added = datetime.datetime.now()
|
papers[k].added = datetime.datetime.now()
|
||||||
except ValueError, e:
|
except ValueError, e:
|
||||||
papers[k] = e
|
papers[k] = e
|
||||||
return papers
|
return papers
|
||||||
@ -95,7 +95,7 @@ def command(args):
|
|||||||
copy_doc = config().import_copy
|
copy_doc = config().import_copy
|
||||||
if copy_doc:
|
if copy_doc:
|
||||||
docfile = rp.databroker.copy_doc(p.citekey, docfile)
|
docfile = rp.databroker.copy_doc(p.citekey, docfile)
|
||||||
|
|
||||||
p.docpath = docfile
|
p.docpath = docfile
|
||||||
rp.push_paper(p)
|
rp.push_paper(p)
|
||||||
ui.print_('{} imported'.format(color.dye(p.citekey, color.cyan)))
|
ui.print_('{} imported'.format(color.dye(p.citekey, color.cyan)))
|
||||||
|
@ -93,6 +93,7 @@ bibtex_raw0 = """@techreport{
|
|||||||
month = "November",
|
month = "November",
|
||||||
note = "Previous number = SIDL-WP-1999-0120",
|
note = "Previous number = SIDL-WP-1999-0120",
|
||||||
year = "1999",
|
year = "1999",
|
||||||
|
type = "Technical Report",
|
||||||
institution = "Stanford InfoLab"
|
institution = "Stanford InfoLab"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,9 +6,11 @@ import testenv
|
|||||||
import fake_env
|
import fake_env
|
||||||
|
|
||||||
from pubs import pubs_cmd
|
from pubs import pubs_cmd
|
||||||
from pubs import color, content, filebroker, uis, beets_ui, p3
|
from pubs import color, content, filebroker, uis, beets_ui, p3, endecoder
|
||||||
|
|
||||||
import str_fixtures
|
import str_fixtures
|
||||||
|
import fixtures
|
||||||
|
|
||||||
|
|
||||||
from pubs.commands import init_cmd, import_cmd
|
from pubs.commands import init_cmd, import_cmd
|
||||||
|
|
||||||
@ -33,7 +35,7 @@ class TestFakeInput(unittest.TestCase):
|
|||||||
color.input()
|
color.input()
|
||||||
|
|
||||||
def test_editor_input(self):
|
def test_editor_input(self):
|
||||||
other_input = fake_env.FakeInput(['yes', 'no'],
|
other_input = fake_env.FakeInput(['yes', 'no'],
|
||||||
module_list=[content, color])
|
module_list=[content, color])
|
||||||
other_input.as_global()
|
other_input.as_global()
|
||||||
self.assertEqual(content.editor_input(), 'yes')
|
self.assertEqual(content.editor_input(), 'yes')
|
||||||
@ -112,13 +114,13 @@ class TestAdd(DataCommandTestCase):
|
|||||||
|
|
||||||
def test_add(self):
|
def test_add(self):
|
||||||
cmds = ['pubs init',
|
cmds = ['pubs init',
|
||||||
'pubs add -b /data/pagerank.bib -d /data/pagerank.pdf',
|
'pubs add /data/pagerank.bib -d /data/pagerank.pdf',
|
||||||
]
|
]
|
||||||
self.execute_cmds(cmds)
|
self.execute_cmds(cmds)
|
||||||
|
|
||||||
def test_add2(self):
|
def test_add2(self):
|
||||||
cmds = ['pubs init -p /not_default',
|
cmds = ['pubs init -p /not_default',
|
||||||
'pubs add -b /data/pagerank.bib -d /data/pagerank.pdf',
|
'pubs add /data/pagerank.bib -d /data/pagerank.pdf',
|
||||||
]
|
]
|
||||||
self.execute_cmds(cmds)
|
self.execute_cmds(cmds)
|
||||||
self.assertEqual(set(self.fs['os'].listdir('/not_default/doc')), {'Page99.pdf'})
|
self.assertEqual(set(self.fs['os'].listdir('/not_default/doc')), {'Page99.pdf'})
|
||||||
@ -129,7 +131,7 @@ class TestList(DataCommandTestCase):
|
|||||||
def test_list(self):
|
def test_list(self):
|
||||||
cmds = ['pubs init -p /not_default2',
|
cmds = ['pubs init -p /not_default2',
|
||||||
'pubs list',
|
'pubs list',
|
||||||
'pubs add -b /data/pagerank.bib -d /data/pagerank.pdf',
|
'pubs add /data/pagerank.bib -d /data/pagerank.pdf',
|
||||||
'pubs list',
|
'pubs list',
|
||||||
]
|
]
|
||||||
self.execute_cmds(cmds)
|
self.execute_cmds(cmds)
|
||||||
@ -177,7 +179,7 @@ class TestUsecase(DataCommandTestCase):
|
|||||||
]
|
]
|
||||||
|
|
||||||
cmds = ['pubs init -p paper_first/',
|
cmds = ['pubs init -p paper_first/',
|
||||||
'pubs add -d data/pagerank.pdf -b data/pagerank.bib',
|
'pubs add -d data/pagerank.pdf data/pagerank.bib',
|
||||||
'pubs list',
|
'pubs list',
|
||||||
'pubs tag',
|
'pubs tag',
|
||||||
'pubs tag Page99 network+search',
|
'pubs tag Page99 network+search',
|
||||||
@ -189,10 +191,10 @@ class TestUsecase(DataCommandTestCase):
|
|||||||
|
|
||||||
def test_second(self):
|
def test_second(self):
|
||||||
cmds = ['pubs init -p paper_second/',
|
cmds = ['pubs init -p paper_second/',
|
||||||
'pubs add -b data/pagerank.bib',
|
'pubs add data/pagerank.bib',
|
||||||
'pubs add -d data/turing-mind-1950.pdf -b data/turing1950.bib',
|
'pubs add -d data/turing-mind-1950.pdf data/turing1950.bib',
|
||||||
'pubs add -b data/martius.bib',
|
'pubs add data/martius.bib',
|
||||||
'pubs add -b data/10.1371%2Fjournal.pone.0038236.bib',
|
'pubs add data/10.1371%2Fjournal.pone.0038236.bib',
|
||||||
'pubs list',
|
'pubs list',
|
||||||
'pubs attach Page99 data/pagerank.pdf'
|
'pubs attach Page99 data/pagerank.pdf'
|
||||||
]
|
]
|
||||||
@ -200,10 +202,10 @@ class TestUsecase(DataCommandTestCase):
|
|||||||
|
|
||||||
def test_third(self):
|
def test_third(self):
|
||||||
cmds = ['pubs init',
|
cmds = ['pubs init',
|
||||||
'pubs add -b data/pagerank.bib',
|
'pubs add data/pagerank.bib',
|
||||||
'pubs add -d data/turing-mind-1950.pdf -b data/turing1950.bib',
|
'pubs add -d data/turing-mind-1950.pdf data/turing1950.bib',
|
||||||
'pubs add -b data/martius.bib',
|
'pubs add data/martius.bib',
|
||||||
'pubs add -b data/10.1371%2Fjournal.pone.0038236.bib',
|
'pubs add data/10.1371%2Fjournal.pone.0038236.bib',
|
||||||
'pubs list',
|
'pubs list',
|
||||||
'pubs attach Page99 data/pagerank.pdf',
|
'pubs attach Page99 data/pagerank.pdf',
|
||||||
('pubs remove Page99', ['y']),
|
('pubs remove Page99', ['y']),
|
||||||
@ -216,7 +218,7 @@ class TestUsecase(DataCommandTestCase):
|
|||||||
cmds = ['pubs init',
|
cmds = ['pubs init',
|
||||||
('pubs add', ['abc', 'n']),
|
('pubs add', ['abc', 'n']),
|
||||||
('pubs add', ['abc', 'y', 'abc', 'n']),
|
('pubs add', ['abc', 'y', 'abc', 'n']),
|
||||||
'pubs add -b data/pagerank.bib',
|
'pubs add data/pagerank.bib',
|
||||||
('pubs edit Page99', ['', 'a']),
|
('pubs edit Page99', ['', 'a']),
|
||||||
]
|
]
|
||||||
self.execute_cmds(cmds)
|
self.execute_cmds(cmds)
|
||||||
@ -240,7 +242,7 @@ class TestUsecase(DataCommandTestCase):
|
|||||||
line3 = re.sub('Page99', 'Ridge07', line2)
|
line3 = re.sub('Page99', 'Ridge07', line2)
|
||||||
|
|
||||||
cmds = ['pubs init',
|
cmds = ['pubs init',
|
||||||
'pubs add -b data/pagerank.bib',
|
'pubs add data/pagerank.bib',
|
||||||
('pubs list', [], line),
|
('pubs list', [], line),
|
||||||
('pubs edit Page99', [bib1]),
|
('pubs edit Page99', [bib1]),
|
||||||
('pubs list', [], line1),
|
('pubs list', [], line1),
|
||||||
@ -256,11 +258,12 @@ class TestUsecase(DataCommandTestCase):
|
|||||||
cmds = ['pubs init',
|
cmds = ['pubs init',
|
||||||
('pubs add', [str_fixtures.bibtex_external0]),
|
('pubs add', [str_fixtures.bibtex_external0]),
|
||||||
'pubs export Page99',
|
'pubs export Page99',
|
||||||
('pubs export Page99 -f bibtex', [], str_fixtures.bibtex_raw0),
|
('pubs export Page99 -f bibtex', []),
|
||||||
'pubs export Page99 -f bibyaml',
|
'pubs export Page99 -f bibyaml',
|
||||||
]
|
]
|
||||||
|
|
||||||
self.execute_cmds(cmds)
|
outs = self.execute_cmds(cmds)
|
||||||
|
self.assertEqual(endecoder.EnDecoder().decode_bibdata(outs[3]), fixtures.page_bibdata)
|
||||||
|
|
||||||
def test_import(self):
|
def test_import(self):
|
||||||
cmds = ['pubs init',
|
cmds = ['pubs init',
|
||||||
@ -282,7 +285,7 @@ class TestUsecase(DataCommandTestCase):
|
|||||||
|
|
||||||
def test_open(self):
|
def test_open(self):
|
||||||
cmds = ['pubs init',
|
cmds = ['pubs init',
|
||||||
'pubs add -b data/pagerank.bib',
|
'pubs add data/pagerank.bib',
|
||||||
'pubs open Page99'
|
'pubs open Page99'
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -295,7 +298,7 @@ class TestUsecase(DataCommandTestCase):
|
|||||||
|
|
||||||
def test_update(self):
|
def test_update(self):
|
||||||
cmds = ['pubs init',
|
cmds = ['pubs init',
|
||||||
'pubs add -b data/pagerank.bib',
|
'pubs add data/pagerank.bib',
|
||||||
'pubs update'
|
'pubs update'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user