def test_existing_data(self): ende = endecoder.EnDecoder() page99_bibentry = ende.decode_bibdata(str_fixtures.bibtex_raw0) for db_class in [databroker.DataBroker, datacache.DataCache]: self.reset_fs() fake_env.copy_dir( self.fs, os.path.join(os.path.dirname(__file__), 'testrepo'), 'repo') db = db_class('repo', 'repo/doc', create=False) self.assertEqual(db.pull_bibentry('Page99'), page99_bibentry) for citekey in [ '10.1371_journal.pone.0038236', '10.1371journal.pone.0063400', 'journal0063400' ]: db.pull_bibentry(citekey) db.pull_metadata(citekey) with self.assertRaises(IOError): db.pull_bibentry('citekey') with self.assertRaises(IOError): db.pull_metadata('citekey') db.add_doc('Larry99', 'docsdir://Page99.pdf') self.assertTrue( content.check_file('repo/doc/Page99.pdf', fail=False)) self.assertTrue( content.check_file('repo/doc/Larry99.pdf', fail=False)) db.remove_doc('docsdir://Page99.pdf')
def test_existing_data(self): ende = endecoder.EnDecoder() page99_bibentry = ende.decode_bibdata(str_fixtures.bibtex_raw0) for db_class in [databroker.DataBroker, datacache.DataCache]: self.fs = fake_env.create_fake_fs([content, filebroker]) fake_env.copy_dir(self.fs, os.path.join(os.path.dirname(__file__), 'testrepo'), 'repo') db = db_class('repo', create=False) self.assertEqual(db.pull_bibentry('Page99'), page99_bibentry) for citekey in ['10.1371_journal.pone.0038236', '10.1371journal.pone.0063400', 'journal0063400']: db.pull_bibentry(citekey) db.pull_metadata(citekey) with self.assertRaises(IOError): db.pull_bibentry('citekey') with self.assertRaises(IOError): db.pull_metadata('citekey') db.add_doc('Larry99', 'docsdir://Page99.pdf') self.assertTrue(content.check_file('repo/doc/Page99.pdf', fail=False)) self.assertTrue(content.check_file('repo/doc/Larry99.pdf', fail=False)) db.remove_doc('docsdir://Page99.pdf') fake_env.unset_fake_fs([content, filebroker])
def setUp(self, nsec_stat=True): super(DataCommandTestCase, self).setUp(nsec_stat=nsec_stat) fake_env.copy_dir(self.fs, os.path.join(os.path.dirname(__file__), 'data'), 'data') fake_env.copy_dir( self.fs, os.path.join(os.path.dirname(__file__), 'bibexamples'), 'bibexamples')
def test_existing_data(self): fake_env.copy_dir(self.fs, os.path.join(os.path.dirname(__file__), 'testrepo'), 'testrepo') fb = filebroker.FileBroker('testrepo', create = True) bib_content = content.read_text_file('testrepo/bib/Page99.bib') self.assertEqual(fb.pull_bibfile('Page99'), bib_content) meta_content = content.read_text_file('testrepo/meta/Page99.yaml') self.assertEqual(fb.pull_metafile('Page99'), meta_content)
def test_existing_data(self): fake_env.copy_dir(self.fs, os.path.join(os.path.dirname(__file__), 'testrepo'), 'testrepo') fb = filebroker.FileBroker('testrepo', create=True) bib_content = content.read_text_file('testrepo/bib/Page99.bib') self.assertEqual(fb.pull_bibfile('Page99'), bib_content) meta_content = content.read_text_file('testrepo/meta/Page99.yaml') self.assertEqual(fb.pull_metafile('Page99'), meta_content)
def test_doccopy(self): fake_env.copy_dir(self.fs, os.path.join(os.path.dirname(__file__), 'data'), 'data') fb = filebroker.FileBroker('testrepo', create = True) docb = filebroker.DocBroker('testrepo') docpath = docb.add_doc('Page99', 'data/pagerank.pdf') self.assertTrue(content.check_file(os.path.join('testrepo', 'doc/Page99.pdf'))) self.assertTrue(docb.in_docsdir(docpath)) self.assertEqual(docpath, 'docsdir://Page99.pdf') docb.remove_doc('docsdir://Page99.pdf') self.assertFalse(content.check_file(os.path.join('testrepo', 'doc/Page99.pdf'), fail=False)) with self.assertRaises(IOError): self.assertFalse(content.check_file(os.path.join('testrepo', 'doc/Page99.pdf'), fail=True))
def test_list_several_no_date(self): self.execute_cmds(['pubs init -p /testrepo']) shutil.rmtree('testrepo') testrepo = os.path.join(os.path.dirname(__file__), 'testrepo') fake_env.copy_dir(self.fs, testrepo, 'testrepo') cmds = ['pubs list', 'pubs remove -f Page99', 'pubs list', 'pubs add /data/pagerank.bib -d /data/pagerank.pdf', 'pubs list', ] outs = self.execute_cmds(cmds) self.assertEqual(4, len(outs[0].splitlines())) self.assertEqual(3, len(outs[2].splitlines())) self.assertEqual(4, len(outs[4].splitlines())) # Last added should be last self.assertEqual('[Page99]', outs[4].splitlines()[-1][:8])
def test_list_several_no_date(self): self.execute_cmds(['pubs init -p /testrepo']) shutil.rmtree('testrepo') testrepo = os.path.join(os.path.dirname(__file__), 'testrepo') fake_env.copy_dir(self.fs, testrepo, 'testrepo') cmds = [ 'pubs list', 'pubs remove -f Page99', 'pubs list', 'pubs add /data/pagerank.bib -d /data/pagerank.pdf', 'pubs list', ] outs = self.execute_cmds(cmds) self.assertEqual(4, len(outs[0].splitlines())) self.assertEqual(3, len(outs[2].splitlines())) self.assertEqual(4, len(outs[4].splitlines())) # Last added should be last self.assertEqual('[Page99]', outs[4].splitlines()[-1][:8])
def test_doccopy(self): fake_env.copy_dir(self.fs, os.path.join(os.path.dirname(__file__), 'data'), 'data') fb = filebroker.FileBroker('testrepo', create=True) docb = filebroker.DocBroker('testrepo') docpath = docb.add_doc('Page99', 'data/pagerank.pdf') self.assertTrue( content.check_file(os.path.join('testrepo', 'doc/Page99.pdf'))) self.assertTrue(docb.in_docsdir(docpath)) self.assertEqual(docpath, 'docsdir://Page99.pdf') docb.remove_doc('docsdir://Page99.pdf') self.assertFalse( content.check_file(os.path.join('testrepo', 'doc/Page99.pdf'), fail=False)) with self.assertRaises(IOError): self.assertFalse( content.check_file(os.path.join('testrepo', 'doc/Page99.pdf'), fail=True))
def setUp(self, nsec_stat=True): super(DataCommandTestCase, self).setUp(nsec_stat=nsec_stat) fake_env.copy_dir(self.fs, os.path.join(os.path.dirname(__file__), 'data'), 'data') fake_env.copy_dir(self.fs, os.path.join(os.path.dirname(__file__), 'bibexamples'), 'bibexamples')
def setUp(self): super(DataCommandTestCase, self).setUp() fake_env.copy_dir(self.fs, os.path.join(os.path.dirname(__file__), 'data'), 'data')
def setUp(self): CommandTestCase.setUp(self) fake_env.copy_dir(self.fs, os.path.join(os.path.dirname(__file__), 'data'), 'data')