示例#1
0
 def test_change_capital_one_author_one_book(self):
     fs = connect_gdrive("test")
     self.assertTrue(fs.isfile(os.path.join('test', 'Leo Baskerville/book8 (8)',
                                                 'cover.jpg').replace('\\', '/')))
     self.assertTrue(fs.isfile(os.path.join('test', 'Leo Baskerville/book8 (8)',
                                                 'book8 - Leo Baskerville.epub').replace('\\', '/')))
     # rename uppercase to lowercase only of author
     self.edit_book(8, content={'bookAuthor': "Leo baskerville"})
     self.assertFalse(self.check_element_on_page((By.ID, "flash_danger")))
     time.sleep(WAIT_GDRIVE)
     details = self.get_book_details(-1)
     self.assertEqual(['Leo baskerville'], details['author'])
     self.assertTrue(fs.isfile(os.path.join('test', 'Leo baskerville/book8 (8)',
                                                 'book8 - Leo baskerville.epub').replace('\\', '/')))
     self.assertTrue(fs.isfile(os.path.join('test', 'Leo baskerville/book8 (8)',
                                                 'cover.jpg').replace('\\', '/')))
     # Check that name of author folder no longer is "Leo Baskerville"
     self.assertNotEqual("Leo Baskerville", fs.getinfo(os.path.join('test', 'Leo Baskerville').replace('\\', '/')).name)
     ret_code, content = self.download_book(8, "admin", "admin123")
     self.assertEqual(200, ret_code)
     # rename book title and author in the same step
     self.edit_book(8, content={'bookAuthor': "Leo Baskerville", 'book_title': 'book 9'})
     self.assertFalse(self.check_element_on_page((By.ID, "flash_danger")))
     time.sleep(WAIT_GDRIVE)
     details = self.get_book_details(-1)
     self.assertEqual(['Leo Baskerville'], details['author'])
     self.assertEqual('book 9', details['title'])
     self.assertTrue(fs.isfile(os.path.join('test', 'Leo Baskerville/book 9 (8)',
                                                 'book 9 - Leo Baskerville.epub').replace('\\', '/')))
     self.assertTrue(fs.isfile(os.path.join('test', 'Leo Baskerville/book 9 (8)',
                                                 'cover.jpg').replace('\\', '/')))
     # Check that name of author folder no longer is "Leo baskerville"
     self.assertNotEqual("Leo baskerville",
                         fs.getinfo(os.path.join('test', 'Leo baskerville').replace('\\', '/')).name)
     ret_code, content = self.download_book(8, "admin", "admin123")
     self.assertEqual(200, ret_code)
     # rename only book title
     self.edit_book(8, content={'bookAuthor': "Leo Baskerville", 'book_title': 'book8'})
     self.assertFalse(self.check_element_on_page((By.ID, "flash_danger")))
     time.sleep(WAIT_GDRIVE)
     details = self.get_book_details(-1)
     self.assertEqual(['Leo Baskerville'], details['author'])
     self.assertEqual('book8', details['title'])
     self.assertTrue(fs.isfile(os.path.join('test', 'Leo Baskerville/book8 (8)',
                                                 'book8 - Leo Baskerville.epub').replace('\\', '/')))
     self.assertTrue(fs.isfile(os.path.join('test', 'Leo Baskerville/book8 (8)',
                                                 'cover.jpg')))
     # Check that name of author folder no longer is "Leo baskerville"
     self.assertNotEqual("Leo baskerville",
                         fs.getinfo(os.path.join('test', 'Leo baskerville').replace('\\', '/')).name)
     ret_code, content = self.download_book(8, "admin", "admin123")
     self.assertEqual(200, ret_code)
    def test_convert_failed_and_email(self):
        tasks = self.check_tasks()
        vals = self.get_convert_book(1)
        select = Select(vals['btn_from'])
        select.select_by_visible_text('TXT')
        select = Select(vals['btn_to'])
        select.select_by_visible_text('AZW3')
        self.check_element_on_page((By.ID, "btn-book-convert")).click()
        time.sleep(1)
        self.assertTrue(self.check_element_on_page((By.ID, "flash_success")))
        time.sleep(4)
        i = 0
        while i < 20:
            time.sleep(2)
            task_len, ret = self.check_tasks(tasks)
            if task_len == 1:
                if ret[-1]['result'] == 'Finished' or ret[-1]['result'] == 'Failed':
                    break
            i += 1
        self.assertEqual(1, task_len)
        self.assertEqual('Finished', ret[-1]['result'])
        fs = connect_gdrive("test")
        orig_file = os.path.join('test', 'Frodo Beutlin','Der Buchtitel (1)',
                                 'Der Buchtitel - Frodo Beutlin.azw3').replace('\\', '/')
        moved_file = os.path.join('test', 'Frodo Beutlin', 'Der Buchtitel (1)',
                                  'book1.azw3').replace('\\', '/')
        fs.move(orig_file, moved_file, overwrite=True)

        fout = io.BytesIO()
        fout.write(os.urandom(124))
        fs.upload(orig_file, fout)
        fout.close()
        self.setup_server(True, {'mail_password': '******'})
        t_len, tasks = self.check_tasks(ret)
        details = self.get_book_details(1)
        self.assertEqual(len(details['kindle']), 1)
        details['kindlebtn'].click()
        i = 0
        while i < 20:
            time.sleep(2)
            task_len, ret = self.check_tasks(tasks)
            if task_len == 1:
                if ret[-1]['result'] == 'Finished' or ret[-1]['result'] == 'Failed':
                    break
            i += 1
        self.assertEqual(ret[-1]['result'], 'Failed')
        self.setup_server(True, {'mail_password': '******'})
        fs.remove(orig_file)
        fs.move(moved_file, orig_file, overwrite=True)
        fs.close()
        self.delete_book_format(1, "AZW3")
