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 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()
Пример #3
0
 def titleContent(self):
     d = DocumentFields()
     d.setField("title", "document about internet")
     notes = Notes(d)
     notes.createTitle()
     content = notes.getDocumentContent()
     expectedContent = "document about internet\n\n"
     # print content
     # print expectedContent
     assert(content == expectedContent)
    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])
Пример #5
0
 def titleContent(self):
     d = DocumentFields()
     d.setField("title", "document about internet")
     notes = LatexNotes(d)
     notes.createTitle()
     content = notes.getDocumentContent()
     expectedContent = LatexNotes.HEADER
     expectedContent += "\\title{document about internet}\n"
     expectedContent += "\\maketitle\n"
     expectedContent += "\n"
     expectedContent += "\\end{document}\n"
     # print content
     # print expectedContent
     assert(content == expectedContent)
 def test_changeField(self):
     a = DocumentFields()
     a.setField("title", "bc")
     a.setField("title", "Other")
     self.assertEqual (a.getNbFields(), 1)
     self.assertTrue(a.hasField("title"))
     self.assertEqual(a.getField("title"), "Other")
Пример #7
0
 def descTableYear(self):
     d = DocumentFields()
     d.setField("year", "2014")
     notes = Notes(d)
     notes.createDescriptionTable()
     content = notes.getDocumentContent()
     expectedContent = Notes.TABLE_HEADER
     expectedContent += "Annee = 2014\n"
     expectedContent += Notes.TABLE_END
     # contentLines = content.splitlines()
     # expLines = expectedContent.splitlines()
     # d = difflib.Differ()
     # diff = d.compare(contentLines, expLines)
     # print "\n".join(diff)
     assert(content == expectedContent)
Пример #8
0
 def descTableAuthors(self):
     d = DocumentFields()
     d.setField("author", "John Bruf, Tommy Bamo")
     notes = Notes(d)
     notes.createDescriptionTable()
     content = notes.getDocumentContent()
     expectedContent = Notes.TABLE_HEADER
     expectedContent += "Auteurs = John Bruf, Tommy Bamo\n"
     expectedContent += Notes.TABLE_END
     contentLines = content.splitlines()
     expLines = expectedContent.splitlines()
     d = difflib.Differ()
     diff = d.compare(contentLines, expLines)
     # print "\n".join(diff)
     assert(content == expectedContent)
Пример #9
0
 def descTableKeywords(self):
     d = DocumentFields()
     d.setField("keywords", "Computer science, Photography")
     notes = Notes(d)
     notes.createDescriptionTable()
     content = notes.getDocumentContent()
     expectedContent = Notes.TABLE_HEADER
     expectedContent += "Mots-cles = Computer science, Photography\n"
     expectedContent += Notes.TABLE_END
     # contentLines = content.splitlines()
     # expLines = expectedContent.splitlines()
     # d = difflib.Differ()
     # diff = d.compare(contentLines, expLines)
     # print "\n".join(diff)
     assert(content == expectedContent)
Пример #10
0
 def descTableJournal(self):
     d = DocumentFields()
     d.setField("journal", "Journal of Computer Science")
     notes = Notes(d)
     notes.createDescriptionTable()
     content = notes.getDocumentContent()
     expectedContent = Notes.TABLE_HEADER
     expectedContent += "Journal = Journal of Computer Science\n"
     expectedContent += Notes.TABLE_END
     # contentLines = content.splitlines()
     # expLines = expectedContent.splitlines()
     # d = difflib.Differ()
     # diff = d.compare(contentLines, expLines)
     # print "\n".join(diff)
     assert(content == expectedContent)
Пример #11
0
    def read(self):  
        fields = DocumentFields()
        with open(self.path.path) as bibtex_file:
            bibtex_str = bibtex_file.read()
                
        bib_database = bibtexparser.loads(bibtex_str)

        for entry in bib_database.entries:
            for field, value in entry.items():
                if (field == "ENTRYTYPE"):
                    docType = strToDocType(value)
                    fields.setDocType(docType)
                elif (field != "ID"):
                    fields.setField(field, value)
        
        return fields
        
    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()
    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()
