def test_organizeWithFiles(self): fields = DocumentFields() fields.setField("title", "document about internet") d = DocumentFolder() d.setDocFields(fields) bibfile = File("bibfile.bib") bibfile.createFile() pdffilename = "pdffile.pdf" pdffile = File(pdffilename) pdffile.createFile() fileList = [bibfile, pdffilename] d.create() d.organize(fileList) self.assertFalse(File("bibfile.bib").exists()) self.assertFalse(File("pdffile.pdf").exists()) folderPath = d.getDir().getPath().getAbsolutePath() newbibfile = File(folderPath + "/" + "bibfile.bib") newpdffile = File(folderPath + "/" + "pdffile.pdf") self.assertTrue(newbibfile.exists()) self.assertTrue(newpdffile.exists()) d.delete()
def folderName(self): a = DocumentFields() a.setField("title", "document") d = DocumentFolder() d.setDocFields(a) for i, title in enumerate(self.titles): a.setField("title", title) name = d.computeFolderName() assert(name == self.folderNames[i])
def organize(self): fields = DocumentFields() fields.setField("title", "document about internet") fields.setField("year", "2014") fields.setField("authors", "John Bruf, Tommy Bamo") fields.setField("keywords", "Computer science, Photography") fields.setField("journal", "Journal of Computer Science") dir = Directory("document_about_internet") dir.removeDir() d = DocumentFolder() d.setDocFields(fields) d.create() assert(not d.hasVideoFolder()) assert(not d.hasImageFolder()) assert(not d.hasNotesFolder()) assert(not d.hasDescFolder()) d.organize() assert(d.hasVideoFolder()) assert(d.hasImageFolder()) assert(d.hasNotesFolder()) assert(d.hasDescFolder()) notesPath = d.getNotesFilePath() print notesPath assert(File(notesPath).exists()) d.delete()
def internFolders(self): a = DocumentFields() a.setField("title", "document") d = DocumentFolder() d.setDocFields(a) d.create() assert(d.getDir().exists()) assert(not d.hasVideoFolder()) assert(not d.hasImageFolder()) assert(not d.hasNotesFolder()) assert(not d.hasDescFolder()) d.createVideoFolder() d.createImageFolder() d.createNotesFolder() d.createDescFolder() assert(d.hasVideoFolder()) assert(d.hasImageFolder()) assert(d.hasNotesFolder()) assert(d.hasDescFolder()) d.delete()
def create(self): a = DocumentFields() a.setField("title", "document") d = DocumentFolder() d.setDocFields(a) for title in self.titles: a.setField("title", title) d.create() assert(d.getDir().exists()) d.delete() assert(not d.getDir().exists()) dir = Directory("documents") dir.createDir() for title in self.titles: a.setField("title", title) d.create(dir.getPath().getAbsolutePath()) assert(d.getDir().exists()) d.delete() assert(not d.getDir().exists()) dir.removeDir()
def test_create(self): a = DocumentFields() a.setField("title", "document") d = DocumentFolder() d.setDocFields(a) # Creation in local folder for title in self.titles: a.setField("title", title) d.create() self.assertTrue(d.getDir().exists()) d.delete() self.assertFalse(d.getDir().exists()) dir = Directory("documents") dir.createDir() # Creaton in another folder for title in self.titles: a.setField("title", title) d.create(dir.getPath().getAbsolutePath()) self.assertTrue(d.getDir().exists()) d.delete() self.assertFalse(d.getDir().exists()) dir.removeDir()