示例#3
0
    def test_change_capital_co_author(self):
        fs = connect_gdrive("test")
        self.assertFalse(fs.isfile(os.path.join('test', 'Frodo Beutlin/Der Buchtitel (1)',
                                                    'cover.jpg').replace('\\', '/')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Frodo Beutlin/Der Buchtitel (1)',
                                                    'Der Buchtitel - Frodo Beutlin.txt').replace('\\', '/')))
        # rename uppercase to lowercase only of author
        self.edit_book(1, content={'bookAuthor': "Frodo Beutlin & Norbert Halagal & Liu yang & Hector Gonçalves"})
        self.assertFalse(self.check_element_on_page((By.ID, "flash_danger")))
        time.sleep(WAIT_GDRIVE)
        details = self.get_book_details(-1)
        self.assertEqual(['Frodo Beutlin', 'Norbert Halagal', 'Liu yang', 'Hector Gonçalves'], details['author'])
        self.assertTrue(fs.isfile(os.path.join('test', 'Frodo Beutlin/Der Buchtitel (1)',
                                                    'Der Buchtitel - Frodo Beutlin.txt').replace('\\', '/')))
        self.assertFalse(fs.isfile(os.path.join('test', 'Frodo Beutlin/Der Buchtitel (1)',
                                                    'cover.jpg').replace('\\', '/')))
        ret_code, content = self.download_book(1, "admin", "admin123")
        self.assertEqual(200, ret_code)

        # rename book title and author in the same step
        self.edit_book(1, content={'bookAuthor': "Frodo Beutlin & Norbert Halagal & Liu Yang & Hector Gonçalves",
                                   'book_title': 'Derbook 1'})
        self.assertFalse(self.check_element_on_page((By.ID, "flash_danger")))
        time.sleep(WAIT_GDRIVE)
        details = self.get_book_details(-1)
        self.assertEqual(['Frodo Beutlin', 'Norbert Halagal', 'Liu Yang', 'Hector Gonçalves'], details['author'])
        self.assertEqual('Derbook 1', details['title'])
        self.assertTrue(fs.isfile(os.path.join('test', 'Frodo Beutlin/Derbook 1 (1)',
                                                    'Derbook 1 - Frodo Beutlin.txt').replace('\\', '/')))
        self.assertFalse(fs.isfile(os.path.join('test', 'Frodo Beutlin/Derbook 1 (1)',
                                                    'cover.jpg').replace('\\', '/')))
        ret_code, content = self.download_book(1, "admin", "admin123")
        self.assertEqual(200, ret_code)
        # rename only book title
        self.edit_book(1, content={'book_title': 'Der Buchtitel'})
        self.assertFalse(self.check_element_on_page((By.ID, "flash_danger")))
        time.sleep(WAIT_GDRIVE)
        details = self.get_book_details(-1)
        self.assertEqual(['Frodo Beutlin', 'Norbert Halagal', 'Liu Yang', 'Hector Gonçalves'], details['author'])
        self.assertEqual('Der Buchtitel', details['title'])
        self.assertFalse(fs.isfile(os.path.join('test', 'Frodo Beutlin/Der Buchtitel (1)',
                                                    'cover.jpg').replace('\\', '/')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Frodo Beutlin/Der Buchtitel (1)',
                                                    'Der Buchtitel - Frodo Beutlin.txt').replace('\\', '/')))
        ret_code, content = self.download_book(1, "admin", "admin123")
        self.assertEqual(200, ret_code)
示例#4
0
    def test_rename_capital_on_upload(self):
        fs = connect_gdrive("test")
        self.fill_basic_config({'config_uploading': 1})
        time.sleep(3)
        self.assertTrue(self.check_element_on_page((By.ID, "flash_success")))
        # Upload book with one author in database
        epub_file = os.path.join(base_path, 'files', 'title.epub')
        change_epub_meta(epub_file, meta={'title': "Useless", 'creator': "asterix Lionherd"})
        self.goto_page('nav_new')
        upload = self.check_element_on_page((By.ID, 'btn-upload'))
        upload.send_keys(epub_file)
        time.sleep(WAIT_GDRIVE)
        self.check_element_on_page((By.ID, 'edit_cancel')).click()
        time.sleep(WAIT_GDRIVE)
        details = self.get_book_details()
        self.assertEqual('Useless', details['title'])
        self.assertEqual(['asterix Lionherd'], details['author'])
        self.assertTrue(fs.isfile(os.path.join('test', 'asterix Lionherd/comicdemo (3)',
                                                    'comicdemo - asterix Lionherd.cbr').replace('\\', '/')))
        self.assertTrue(fs.isfile(os.path.join('test', 'asterix Lionherd/comicdemo (3)',
                                                    'cover.jpg').replace('\\', '/')))
        ret_code, content = self.download_book(3, "admin", "admin123")
        self.assertEqual(200, ret_code)
        ret_code, content = self.download_book(details['id'], "admin", "admin123")
        self.assertEqual(200, ret_code)

        self.delete_book(details['id'])
        time.sleep(WAIT_GDRIVE)
        self.edit_book(3, content={'bookAuthor': "Asterix Lionherd"})
        time.sleep(WAIT_GDRIVE)
        self.assertFalse(self.check_element_on_page((By.ID, "flash_danger")))
        details = self.get_book_details(-1)
        self.assertEqual(['Asterix Lionherd'], details['author'])
        self.assertTrue(fs.isfile(os.path.join('test', 'Asterix Lionherd/comicdemo (3)',
                                                    'comicdemo - Asterix Lionherd.cbr').replace('\\', '/')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Asterix Lionherd/comicdemo (3)',
                                                    'cover.jpg').replace('\\', '/')))

        # Upload book with one co-author in database
        change_epub_meta(epub_file, meta={'title': "Useless", 'creator': 'liu yang'})
        self.goto_page('nav_new')
        upload = self.check_element_on_page((By.ID, 'btn-upload'))
        upload.send_keys(epub_file)
        time.sleep(WAIT_GDRIVE)
        self.check_element_on_page((By.ID, 'edit_cancel')).click()
        time.sleep(WAIT_GDRIVE)
        self.assertFalse(self.check_element_on_page((By.ID, "flash_danger")))
        details = self.get_book_details(-1)
        self.assertEqual('Useless', details['title'])
        self.assertEqual(['liu yang'], details['author'])
        ret_code, content = self.download_book(1, "admin", "admin123")
        self.assertEqual(200, ret_code)
        ret_code, content = self.download_book(details['id'], "admin", "admin123")
        self.assertEqual(200, ret_code)
        self.delete_book(details['id'])
        time.sleep(WAIT_GDRIVE)
        details = self.get_book_details(1)
        self.assertEqual(['Frodo Beutlin', 'Norbert Halagal', 'liu yang', 'Hector Gonçalves'], details['author'])
        self.assertTrue(fs.isfile(os.path.join('test', 'Frodo Beutlin/Der Buchtitel (1)',
                                                    'Der Buchtitel - Frodo Beutlin.txt').replace('\\', '/')))
        self.assertFalse(fs.isfile(os.path.join('test', 'Frodo Beutlin/Der Buchtitel (1)',
                                                    'cover.jpg').replace('\\', '/')))
        self.edit_book(1, content={'bookAuthor': "Frodo Beutlin & Norbert Halagal & Liu Yang & Hector Gonçalves"})
        time.sleep(WAIT_GDRIVE)
        self.assertFalse(self.check_element_on_page((By.ID, "flash_danger")))
        details = self.get_book_details(-1)
        self.assertEqual(['Frodo Beutlin', 'Norbert Halagal', 'Liu Yang', 'Hector Gonçalves'], details['author'])

        # ToDo: Upload file with multiple existing authors
        self.fill_basic_config({'config_uploading': 0})
        self.assertTrue(self.check_element_on_page((By.ID, "flash_success")))