Пример #14
0
    def descTableAuthors(self):
        d = DocumentFields()
        d.setField("author", "Bruf, John and Bamo, Tomy")
        notes = WikiNotes(d)
        notes.createDescriptionTable()
        content = notes.getDocumentContent()

        expectedContent = WikiNotes.TABLE_HEADER
        expectedContent += ( "|Auteurs :\n"
                            "| \'\'\'John Bruf, Tomy Bamo\'\'\'\n"
                            "|-\n")
        expectedContent += WikiNotes.TABLE_END

        contentLines = content.splitlines()
        expLines = expectedContent.splitlines()
        d = difflib.Differ()
        diff = d.compare(contentLines, expLines)
        # print "\n".join(diff)
        assert(content == expectedContent)
 def setType(self):
     a = DocumentFields()
     
     for t in DocumentFields.TYPES:
         a.setDocType(t)
         assert (a.getDocType() == t)
     
     a.setDocType(DocumentFields.OTHER)
     assert (a.getDocType() == DocumentFields.OTHER)
 def test_setType(self):
     a = DocumentFields()
     
     for t in DocumentFields.TYPES:
         a.setDocType(t)
         self.assertEqual(a.getDocType(), t)
     
     a.setDocType(DocumentFields.DOC_UNKNOWN)
     self.assertEqual(a.getDocType(), DocumentFields.DOC_UNKNOWN)
Пример #17
0
 def descTableYear(self):
     d = DocumentFields()
     d.setField("year", "2014")
     notes = LatexNotes(d)
     notes.createDescriptionTable()
     content = notes.getDocumentContent()
     expectedContent = LatexNotes.HEADER
     expectedContent += ("\\begin{longtable}[c]{@{}ll@{}}\n"
                         "\\toprule\\addlinespace\n"
                         "\n"
                         "Annee : & \\textbf{2014}\n"
                         "\\\\\\addlinespace\n"
                         "\n"
                         "\\bottomrule\n"
                         "\\end{longtable}\n")
     expectedContent += "\n"
     expectedContent += "\\end{document}\n"
     # contentLines = content.splitlines()
     # expLines = expectedContent.splitlines()
     # d = difflib.Differ()
     # diff = d.compare(contentLines, expLines)
     # print "\n".join(diff)
     assert(content == expectedContent)
Пример #18
0
 def descTableAuthors(self):
     d = DocumentFields()
     d.setField("author", "Bruf, John and Bamo, Tomy")
     notes = LatexNotes(d)
     notes.createDescriptionTable()
     content = notes.getDocumentContent()
     expectedContent = LatexNotes.HEADER
     expectedContent += ("\\begin{longtable}[c]{@{}ll@{}}\n"
                         "\\toprule\\addlinespace\n"
                         "\n"
                         "Auteurs : & \\textbf{John Bruf, Tomy Bamo}\n"
                         "\\\\\\addlinespace\n"
                         "\n"
                         "\\bottomrule\n"
                         "\\end{longtable}\n")
     expectedContent += "\n"
     expectedContent += "\\end{document}\n"
     # contentLines = content.splitlines()
     # expLines = expectedContent.splitlines()
     # d = difflib.Differ()
     # diff = d.compare(contentLines, expLines)
     # print "\n".join(diff)
     assert(content == expectedContent)
Пример #19
0
 def descTableKeywords(self):
     d = DocumentFields()
     d.setField("keywords", "Computer science, Photography")
     notes = LatexNotes(d)
     notes.createDescriptionTable()
     content = notes.getDocumentContent()
     expectedContent = LatexNotes.HEADER
     expectedContent += ("\\begin{longtable}[c]{@{}ll@{}}\n"
                         "\\toprule\\addlinespace\n"
                         "\n"
                         "Mots-cles : & \\textbf{Computer science, Photography}\n"
                         "\\\\\\addlinespace\n"
                         "\n"
                         "\\bottomrule\n"
                         "\\end{longtable}\n")
     expectedContent += "\n"
     expectedContent += "\\end{document}\n"
     # contentLines = content.splitlines()
     # expLines = expectedContent.splitlines()
     # d = difflib.Differ()
     # diff = d.compare(contentLines, expLines)
     # print "\n".join(diff)
     assert(content == expectedContent)
