diff --git a/README.md b/README.md index 10c3b4a..c10746d 100644 --- a/README.md +++ b/README.md @@ -142,13 +142,13 @@ Here are some sources of inspirations for this project : A list of ideas and TODO. Don't hesitate to give feedback on the ones you really want or to propose your owns. +0. Add book 60. Unittest 80. Search engine 85. Anti-duplicate ? 90. Look for published version in arXiv 95. No DOI for HAL => metadata with SOAP API… don't want to handle it for now :/ 200. Webserver interface ? GUI ? (not likely for now…) -300. Tree à la docear ? ## Thanks diff --git a/params.py.example b/params.py.example index 2d283fe..5003539 100644 --- a/params.py.example +++ b/params.py.example @@ -1,9 +1,11 @@ # -*- coding: utf8 -*- # The folder in which the papers should be stored -# /!\ Keep the trailing slash /!\ folder = "/home/phyks/Papers/" +if folder[-1] != '/': + folder = folder+'/' + # The various proxies available to retrieve the content proxies = [ '', diff --git a/tests/test_backend.py b/tests/test_backend.py index 79783ee..fd863eb 100644 --- a/tests/test_backend.py +++ b/tests/test_backend.py @@ -10,38 +10,103 @@ # ----------------------------------------------------------------------------- import unittest from backend import * +from bibtexparser.bparser import BibTexParser +import shutil +import tempfile class TestFetcher(unittest.TestCase): - def test_getNewName(self): - return + def setUp(self): + params.folder = tempfile.mkdtemp()+"/" + self.bibtex_article_string = """ +@article{1303.3130v1, + abstract={We study the role of the dipolar interaction, correctly accounting for the +Dipolar-Induced Resonance (DIR), in a quasi-one-dimensional system of ultracold +bosons. We first show how the DIR affects the lowest-energy states of two +particles in a harmonic trap. Then, we consider a deep optical lattice loaded +with ultracold dipolar bosons. We describe this many-body system using an +atom-dimer extended Bose-Hubbard model. We analyze the impact of the DIR on the +phase diagram at T=0 by exact diagonalization of a small-sized system. In +particular, the resonance strongly modifies the range of parameters for which a +mass density wave should occur.}, + archiveprefix={arXiv}, + author={N. Bartolo and D. J. Papoular and L. Barbiero and C. Menotti and A. Recati}, + eprint={1303.3130v1}, + file={/home/phyks/Papers/N_Bartolo_A_Recati-j-2013.pdf}, + link={http://arxiv.org/abs/1303.3130v1}, + month={Mar}, + primaryclass={cond-mat.quant-gas}, + tag={}, + title={Dipolar-Induced Resonance for Ultracold Bosons in a Quasi-1D Optical +Lattice}, + year={2013}, +}""" + self.bibtex_article = BibTexParser(self.bibtex_article_string).get_entry_dict() + self.bibtex_article = self.bibtex_article[self.bibtex_article.keys()[0]] + + self.bibtex_book_string = """ +""" + self.bibtex_book = BibTexParser(self.bibtex_book_string).get_entry_dict() + self.bibtex_book = self.bibtex_book[self.bibtex_book.keys()[0]] + + def test_getNewName_article(self): + self.assertEqual(getNewName("test.pdf", self.bibtex_article), + params.folder+"N_Bartolo_A_Recati-j-2013-v1.pdf") + + def test_getNewName_article_override(self): + self.assertEqual(getNewName("test.pdf", self.bibtex_article, override_format="%f"), + params.folder+"N_Bartolo.pdf") + + def test_getNewName_book(self): +# TODO + self.assertEqual(getNewName("test.pdf", self.bibtex_book), + params.folder+"") + + def test_getNewName_book_override(self): +# TODO + self.assertEqual(getNewName("test.pdf", self.bibtex_book, override_format="%a"), + params.folder+"N_Bartolo.pdf") def test_bibtexAppend(self): - return + bibtexAppend(self.bibtex) + with open(params.folder+'index.bib', 'r') as fh: + self.assertEqual(fh.read(), + '@article{1303.3130v1,\n\tabstract={We study the role of the dipolar interaction, correctly accounting for the\nDipolar-Induced Resonance (DIR), in a quasi-one-dimensional system of ultracold\nbosons. We first show how the DIR affects the lowest-energy states of two\nparticles in a harmonic trap. Then, we consider a deep optical lattice loaded\nwith ultracold dipolar bosons. We describe this many-body system using an\natom-dimer extended Bose-Hubbard model. We analyze the impact of the DIR on the\nphase diagram at T=0 by exact diagonalization of a small-sized system. In\nparticular, the resonance strongly modifies the range of parameters for which a\nmass density wave should occur.},\n\tarchiveprefix={arXiv},\n\tauthor={N. Bartolo and D. J. Papoular and L. Barbiero and C. Menotti and A. Recati},\n\teprint={1303.3130v1},\n\tfile={/home/phyks/Papers/N_Bartolo_A_Recati-j-2013.pdf},\n\tlink={http://arxiv.org/abs/1303.3130v1},\n\tmonth={Mar},\n\tprimaryclass={cond-mat.quant-gas},\n\ttag={},\n\ttitle={Dipolar-Induced Resonance for Ultracold Bosons in a Quasi-1D Optical\nLattice},\n\tyear={2013},\n}\n\n\n') def test_bibtexEdit(self): +# TODO return def test_bibtexRewrite(self): +# TODO return def test_deleteId(self): +# TODO return def test_deleteFile(self): +# TODO return def test_diffFilesIndex(self): +# TODO return def test_getBibtex(self): +# TODO return def test_getEntries(self): +# TODO return def test_updateArxiv(self): +# TODO return + def tearDown(self): + shutil.rmtree(params.folder) + if __name__ == '__main__': unittest.main()