Exemplo n.º 1
0
    def test_processfile_mobi(self):
        """ Тестирование процедуры processfile (извлекает метаданные из книги EPUB и помещает в БД) """
        opdsdb.clear_all()
        scanner = opdsScanner()
        scanner.processfile(self.test_mobi, self.test_ROOTLIB,
                            os.path.join(self.test_ROOTLIB, self.test_mobi),
                            None, 0, 542811)
        book = Book.objects.get(filename=self.test_mobi)
        self.assertIsNotNone(book)
        self.assertEqual(scanner.books_added, 1)
        self.assertEqual(book.filename, self.test_mobi)
        self.assertEqual(book.path, ".")
        self.assertEqual(book.format, "mobi")
        self.assertEqual(book.cat_type, 0)
        #self.assertGreaterEqual(book.registerdate, )
        self.assertEqual(book.docdate, "2011-11-20")
        self.assertEqual(book.lang, "")
        self.assertEqual(book.title, "Vector")
        self.assertEqual(book.search_title, "Vector".upper())
        self.assertEqual(book.annotation, "")
        self.assertEqual(book.avail, 2)
        self.assertEqual(book.catalog.path, ".")
        self.assertEqual(book.catalog.cat_name, ".")
        self.assertEqual(book.catalog.cat_type, 0)
        self.assertEqual(book.filesize, 542811)

        self.assertEqual(book.authors.count(), 1)
        self.assertEqual(
            book.authors.get(full_name="Cook Robin").search_full_name,
            "COOK ROBIN")
Exemplo n.º 2
0
 def clear(self):
     with transaction.atomic():
         opdsdb.clear_all(self.verbose)
     if not self.nogenres:
         call_command('loaddata', 'genre.json', app_label='opds_catalog') 
     Counter.objects.update_known_counters()
     opdsdb.pg_optimize(False)
Exemplo n.º 3
0
 def clear(self):
     with transaction.atomic():
         opdsdb.clear_all(self.verbose)
     if not self.nogenres:
         call_command('loaddata', 'genre.json', app_label='opds_catalog')
     Counter.objects.update_known_counters()
     opdsdb.pg_optimize(False)
Exemplo n.º 4
0
 def setUp(self):
     opdsdb.clear_all()
     opdsdb.addcattree("root/child/subchild",opdsdb.CAT_NORMAL)
     book = opdsdb.addbook("testbook.fb2", "root/child",opdsdb.findcat("root/child"),".fb2","Test Book", "Annotation", "01.01.2016", "ru", 500, 0)
     opdsdb.addbauthor(book, opdsdb.addauthor("Test Author"))
     opdsdb.addbgenre(book, opdsdb.addgenre("fantastic"))
     opdsdb.addbseries(book, opdsdb.addseries("mywork"), 1)
Exemplo n.º 5
0
    def test_processfile_mobi(self):
        """ Тестирование процедуры processfile (извлекает метаданные из книги EPUB и помещает в БД) """
        opdsdb.clear_all()
        scanner = opdsScanner()
        scanner.processfile(self.test_mobi, self.test_ROOTLIB, os.path.join(self.test_ROOTLIB,self.test_mobi), None,0,542811)
        book = Book.objects.get(filename=self.test_mobi)
        self.assertIsNotNone(book)
        self.assertEqual(scanner.books_added,1)
        self.assertEqual(book.filename, self.test_mobi)
        self.assertEqual(book.path, ".")
        self.assertEqual(book.format, "mobi")
        self.assertEqual(book.cat_type, 0)
        #self.assertGreaterEqual(book.registerdate, )
        self.assertEqual(book.docdate, "2011-11-20")
        self.assertEqual(book.lang, "")
        self.assertEqual(book.title, "Vector")
        self.assertEqual(book.search_title, "Vector".upper())
        self.assertEqual(book.annotation, "")
        self.assertEqual(book.avail, 2)
        self.assertEqual(book.catalog.path, ".")
        self.assertEqual(book.catalog.cat_name, ".")
        self.assertEqual(book.catalog.cat_type, 0)
        self.assertEqual(book.filesize, 542811)

        self.assertEqual(book.authors.count(), 1)
        self.assertEqual(book.authors.get(full_name="Cook Robin").search_full_name, "COOK ROBIN")