示例#5
0
    def test_change_capital_rename_two_co_authors(self):
        fs = connect_gdrive("test")
        # check initial filenames
        self.assertTrue(fs.isfile(os.path.join('test', 'Asterix Lionherd/comicdemo (3)',
                                                    'comicdemo - Asterix Lionherd.cbr')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Asterix Lionherd/comicdemo (3)',
                                                    'cover.jpg').replace('\\', '/')))
        self.assertFalse(fs.isfile(os.path.join('test', 'Frodo Beutlin/Der Buchtitel (1)',
                                                    'cover.jpg').replace('\\', '/')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Frodo Beutlin/Der Buchtitel (1)',
                                                    'Der Buchtitel - Frodo Beutlin.txt').replace('\\', '/')))
        # Add 2. author to book to have usecase
        self.edit_book(3, content={'bookAuthor': "Asterix Lionherd & Liu Yang"})
        self.assertFalse(self.check_element_on_page((By.ID, "flash_danger")))
        time.sleep(WAIT_GDRIVE)
        details = self.get_book_details(-1)
        self.assertEqual(['Asterix Lionherd', 'Liu Yang'], details['author'])
        self.assertTrue(fs.isfile(os.path.join('test', 'Asterix Lionherd/comicdemo (3)',
                                                    'comicdemo - Asterix Lionherd.cbr').replace('\\', '/')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Asterix Lionherd/comicdemo (3)',
                                                    'cover.jpg').replace('\\', '/')))

        #rename co-author
        self.edit_book(1, content={'bookAuthor': "Frodo Beutlin & Norbert Halagal & liu Yang & Hector Gonçalves"})
        self.assertFalse(self.check_element_on_page((By.ID, "flash_danger")))
        time.sleep(WAIT_GDRIVE)
        details = self.get_book_details(-1)
        self.assertEqual(['Frodo Beutlin', 'Norbert Halagal', 'liu Yang', 'Hector Gonçalves'], details['author'])
        details = self.get_book_details(3)
        self.assertEqual(['Asterix Lionherd', 'liu Yang'], details['author'])
        self.assertTrue(fs.isfile(os.path.join('test', 'Asterix Lionherd/comicdemo (3)',
                                                    'comicdemo - Asterix Lionherd.cbr').replace('\\', '/')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Asterix Lionherd/comicdemo (3)',
                                                    'cover.jpg').replace('\\', '/')))
        self.assertFalse(fs.isfile(os.path.join('test', 'Frodo Beutlin/Der Buchtitel (1)',
                                                    'cover.jpg').replace('\\', '/')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Frodo Beutlin/Der Buchtitel (1)',
                                                    'Der Buchtitel - Frodo Beutlin.txt').replace('\\', '/')))

        ret_code, content = self.download_book(3, "admin", "admin123")
        self.assertEqual(200, ret_code)
        ret_code, content = self.download_book(1, "admin", "admin123")
        self.assertEqual(200, ret_code)

        # rename book title and author in the same step
        self.edit_book(1, content={'bookAuthor': "Frodo Beutlin & Norbert Halagal & Liu Yang & Hector Gonçalves",
                                   'book_title': 'Derbook 1'})
        self.assertFalse(self.check_element_on_page((By.ID, "flash_danger")))
        time.sleep(WAIT_GDRIVE)
        details = self.get_book_details(-1)
        self.assertEqual(['Frodo Beutlin', 'Norbert Halagal', 'Liu Yang', 'Hector Gonçalves'], details['author'])
        self.assertEqual('Derbook 1', details['title'])
        self.assertTrue(fs.isfile(os.path.join('test', 'Frodo Beutlin/Derbook 1 (1)',
                                                    'Derbook 1 - Frodo Beutlin.txt').replace('\\', '/')))
        self.assertFalse(fs.isfile(os.path.join('test', 'Frodo Beutlin/Derbook 1 (1)',
                                                    'cover.jpg').replace('\\', '/')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Asterix Lionherd/comicdemo (3)',
                                                    'comicdemo - Asterix Lionherd.cbr').replace('\\', '/')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Asterix Lionherd/comicdemo (3)',
                                                    'cover.jpg').replace('\\', '/')))
        ret_code, content = self.download_book(1, "admin", "admin123")
        self.assertEqual(200, ret_code)
        ret_code, content = self.download_book(3, "admin", "admin123")
        self.assertEqual(200, ret_code)
        self.edit_book(3, content={'bookAuthor': "Asterix Lionherd"})
        self.assertFalse(self.check_element_on_page((By.ID, "flash_danger")))
        time.sleep(WAIT_GDRIVE)
        details = self.get_book_details(-1)
        self.assertEqual(['Asterix Lionherd'], details['author'])

        # rename only book title
        self.edit_book(1, content={'book_title': 'Der Buchtitel'})
        self.assertFalse(self.check_element_on_page((By.ID, "flash_danger")))
        time.sleep(WAIT_GDRIVE)
        details = self.get_book_details(-1)
        self.assertEqual(['Frodo Beutlin', 'Norbert Halagal', 'Liu Yang', 'Hector Gonçalves'], details['author'])
        self.assertEqual('Der Buchtitel', details['title'])
        self.assertFalse(fs.isfile(os.path.join('test', 'Frodo Beutlin/Der Buchtitel (1)',
                                                    'cover.jpg').replace('\\', '/')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Frodo Beutlin/Der Buchtitel (1)',
                                                    'Der Buchtitel - Frodo Beutlin.txt').replace('\\', '/')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Asterix Lionherd/comicdemo (3)',
                                                    'comicdemo - Asterix Lionherd.cbr').replace('\\', '/')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Asterix Lionherd/comicdemo (3)',
                                                    'cover.jpg').replace('\\', '/')))
        ret_code, content = self.download_book(1, "admin", "admin123")
        self.assertEqual(200, ret_code)
