コード例 #1
0
    def test_with_bibtex(self):
        bibstring = """
        @article{10.1002/andp.19053221004, author = { A. Einstein },
          doi = { 10.1002/andp.19053221004 },
          issue = { 10 }, journal = { Ann. Phys. }, pages = { 891--921 },
          title = { Zur Elektrodynamik bewegter K\"{o}rper },
          type = { article },
          volume = { 322 },
          year = { 1905 },
        }
        """
        bibfile = tempfile.mktemp()
        pdf = create_random_pdf()
        with open(bibfile, 'w+') as fd:
            fd.write(bibstring)

        self.assertTrue(get_document_extension(pdf) == 'pdf')

        result = self.invoke([pdf, '--from-bibtex', bibfile])

        db = papis.database.get()
        docs = db.query_dict(
            dict(author="einstein", title="Elektrodynamik bewegter"))
        self.assertTrue(len(docs) == 1)
        doc = docs[0]
        self.assertTrue(len(doc.get_files()) == 1)

        # This is the original pdf file, it should still be there
        self.assertTrue(os.path.exists(pdf))
        # and it should still be apdf
        self.assertTrue(get_document_extension(pdf) == 'pdf')
        self.assertTrue(get_document_extension(doc.get_files()[0]) == 'pdf')
コード例 #2
0
ファイル: test_add.py プロジェクト: wbrandenburger/papis
    def test_from_yaml(self):
        yamlstring = (
            "title: The lord of the rings\n"
            "author: Tolkien\n"
        )
        yamlfile = tempfile.mktemp()
        epub = create_random_epub()
        with open(yamlfile, 'w+') as fd:
            fd.write(yamlstring)

        self.assertTrue(get_document_extension(epub) == 'epub')

        result = self.invoke([
            epub, '--from yaml', yamlfile
        ])

        db = papis.database.get()
        docs = db.query_dict({"author": "Tolkien"})
        self.assertTrue(len(docs) == 1)
        doc = docs[0]
        self.assertTrue(len(doc.get_files()) == 1)

        # This is the original epub file, it should still be there
        self.assertTrue(os.path.exists(epub))
        # and it should still be an epub
        self.assertTrue(get_document_extension(epub) == 'epub')
        self.assertTrue(get_document_extension(doc.get_files()[0]) == 'epub')
コード例 #3
0
ファイル: test_utils.py プロジェクト: wbrandenburger/papis
def test_extension():
    docs = [
        [tests.create_random_pdf(), "pdf"],
        [tests.create_random_pdf(), "pdf"],
        [tests.create_random_file(), "data"],
        [tests.create_random_epub(), "epub"],
        [tests.create_random_file(suffix='.yaml'), "yaml"],
        [tests.create_random_file(suffix='.text'), "text"],
    ]
    for d in docs:
        assert(get_document_extension(d[0]) == d[1])