Exemplo n.º 6
0
    def test_processfile_epub(self):
        """ Тестирование процедуры processfile (извлекает метаданные из книги EPUB и помещает в БД) """
        opdsdb.clear_all()
        scanner = opdsScanner()
        scanner.processfile(self.test_epub, self.test_ROOTLIB, os.path.join(self.test_ROOTLIB,self.test_epub), None,0,491279)
        book = Book.objects.get(filename=self.test_epub)
        self.assertIsNotNone(book)
        self.assertEqual(scanner.books_added,1)
        self.assertEqual(book.filename, self.test_epub)
        self.assertEqual(book.path, ".")
        self.assertEqual(book.format, "epub")
        self.assertEqual(book.cat_type, 0)
        #self.assertGreaterEqual(book.registerdate, )
        self.assertEqual(book.docdate, "2015")
        self.assertEqual(book.lang, "ru")
        self.assertEqual(book.title, "У меня девять жизней (шф (продолжатели))")
        self.assertEqual(book.search_title, "У меня девять жизней (шф (продолжатели))".upper())
        self.assertEqual(book.annotation, "Собрание произведений. Том 2")
        self.assertEqual(book.avail, 2)
        self.assertEqual(book.catalog.path, ".")
        self.assertEqual(book.catalog.cat_name, ".")
        self.assertEqual(book.catalog.cat_type, 0)
        self.assertEqual(book.filesize, 491279)

        self.assertEqual(book.authors.count(), 1)
        self.assertEqual(book.authors.get(full_name="Мирер Александр").search_full_name, "МИРЕР АЛЕКСАНДР")

        self.assertEqual(book.genres.count(), 1)
        self.assertEqual(book.genres.get(genre="sf").section, opdsdb.unknown_genre)
        self.assertEqual(book.genres.get(genre="sf").subsection, "sf")
Exemplo n.º 7
0
    def test_processfile_fb2(self):
        """ Тестирование процедуры processfile (извлекает метаданные из книги FB2 и помещает в БД) """
        opdsdb.clear_all()
        scanner = opdsScanner()
        scanner.processfile(self.test_fb2, self.test_ROOTLIB, os.path.join(self.test_ROOTLIB,self.test_fb2), None,0,495373)
        book = Book.objects.get(filename=self.test_fb2)
        self.assertIsNotNone(book)
        self.assertEqual(scanner.books_added,1)
        self.assertEqual(book.filename, self.test_fb2)
        self.assertEqual(book.path, ".")
        self.assertEqual(book.format, "fb2")
        self.assertEqual(book.cat_type, 0)
        #self.assertGreaterEqual(book.registerdate, )
        self.assertEqual(book.docdate, "30.1.2011")
        self.assertEqual(book.lang, "en")
        self.assertEqual(book.title, "The Sanctuary Sparrow")
        self.assertEqual(book.search_title, "The Sanctuary Sparrow".upper())
        self.assertEqual(book.annotation, "")
        self.assertEqual(book.avail, 2)
        self.assertEqual(book.catalog.path, ".")
        self.assertEqual(book.catalog.cat_name, ".")
        self.assertEqual(book.catalog.cat_type, 0)
        self.assertEqual(book.filesize, 495373)

        self.assertEqual(book.authors.count(), 1)
        self.assertEqual(book.authors.get(full_name="Peters Ellis").search_full_name, "PETERS ELLIS")

        self.assertEqual(book.genres.count(), 1)
        self.assertEqual(book.genres.get(genre="antique").section, opdsdb.unknown_genre)
        self.assertEqual(book.genres.get(genre="antique").subsection, "antique")
Exemplo n.º 8
0
 def test_scanall(self):
     """ Тестирование процедуры scanall (извлекает метаданные из книг и помещает в БД) """
     opdsdb.clear_all()
     scanner = opdsScanner()
     scanner.scan_all()
     self.assertEquals(scanner.books_added, 6)
     self.assertEquals(scanner.bad_books, 1)
     self.assertEquals(Book.objects.all().count(), 6)
     self.assertEquals(Author.objects.all().count(), 6)
     self.assertEquals(Genre.objects.all().count(), 5)
     self.assertEquals(Series.objects.all().count(), 1)
     self.assertEquals(Catalog.objects.all().count(), 2)