示例#6
0
    def test_change_capital_rename_co_author(self):
        fs = connect_gdrive("test")
        self.assertFalse(fs.isfile(os.path.join('test', 'Frodo Beutlin/Der Buchtitel (1)',
                                                    'cover.jpg')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Frodo Beutlin/Der Buchtitel (1)',
                                                    'Der Buchtitel - Frodo Beutlin.txt').replace('\\', '/')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Hector Goncalves/book9 (11)',
                                                    'book9 - Hector Goncalves.pdf').replace('\\', '/')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Hector Goncalves/book9 (11)',
                                                    'cover.jpg').replace('\\', '/')))
        # Author folder is not found due to utf characters not represented in filename
        self.edit_book(1, content={'bookAuthor': "Frodo Beutlin & Norbert Halagal & Liu Yang & hector Gonçalves"})
        self.assertFalse(self.check_element_on_page((By.ID, "flash_danger")))
        time.sleep(WAIT_GDRIVE)
        details = self.get_book_details(-1)
        self.assertEqual(['Frodo Beutlin', 'Norbert Halagal', 'Liu Yang', 'hector Gonçalves'], details['author'])
        self.assertFalse(fs.isfile(os.path.join('test', 'Frodo Beutlin/Der Buchtitel (1)',
                                                    'cover.jpg').replace('\\', '/')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Frodo Beutlin/Der Buchtitel (1)',
                                                    'Der Buchtitel - Frodo Beutlin.txt').replace('\\', '/')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Hector Goncalves/book9 (11)',
                                                    'book9 - Hector Goncalves.pdf').replace('\\', '/')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Hector Goncalves/book9 (11)',
                                                    'cover.jpg').replace('\\', '/')))
        ret_code, content = self.download_book(1, "admin", "admin123")
        self.assertEqual(200, ret_code)
        ret_code, content = self.download_book(11, "admin", "admin123")
        self.assertEqual(200, ret_code)

        # ToDo: currently empty folder Hector Goncalves remains
        self.edit_book(11, content={'bookAuthor': "hector Gonçalves & Unbekannt"})
        self.assertFalse(self.check_element_on_page((By.ID, "flash_danger")))
        time.sleep(WAIT_GDRIVE)
        details = self.get_book_details(-1)
        self.assertEqual(['hector Gonçalves', 'Unbekannt'], details['author'])

        self.edit_book(11, content={'bookAuthor': "Hector Gonçalve"})
        self.assertFalse(self.check_element_on_page((By.ID, "flash_danger")))
        time.sleep(WAIT_GDRIVE)
        self.edit_book(11, content={'bookAuthor': "Hector Gonçalves & unbekannt"})
        self.assertFalse(self.check_element_on_page((By.ID, "flash_danger")))
        time.sleep(WAIT_GDRIVE)
        # rename uppercase to lowercase only of author
        self.edit_book(1, content={'bookAuthor': "Frodo Beutlin & Norbert Halagal & Liu Yang & Hector gonçalves"})
        self.assertFalse(self.check_element_on_page((By.ID, "flash_danger")))
        time.sleep(WAIT_GDRIVE)
        details = self.get_book_details(-1)
        self.assertEqual(['Frodo Beutlin', 'Norbert Halagal', 'Liu Yang', 'Hector gonçalves'], details['author'])
        self.assertTrue(fs.isfile(os.path.join('test', 'Frodo Beutlin/Der Buchtitel (1)',
                                                    'Der Buchtitel - Frodo Beutlin.txt').replace('\\', '/')))
        self.assertFalse(fs.isfile(os.path.join('test', 'Frodo Beutlin/Der Buchtitel (1)',
                                                    'cover.jpg').replace('\\', '/')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Hector gonçalves/book9 (11)',
                                                    'book9 - Hector gonçalves.pdf').replace('\\', '/')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Hector gonçalves/book9 (11)',
                                                    'cover.jpg').replace('\\', '/')))
        # Check that name of author folder no longer is "Hector Gonçalves"
        self.assertNotEqual("Hector Gonçalves",
                            fs.getinfo(os.path.join('test', 'Hector Gonçalves').replace('\\', '/')).name)

        ret_code, content = self.download_book(1, "admin", "admin123")
        self.assertEqual(200, ret_code)
        ret_code, content = self.download_book(11, "admin", "admin123")
        self.assertEqual(200, ret_code)

        # rename book title and author in the same step
        self.edit_book(1, content={'bookAuthor': "Frodo Beutlin & Norbert Halagal & Liu Yang & Hector Gonçalves",
                                   'book_title': 'Derbook 1'})
        self.assertFalse(self.check_element_on_page((By.ID, "flash_danger")))
        time.sleep(WAIT_GDRIVE)
        details = self.get_book_details(-1)
        self.assertEqual(['Frodo Beutlin', 'Norbert Halagal', 'Liu Yang', 'Hector Gonçalves'], details['author'])
        self.assertEqual('Derbook 1', details['title'])
        self.assertTrue(fs.isfile(os.path.join('test', 'Frodo Beutlin/Derbook 1 (1)',
                                                    'Derbook 1 - Frodo Beutlin.txt').replace('\\', '/')))
        self.assertFalse(fs.isfile(os.path.join('test', 'Frodo Beutlin/Derbook 1 (1)',
                                                    'cover.jpg').replace('\\', '/')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Hector Gonçalves/book9 (11)',
                                                    'book9 - Hector Gonçalves.pdf').replace('\\', '/')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Hector Gonçalves/book9 (11)',
                                                    'cover.jpg').replace('\\', '/')))
        ret_code, content = self.download_book(1, "admin", "admin123")
        self.assertEqual(200, ret_code)
        ret_code, content = self.download_book(11, "admin", "admin123")
        self.assertEqual(200, ret_code)

        # rename only book title
        self.edit_book(1, content={'book_title': 'Der Buchtitel'})
        self.assertFalse(self.check_element_on_page((By.ID, "flash_danger")))
        time.sleep(WAIT_GDRIVE)
        details = self.get_book_details(-1)
        self.assertEqual(['Frodo Beutlin', 'Norbert Halagal', 'Liu Yang', 'Hector Gonçalves'], details['author'])
        self.assertEqual('Der Buchtitel', details['title'])
        self.assertFalse(fs.isfile(os.path.join('test', 'Frodo Beutlin/Der Buchtitel (1)',
                                                    'cover.jpg').replace('\\', '/')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Frodo Beutlin/Der Buchtitel (1)',
                                                    'Der Buchtitel - Frodo Beutlin.txt').replace('\\', '/')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Hector Gonçalves/book9 (11)',
                                                    'book9 - Hector Gonçalves.pdf').replace('\\', '/')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Hector Gonçalves/book9 (11)',
                                                    'cover.jpg').replace('\\', '/')))
        ret_code, content = self.download_book(1, "admin", "admin123")
        self.assertEqual(200, ret_code)