Пример #20
0
    def descAll(self):
        d = DocumentFields()
        d.setField("title", "document about internet")
        d.setField("year", "2014")
        d.setField("author", "John Bruf, Tommy Bamo")
        d.setField("keywords", "Computer science, Photography")
        d.setField("journal", "Journal of Computer Science")
        notes = Notes(d)
        notes.createAllContent()
        content = notes.getDocumentContent()
        expectedContent = "document about internet\n\n"
        expectedContent += Notes.TABLE_HEADER
        expectedContent += "Annee = 2014\n"
        expectedContent += "Auteurs = John Bruf, Tommy Bamo\n"
        expectedContent += "Mots-cles = Computer science, Photography\n"
        expectedContent += "Journal = Journal of Computer Science\n"
        expectedContent += Notes.TABLE_END

        # contentLines = content.splitlines()
        # expLines = expectedContent.splitlines()
        # d = difflib.Differ()
        # diff = d.compare(contentLines, expLines)
        # print "\n".join(diff)

        assert(content == expectedContent)
 def test_createEmpty(self):
     a = DocumentFields()
     assert (a.getNbFields() == 0)
     assert (a.getDocType() == DocumentFields.DOC_UNKNOWN)
 def addMultipleFields(self):
     a = DocumentFields()
     a.setField("title", "bc")
     a.setField("conf", "machin")
     a.setField("author", "martin")
     assert (a.getNbFields() == 3)
     assert (a.hasField("title"))
     assert (a.hasField("conf"))
     assert (a.hasField("author"))
     assert (a.getField("title") == "bc")
     assert (a.getField("conf") == "machin")
     assert (a.getField("author") == "martin")
 def getEmptyField(self):
     a = DocumentFields()
     assert (a.getField("title") == None)
 def addField(self):
     a = DocumentFields()
     a.setField("title", "bc")
     assert (a.getNbFields() == 1)
     assert (a.hasField("title"))
     assert (a.getField("title") == "bc")
 def createEmpty(self):
     a = DocumentFields()
     assert (a.getNbFields() == 0)
     assert (a.getDocType() == DocumentFields.OTHER)
 def test_getEmptyField(self):
     a = DocumentFields()
     self.assertIsNone(a.getField("title"), None)
 def test_addMultipleFields(self):
     a = DocumentFields()
     a.setField("title", "bc")
     a.setField("conf", "machin")
     a.setField("author", "martin")
     self.assertEqual (a.getNbFields(), 3)
     self.assertTrue(a.hasField("title"))
     self.assertTrue(a.hasField("conf"))
     self.assertTrue(a.hasField("author"))
     self.assertEqual(a.getField("title"), "bc")
     self.assertEqual(a.getField("conf"), "machin")
     self.assertEqual(a.getField("author"), "martin")
Пример #28
0
 def descTableAll(self):
     d = DocumentFields()
     d.setField("title", "document about internet")
     d.setField("year", "2014")
     d.setField("author", "Bruf, John and Bamo, Tomy")
     d.setField("keywords", "Computer science, Photography")
     d.setField("journal", "Journal of Computer Science")
     notes = LatexNotes(d)
     notes.createTitle()
     notes.createDescriptionTable()
     content = notes.getDocumentContent()
     expectedContent = LatexNotes.HEADER
     expectedContent += "\\title{document about internet}\n"
     expectedContent += "\\maketitle\n"
     expectedContent += "\n"
     expectedContent += ("\\begin{longtable}[c]{@{}ll@{}}\n"
                         "\\toprule\\addlinespace\n"
                         "\n"
                         "Annee : & \\textbf{2014}\n"
                         "\\\\\\addlinespace\n"
                         "\n"
                         "Auteurs : & \\textbf{John Bruf, Tomy Bamo}\n"
                         "\\\\\\addlinespace\n"
                         "\n"
                         "Mots-cles : & \\textbf{Computer science, Photography}\n"
                         "\\\\\\addlinespace\n"
                         "\n"
                         "Journal : & \\textbf{Journal of Computer Science}\n"
                         "\\\\\\addlinespace\n"
                         "\n"
                         "\\bottomrule\n"
                         "\\end{longtable}\n")
     expectedContent += "\n"
     expectedContent += "\\end{document}\n"
     # contentLines = content.splitlines()
     # expLines = expectedContent.splitlines()
     # d = difflib.Differ()
     # diff = d.compare(contentLines, expLines)
     # print "\n".join(diff)
     assert(content == expectedContent)
    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()
Пример #30
0
    def descTableAll(self):
        d = DocumentFields()
        d.setField("title", "document about internet")
        d.setField("year", "2014")
        d.setField("author", "Bruf, John and Bamo, Tomy")
        d.setField("keywords", "Computer science, Photography")
        d.setField("journal", "Journal of Computer Science")
        notes = WikiNotes(d)
        notes.createTitle()
        notes.createDescriptionTable()
        content = notes.getDocumentContent()

        expectedContent = WikiNotes.TABLE_HEADER
        expectedContent += ("|Annee :\n"
                            "| \'\'\'2014\'\'\'\n"
                            "|-\n"
                            "|Auteurs :\n"
                            "| \'\'\'John Bruf, Tomy Bamo\'\'\'\n"
                            "|-\n"
                            "|Mots-cles :\n"
                            "| \'\'\'Computer science, Photography\'\'\'\n"
                            "|-\n"
                            "|Journal :\n"
                            "| \'\'\'Journal of Computer Science\'\'\'\n"
                            "|-\n")
        expectedContent += WikiNotes.TABLE_END

        # contentLines = content.splitlines()
        # expLines = expectedContent.splitlines()
        # d = difflib.Differ()
        # diff = d.compare(contentLines, expLines)
        # print "\n".join(diff)
        assert(content == expectedContent)