Exemplo n.º 9
0
 def test_scanall(self):
     """ Тестирование процедуры scanall (извлекает метаданные из книг и помещает в БД) """
     opdsdb.clear_all()
     scanner = opdsScanner()
     scanner.scan_all()
     self.assertEquals(scanner.books_added, 6)
     self.assertEquals(scanner.bad_books, 1)
     self.assertEquals(Book.objects.all().count(), 6)
     self.assertEquals(Author.objects.all().count(), 6)
     self.assertEquals(Genre.objects.all().count(), 5)
     self.assertEquals(Series.objects.all().count(), 1)
     self.assertEquals(Catalog.objects.all().count(), 2)
Exemplo n.º 10
0
    def test_processzip(self):
        """ Тестирование процедуры processzip (извлекает метаданные из книг, помещенных в архив и помещает их БД) """
        opdsdb.clear_all()
        scanner = opdsScanner()
        scanner.processzip(self.test_zip, self.test_ROOTLIB,
                           os.path.join(self.test_ROOTLIB, self.test_zip))
        self.assertEquals(scanner.books_added, 3)
        self.assertEquals(Book.objects.all().count(), 3)
        self.assertEquals(Catalog.objects.all().count(), 2)

        book = Book.objects.get(filename="539603.fb2")
        self.assertEqual(book.filesize, 15194)
        self.assertEqual(book.path, self.test_zip)
        self.assertEqual(book.cat_type, 1)
        self.assertEqual(book.catalog.path, self.test_zip)
        self.assertEqual(book.catalog.cat_name, self.test_zip)
        self.assertEqual(book.catalog.cat_type, 1)
        self.assertEqual(book.docdate, "2014-09-15")
        self.assertEqual(book.title, "Любовь в жизни Обломова")
        self.assertEqual(book.avail, 2)
        self.assertEqual(book.authors.count(), 1)
        self.assertEqual(
            book.authors.get(full_name="Логинов Святослав").search_full_name,
            "ЛОГИНОВ СВЯТОСЛАВ")
        self.assertEqual(book.genres.count(), 1)
        self.assertEqual(
            book.genres.get(genre="nonf_criticism").section,
            opdsdb.unknown_genre)
        self.assertEqual(
            book.genres.get(genre="nonf_criticism").subsection,
            "nonf_criticism")

        book = Book.objects.get(filename="539485.fb2")
        self.assertEqual(book.filesize, 12293)
        self.assertEqual(book.path, self.test_zip)
        self.assertEqual(book.cat_type, 1)
        self.assertEqual(book.title, "Китайски сладкиш с късметче")
        self.assertEqual(
            book.authors.get(full_name="Фрич Чарлз").search_full_name,
            "ФРИЧ ЧАРЛЗ")

        book = Book.objects.get(filename="539273.fb2")
        self.assertEqual(book.filesize, 21722)
        self.assertEqual(book.path, self.test_zip)
        self.assertEqual(book.cat_type, 1)
        self.assertEqual(book.title, "Драконьи Услуги")
        self.assertEqual(
            book.authors.get(full_name="Куприянов Денис").search_full_name,
            "КУПРИЯНОВ ДЕНИС")
Exemplo n.º 11
0
 def setUp(self):
     opdsdb.clear_all()
     book = Book.objects.create(filename="testbook.fb2", path=".", filesize=500, format="fb2", cat_type=0, 
                         registerdate=self.testdatetime,docdate="01.01.2016", lang="ru", title="Книга", search_title="КНИГА", 
                         annotation="Аннотация", avail=2,catalog=Catalog.objects.create(parent=None, cat_name=".", path=".", cat_type=0)
     )
     author = Author.objects.create(full_name="Шелепнев Дмитрий", search_full_name="ШЕЛЕПНЕВ ДМИТРИЙ")
     genre = Genre.objects.create(genre="fantastic0", section="fantastic1", subsection="fantastic2")
     series = Series.objects.create(ser="mywork", search_ser="MYWORK")
     bauthor.objects.create(book=book, author=author)
     bgenre.objects.create(book=book, genre=genre)
     bseries.objects.create(book=book, ser=series, ser_no=1)
     user = User.objects.create_user("testuser","*****@*****.**", "testpassword", first_name="Test", last_name="User")
     bookshelf.objects.create(user=user, book=book, readtime=self.testdatetime)
     Counter.objects.update_known_counters()