示例#7
0
    def test_change_capital_one_author_two_books(self):
        fs = connect_gdrive("test")
        self.assertTrue(fs.isfile(os.path.join('test', 'Norbert Halagal/book11 (13)',
                                                    'cover.jpg').replace('\\', '/')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Norbert Halagal/book11 (13)',
                                                    'book11 - Norbert Halagal.pdf').replace('\\', '/')))
        # rename uppercase to lowercase only of author
        self.edit_book(13, content={'bookAuthor': "Norbert halagal"})
        self.assertFalse(self.check_element_on_page((By.ID, "flash_danger")))
        time.sleep(WAIT_GDRIVE)
        details = self.get_book_details(-1)
        self.assertEqual(['Norbert halagal'], details['author'])
        self.assertTrue(fs.isfile(os.path.join('test', 'Norbert halagal/book11 (13)',
                                                    'book11 - Norbert halagal.pdf').replace('\\', '/')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Norbert halagal/book11 (13)',
                                                    'cover.jpg').replace('\\', '/')))
        # Check that name of author folder no longer is "Peter parker"
        self.assertNotEqual("Norbert Halagal",
                            fs.getinfo(os.path.join('test', 'Norbert Halagal').replace('\\', '/')).name)
        details = self.get_book_details(1)
        self.assertCountEqual(['Frodo Beutlin', 'Norbert halagal', 'Liu Yang', 'Hector Gonçalves'], details['author'])
        ret_code, content = self.download_book(13, "admin", "admin123")
        self.assertEqual(200, ret_code)
        ret_code, content = self.download_book(1, "admin", "admin123")
        self.assertEqual(200, ret_code)

        # rename book title and author in the same step
        self.edit_book(13, content={'bookAuthor': "Norbert Halagal", 'book_title': 'book 11'})
        self.assertFalse(self.check_element_on_page((By.ID, "flash_danger")))
        time.sleep(WAIT_GDRIVE)
        details = self.get_book_details(-1)
        self.assertEqual(['Norbert Halagal'], details['author'])
        self.assertEqual('book 11', details['title'])
        self.assertTrue(fs.isfile(os.path.join('test', 'Norbert Halagal/book 11 (13)',
                                                    'book 11 - Norbert Halagal.pdf').replace('\\', '/')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Norbert Halagal/book 11 (13)',
                                                    'cover.jpg').replace('\\', '/')))
        # Check that name of author folder no longer is "Norbert halagal"
        self.assertNotEqual("Norbert halagal",
                            fs.getinfo(os.path.join('test', 'Norbert halagal').replace('\\', '/')).name)

        ret_code, content = self.download_book(13, "admin", "admin123")
        self.assertEqual(200, ret_code)
        ret_code, content = self.download_book(1, "admin", "admin123")
        self.assertEqual(200, ret_code)
        # rename only book title
        self.edit_book(13, content={'book_title': 'book11'})
        self.assertFalse(self.check_element_on_page((By.ID, "flash_danger")))
        time.sleep(WAIT_GDRIVE)
        details = self.get_book_details(-1)
        self.assertEqual(['Norbert Halagal'], details['author'])
        self.assertEqual('book11', details['title'])
        self.assertTrue(fs.isfile(os.path.join('test', 'Norbert Halagal/book11 (13)',
                                                    'book11 - Norbert Halagal.pdf').replace('\\', '/')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Norbert Halagal/book11 (13)',
                                                    'cover.jpg').replace('\\', '/')))
        # Check that name of author folder no longer is "Norbert halagal"
        self.assertNotEqual("Norbert halagal",
                            fs.getinfo(os.path.join('test', 'Norbert halagal').replace('\\', '/')).name)

        ret_code, content = self.download_book(13, "admin", "admin123")
        self.assertEqual(200, ret_code)