Exemplo n.º 12
0
    def test_processzip(self):
        """ Тестирование процедуры processzip (извлекает метаданные из книг, помещенных в архив и помещает их БД) """
        opdsdb.clear_all()
        scanner = opdsScanner()
        scanner.processzip(self.test_zip, self.test_ROOTLIB, os.path.join(self.test_ROOTLIB,self.test_zip) )
        self.assertEquals(scanner.books_added, 3)
        self.assertEquals(Book.objects.all().count(), 3)
        self.assertEquals(Catalog.objects.all().count(), 2)

        book = Book.objects.get(filename="539603.fb2")
        self.assertEqual(book.filesize, 15194)
        self.assertEqual(book.path, self.test_zip)
        self.assertEqual(book.cat_type, 1)
        self.assertEqual(book.catalog.path, self.test_zip)
        self.assertEqual(book.catalog.cat_name, self.test_zip)
        self.assertEqual(book.catalog.cat_type, 1)
        self.assertEqual(book.docdate, "2014-09-15")
        self.assertEqual(book.title, "Любовь в жизни Обломова")
        self.assertEqual(book.avail, 2)
        self.assertEqual(book.authors.count(), 1)
        self.assertEqual(book.authors.get(full_name="Логинов Святослав").search_full_name, "ЛОГИНОВ СВЯТОСЛАВ")
        self.assertEqual(book.genres.count(), 1)
        self.assertEqual(book.genres.get(genre="nonf_criticism").section, opdsdb.unknown_genre)
        self.assertEqual(book.genres.get(genre="nonf_criticism").subsection, "nonf_criticism")

        book = Book.objects.get(filename="539485.fb2")
        self.assertEqual(book.filesize, 12293)
        self.assertEqual(book.path, self.test_zip)
        self.assertEqual(book.cat_type, 1)
        self.assertEqual(book.title, "Китайски сладкиш с късметче")
        self.assertEqual(book.authors.get(full_name="Фрич Чарлз").search_full_name, "ФРИЧ ЧАРЛЗ")

        book = Book.objects.get(filename="539273.fb2")
        self.assertEqual(book.filesize, 21722)
        self.assertEqual(book.path, self.test_zip)
        self.assertEqual(book.cat_type, 1)
        self.assertEqual(book.title, "Драконьи Услуги")
        self.assertEqual(book.authors.get(full_name="Куприянов Денис").search_full_name, "КУПРИЯНОВ ДЕНИС")
Exemplo n.º 13
0
 def setUp(self):
     opdsdb.clear_all()
     book = Book.objects.create(filename="testbook.fb2",
                                path=".",
                                filesize=500,
                                format="fb2",
                                cat_type=0,
                                registerdate=self.testdatetime,
                                docdate="01.01.2016",
                                lang="ru",
                                title="Книга",
                                search_title="КНИГА",
                                annotation="Аннотация",
                                avail=2,
                                catalog=Catalog.objects.create(parent=None,
                                                               cat_name=".",
                                                               path=".",
                                                               cat_type=0))
     author = Author.objects.create(full_name="Шелепнев Дмитрий",
                                    search_full_name="ШЕЛЕПНЕВ ДМИТРИЙ")
     genre = Genre.objects.create(genre="fantastic0",
                                  section="fantastic1",
                                  subsection="fantastic2")
     series = Series.objects.create(ser="mywork", search_ser="MYWORK")
     bauthor.objects.create(book=book, author=author)
     bgenre.objects.create(book=book, genre=genre)
     bseries.objects.create(book=book, ser=series, ser_no=1)
     user = User.objects.create_user("testuser",
                                     "*****@*****.**",
                                     "testpassword",
                                     first_name="Test",
                                     last_name="User")
     bookshelf.objects.create(user=user,
                              book=book,
                              readtime=self.testdatetime)
     Counter.objects.update_known_counters()