示例#8
0
    def test_change_capital_one_author_two_books(self):
        fs = connect_gdrive("test")
        self.assertTrue(fs.isfile(os.path.join('test', 'Peter Parker/book7 (10)',
                                                    'cover.jpg')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Peter Parker/book7 (10)',
                                                    'book7 - Peter Parker.epub').replace('\\', '/')))
        # rename uppercase to lowercase only of author
        self.edit_book(10, content={'bookAuthor': "Peter parker"})
        self.assertFalse(self.check_element_on_page((By.ID, "flash_danger")))
        time.sleep(WAIT_GDRIVE)
        details = self.get_book_details(-1)
        self.assertEqual(['Peter parker'], details['author'])
        self.assertTrue(fs.isfile(os.path.join('test', 'Peter parker/book7 (10)',
                                                    'book7 - Peter parker.epub').replace('\\', '/')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Peter parker/book7 (10)',
                                                    'cover.jpg').replace('\\', '/')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Peter parker/Very long extra super turbo cool tit (4)',
                                                    'cover.jpg').replace('\\', '/')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Peter parker/Very long extra super turbo cool tit (4)',
                                                    'Very long extra super turbo cool title wit - Peter parker.pdf')
                                  .replace('\\', '/')))
        # Check that name of author folder no longer is "Peter Parker"
        self.assertNotEqual("Peter Parker",
                            fs.getinfo(os.path.join('test', 'Peter Parker').replace('\\', '/')).name)
        ret_code, content = self.download_book(10, "admin", "admin123")
        self.assertEqual(200, ret_code)
        ret_code, content = self.download_book(4, "admin", "admin123")
        self.assertEqual(200, ret_code)
        # rename book title and author in the same step
        self.edit_book(10, content={'bookAuthor': "Peter Parker", 'book_title': 'book 7'})
        self.assertFalse(self.check_element_on_page((By.ID, "flash_danger")))
        time.sleep(WAIT_GDRIVE)
        details = self.get_book_details(-1)
        self.assertEqual(['Peter Parker'], details['author'])
        self.assertEqual('book 7', details['title'])
        self.assertTrue(fs.isfile(os.path.join('test', 'Peter Parker/book 7 (10)',
                                                    'book 7 - Peter Parker.epub').replace('\\', '/')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Peter Parker/book 7 (10)',
                                                    'cover.jpg').replace('\\', '/')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Peter Parker/Very long extra super turbo cool tit (4)',
                                                    'cover.jpg').replace('\\', '/')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Peter Parker/Very long extra super turbo cool tit (4)',
                                                    'Very long extra super turbo cool title wit - Peter Parker.pdf')
                                  .replace('\\', '/')))
        # Check that name of author folder no longer is "Peter parker"
        self.assertNotEqual("Peter parker",
                            fs.getinfo(os.path.join('test', 'Peter parker').replace('\\', '/')).name)
        ret_code, content = self.download_book(10, "admin", "admin123")
        self.assertEqual(200, ret_code)
        ret_code, content = self.download_book(4, "admin", "admin123")
        self.assertEqual(200, ret_code)
        # rename only book title
        self.edit_book(10, content={'bookAuthor': "Peter Parker", 'book_title': 'book7'})
        self.assertFalse(self.check_element_on_page((By.ID, "flash_danger")))
        time.sleep(WAIT_GDRIVE)
        details = self.get_book_details(-1)
        self.assertEqual(['Peter Parker'], details['author'])
        self.assertEqual('book7', details['title'])
        self.assertTrue(fs.isfile(os.path.join('test', 'Peter Parker/book7 (10)',
                                                    'book7 - Peter Parker.epub').replace('\\', '/')))
        self.assertTrue(fs.isfile(os.path.join('test', 'Peter Parker/book7 (10)',
                                                    'cover.jpg').replace('\\', '/')))
        # Check that name of author folder no longer is "Peter parker"
        self.assertNotEqual("Peter parker",
                            fs.getinfo(os.path.join('test', 'Peter parker').replace('\\', '/')).name)

        ret_code, content = self.download_book(8, "admin", "admin123")
        self.assertEqual(200, ret_code)
 def test_watch_metadata(self):
     # enable watch metadata
     self.goto_page("db_config")
     button = self.check_element_on_page((By.ID, "enable_gdrive_watch"))
     self.assertTrue(button)
     button.click()
     self.wait_page_has_loaded()
     time.sleep(5)
     self.assertTrue(
         self.check_element_on_page(
             (By.ID, "config_google_drive_watch_changes_response")))
     # Check revoke is working
     revoke = self.check_element_on_page((By.ID, "watch_revoke"))
     self.assertTrue(revoke)
     revoke.click()
     self.wait_page_has_loaded()
     time.sleep(5)
     button = self.check_element_on_page((By.ID, "enable_gdrive_watch"))
     self.assertTrue(button)
     button.click()
     self.wait_page_has_loaded()
     time.sleep(5)
     # change book series content
     self.edit_book(5, content={'series': 'test'})
     self.wait_page_has_loaded()
     time.sleep(10)
     book = self.get_book_details(-1)
     self.assertEqual(book['series'], 'test')
     # upload new metadata.db from outside
     fs = connect_gdrive("test")
     # upload unchanged database from hdd -> watch metadata should recognize this and replace current
     # used metadata.db
     metadata = open(os.path.join(base_path, 'Calibre_db', 'metadata.db'),
                     'rb')
     fs.upload(
         os.path.join('test', 'metadata.db').replace('\\', '/'), metadata)
     metadata.close()
     loop = 0
     while loop < 3:
         loop += 1
         # wait a bit
         time.sleep(5)
         self.wait_page_has_loaded()
         time.sleep(10)
         # check book series content changed back
         book = self.get_book_details(5)
         if 'series' not in book:
             break
     self.assertNotIn('series', book)
     self.goto_page("db_config")
     self.wait_page_has_loaded()
     time.sleep(5)
     self.assertTrue(
         self.check_element_on_page(
             (By.ID, "config_google_drive_watch_changes_response")))
     # Check revoke is working
     revoke = self.check_element_on_page((By.ID, "watch_revoke"))
     self.assertTrue(revoke)
     revoke.click()
     self.wait_page_has_loaded()
     time.sleep(5)
    def test_edit_author(self):
        self.fill_basic_config({"config_unicode_filename": 1})
        self.check_element_on_page((By.ID, 'flash_success'))
        fs = connect_gdrive("test")
        self.get_book_details(8)
        self.check_element_on_page((By.ID, "edit_book")).click()
        self.wait_page_has_loaded()
        self.edit_book(content={'bookAuthor': u'O0ü 执'})
        self.wait_page_has_loaded()
        values = self.get_book_details()
        self.assertEqual(u'O0ü 执', values['author'][0])
        new_book_path = os.path.join('test', 'O0u Zhi',
                                     'book8 (8)').replace('\\', '/')
        gdrive_path = check_path_gdrive(fs, new_book_path)
        self.assertTrue(gdrive_path)
        old_book_path = os.path.join('test', 'Leo Baskerville',
                                     'book8 (8)').replace('\\', '/')
        gdrive_path = check_path_gdrive(fs, old_book_path)
        self.assertFalse(gdrive_path)

        self.check_element_on_page((By.ID, "edit_book")).click()
        self.edit_book(content={'bookAuthor': ' O0ü name '}, detail_v=True)
        self.wait_page_has_loaded()
        self.check_element_on_page((By.ID, 'flash_success'))
        author = self.check_element_on_page((By.ID, "bookAuthor"))
        # calibre strips spaces in the end
        self.assertEqual(u'O0ü name', author.get_attribute('value'))
        # self.assertTrue(os.path.isdir(os.path.join(TEST_DB, 'O0u name', 'book8 (8)')))
        new_book_path = os.path.join('test', 'O0u name',
                                     'book8 (8)').replace('\\', '/')
        gdrive_path = check_path_gdrive(fs, new_book_path)
        self.assertTrue(gdrive_path)

        self.edit_book(content={'bookAuthor': ''})
        self.wait_page_has_loaded()
        values = self.get_book_details()
        # os.path.join(TEST_DB, 'Unknown', 'book8 (8)')
        self.assertEqual('Unknown', values['author'][0])
        # self.assertTrue(os.path.isdir(os.path.join(TEST_DB, values['author'][0], 'book8 (8)')))
        new_book_path = os.path.join('test', values['author'][0],
                                     'book8 (8)').replace('\\', '/')
        gdrive_path = check_path_gdrive(fs, new_book_path)
        self.assertTrue(gdrive_path)

        self.check_element_on_page((By.ID, "edit_book")).click()
        # Check authorsort
        self.edit_book(content={'bookAuthor': 'Marco, Lulu de'})
        self.wait_page_has_loaded()
        values = self.get_book_details()
        # os.path.join(TEST_DB, values['author'][0], 'book8 (8)')
        self.assertEqual(values['author'][0], 'Marco, Lulu de')
        list_element = self.goto_page('nav_author')
        # ToDo check names of List elements
        self.get_book_details(8)
        self.check_element_on_page((By.ID, "edit_book")).click()

        self.edit_book(content={'bookAuthor': 'Sigurd Lindgren'},
                       detail_v=True)
        self.wait_page_has_loaded()
        self.check_element_on_page((By.ID, 'flash_success'))
        author = self.check_element_on_page(
            (By.ID, "bookAuthor")).get_attribute('value')
        self.assertEqual(u'Sigurd Lindgren', author)
        new_book_path = os.path.join('test', author,
                                     'book8 (8)').replace('\\', '/')
        gdrive_path = check_path_gdrive(fs, new_book_path)
        self.assertTrue(gdrive_path)

        # self.assertTrue(os.path.isdir(os.path.join(TEST_DB, author, 'book8 (8)')))
        self.edit_book(
            content={'bookAuthor': 'Sigurd Lindgren&Leo Baskerville'},
            detail_v=True)
        self.wait_page_has_loaded()
        self.check_element_on_page((By.ID, 'flash_success'))
        new_book_path = os.path.join('test', 'Sigurd Lindgren',
                                     'book8 (8)').replace('\\', '/')
        gdrive_path = check_path_gdrive(fs, new_book_path)
        self.assertTrue(gdrive_path)
        old_book_path = os.path.join('test', 'Leo Baskerville',
                                     'book8 (8)').replace('\\', '/')
        gdrive_path = check_path_gdrive(fs, old_book_path)
        self.assertFalse(gdrive_path)

        author = self.check_element_on_page((By.ID, "bookAuthor"))
        self.assertEqual(u'Sigurd Lindgren & Leo Baskerville',
                         author.get_attribute('value'))
        self.edit_book(
            content={'bookAuthor': ' Leo Baskerville & Sigurd Lindgren '},
            detail_v=True)
        self.wait_page_has_loaded()
        self.check_element_on_page((By.ID, 'flash_success'))

        new_book_path = os.path.join('test', 'Leo Baskerville',
                                     'book8 (8)').replace('\\', '/')
        gdrive_path = check_path_gdrive(fs, new_book_path)
        self.assertTrue(gdrive_path)
        old_book_path = os.path.join('test', 'Sigurd Lindgren',
                                     'book8 (8)').replace('\\', '/')
        gdrive_path = check_path_gdrive(fs, old_book_path)
        self.assertFalse(gdrive_path)
        time.sleep(5)
        self.edit_book(content={'bookAuthor': 'Pipo| Pipe'}, detail_v=True)
        time.sleep(4)
        self.wait_page_has_loaded()
        self.check_element_on_page((By.ID, 'flash_success'))
        author = self.check_element_on_page((By.ID, "bookAuthor"))
        self.assertEqual(u'Pipo, Pipe', author.get_attribute('value'))
        self.goto_page('nav_author')

        file_path = os.path.join('test', 'Pipo, Pipe',
                                 'book8 (8)').replace('\\', '/')
        not_file_path = os.path.join('test', 'Pipo, Pipe',
                                     'nofolder').replace('\\', '/')
        fs.movedir(file_path, not_file_path, create=True)
        self.get_book_details(8)
        self.check_element_on_page((By.ID, "edit_book")).click()
        self.edit_book(content={'bookAuthor': u'Not found'})
        time.sleep(WAIT_GDRIVE)
        self.wait_page_has_loaded()
        self.check_element_on_page((By.ID, 'flash_danger'))
        values = self.get_book_details(8)
        self.assertEqual(values['author'][0], 'Pipo, Pipe')
        fs.movedir(not_file_path, file_path, create=True)
        fs.close()
        self.check_element_on_page((By.ID, "edit_book")).click()
        self.edit_book(content={'bookAuthor': 'Leo Baskerville'},
                       detail_v=True)
        self.wait_page_has_loaded()
        time.sleep(5)
        self.check_element_on_page((By.ID, 'flash_success'))
        self.fill_basic_config({"config_unicode_filename": 0})
        self.check_element_on_page((By.ID, 'flash_success'))
    def test_edit_title(self):
        self.fill_basic_config({"config_unicode_filename": 1})
        self.check_element_on_page((By.ID, 'flash_success'))
        fs = connect_gdrive("test")
        self.get_book_details(4)
        self.check_element_on_page((By.ID, "edit_book")).click()
        self.wait_page_has_loaded()
        self.edit_book(content={'book_title': u'O0ü 执'})
        self.wait_page_has_loaded()
        values = self.get_book_details()
        self.assertEqual(u'O0ü 执', values['title'])
        new_book_path = os.path.join('test', values['author'][0],
                                     'O0u Zhi (4)').replace('\\', '/')
        gdrive_path = check_path_gdrive(fs, new_book_path)
        self.assertTrue(gdrive_path)
        old_book_path = os.path.join(
            'test', values['author'][0],
            'Very long extra super turbo cool tit (4)').replace('\\', '/')
        gdrive_path = check_path_gdrive(fs, old_book_path)
        self.assertFalse(gdrive_path)
        self.check_element_on_page((By.ID, "edit_book")).click()
        self.wait_page_has_loaded()
        # file operation
        fout = io.BytesIO()
        fout.write(os.urandom(124))
        fs.upload(
            os.path.join('test', values['author'][0], 'O0u Zhi (4)',
                         'test.dum').replace('\\', '/'), fout)
        fout.close()
        self.edit_book(content={'book_title': u' O0ü 执'}, detail_v=True)
        self.wait_page_has_loaded()
        self.assertTrue(self.check_element_on_page((By.ID, 'flash_success')))
        title = self.check_element_on_page((By.ID, "book_title"))
        # calibre strips spaces in beginning
        self.assertEqual(u'O0ü 执', title.get_attribute('value'))
        new_book_path = os.path.join('test', values['author'][0],
                                     'O0u Zhi (4)').replace('\\', '/')
        gdrive_path = check_path_gdrive(fs, new_book_path)
        self.wait_page_has_loaded()
        self.edit_book(content={'book_title': u'O0ü name'}, detail_v=True)
        self.wait_page_has_loaded()
        self.assertTrue(self.check_element_on_page((By.ID, 'flash_success')))
        title = self.check_element_on_page((By.ID, "book_title"))
        # calibre strips spaces in the end
        self.assertEqual(u'O0ü name', title.get_attribute('value'))
        new_book_path = os.path.join('test', values['author'][0],
                                     'O0u name (4)').replace('\\', '/')
        gdrive_path = check_path_gdrive(fs, new_book_path)
        self.assertTrue(gdrive_path)
        # self.assertFalse(os.path.isdir(os.path.join(TEST_DB, values['author'][0], 'O0u Zhi (4)')))
        old_book_path = os.path.join('test', values['author'][0],
                                     'O0u Zhi (4)').replace('\\', '/')
        gdrive_path = check_path_gdrive(fs, old_book_path)
        self.assertFalse(gdrive_path)

        self.edit_book(content={'book_title': ''})
        self.wait_page_has_loaded()
        time.sleep(2)
        values = self.get_book_details()
        # os.path.join(TEST_DB, values['author'][0], 'Unknown')
        self.assertEqual('Unknown', values['title'])
        # self.assertTrue(os.path.isdir(os.path.join(TEST_DB, values['author'][0], 'Unknown (4)')))
        new_book_path = os.path.join('test', values['author'][0],
                                     'Unknown (4)').replace('\\', '/')
        gdrive_path = check_path_gdrive(fs, new_book_path)
        self.assertTrue(gdrive_path)
        old_book_path = os.path.join('test', values['author'][0],
                                     'Unknown').replace('\\', '/')
        gdrive_path = check_path_gdrive(fs, old_book_path)
        self.assertFalse(gdrive_path)
        self.check_element_on_page((By.ID, "edit_book")).click()
        self.wait_page_has_loaded()
        self.edit_book(content={'book_title': 'The camicdemo'})
        self.wait_page_has_loaded()
        values = self.get_book_details()
        self.assertEqual('The camicdemo', values['title'])
        self.goto_page('nav_new')
        self.wait_page_has_loaded()
        books = self.get_books_displayed()
        self.assertEqual('The camicdemo', books[1][8]['title'])
        file_path = os.path.join('test', values['author'][0],
                                 'The camicdemo (4)').replace('\\', '/')
        not_file_path = os.path.join('test', values['author'][0],
                                     'camicdemo').replace('\\', '/')

        # file operation
        fs.movedir(file_path, not_file_path, create=True)
        self.get_book_details(4)
        self.check_element_on_page((By.ID, "edit_book")).click()
        self.wait_page_has_loaded()
        self.edit_book(content={'book_title': u'Not found'})
        self.wait_page_has_loaded()
        time.sleep(4)
        self.check_element_on_page((By.ID, 'flash_danger'))
        values = self.get_book_details(4)
        # title = self.check_element_on_page((By.ID, "book_title"))
        # calibre strips spaces in the end
        self.assertEqual('The camicdemo', values['title'])
        # file operation
        fs.movedir(not_file_path, file_path, create=True)
        # missing cover file is not detected, and cover file is moved
        cover_file = os.path.join('test', values['author'][0],
                                  'The camicdemo (4)',
                                  'cover.jpg').replace('\\', '/')
        not_cover_file = os.path.join('test', values['author'][0],
                                      'The camicdemo (4)',
                                      'no_cover.jpg').replace('\\', '/')

        # file operation
        fs.move(cover_file, not_cover_file)
        self.check_element_on_page((By.ID, "edit_book")).click()
        self.edit_book(content={'book_title': u'No Cover'}, detail_v=True)
        self.wait_page_has_loaded()
        self.check_element_on_page((By.ID, 'flash_success'))
        title = self.check_element_on_page((By.ID, "book_title"))
        self.assertEqual('No Cover', title.get_attribute('value'))
        cover_file = os.path.join('test', values['author'][0], 'No Cover (4)',
                                  'cover.jpg').replace('\\', '/')
        not_cover_file = os.path.join('test', values['author'][0],
                                      'No Cover (4)',
                                      'no_cover.jpg').replace('\\', '/')

        fs.move(not_cover_file, cover_file)
        fs.close()
        self.edit_book(content={'book_title': u'Pipo|;.:'}, detail_v=True)
        self.wait_page_has_loaded()
        self.check_element_on_page((By.ID, 'flash_success'))
        title = self.check_element_on_page((By.ID, "book_title"))
        self.assertEqual(u'Pipo|;.:', title.get_attribute('value'))
        self.edit_book(
            content={
                'book_title':
                u'Very long extra super turbo cool title without any issue of displaying including ö utf-8 characters'
            })
        time.sleep(5)
        self.wait_page_has_loaded()
        ele = self.check_element_on_page((By.ID, "title"))
        self.assertEqual(
            ele.text,
            u'Very long extra super turbo cool title without any issue of displaying including ö utf-8 characters'
        )
        self.wait_page_has_loaded()
        self.check_element_on_page((By.ID, "edit_book")).click()
        self.edit_book(content={'book_title': u'book6'})
        self.wait_page_has_loaded()
        self.fill_basic_config({"config_unicode_filename": 0})
        self.check_element_on_page((By.ID, 'flash_success'))