Book Table of Content (TOC)
Now our book has some xhtml files so we need generate toc and tell client:
It can work but I think it should in BookVIewSet because they have closely connection.
Some test case meet error
After create book we will trigger a sender to split epub file. We need to redesign test case.
def test_split_book_after_create_book(self):
f = DjangoFile(open(test_book_path, mode='rb'))
book = Book.objects.create(title=test_book_title, owner_id=self.defaultUser.id, filename=f)
self.assertTrue(book)
But:
django.core.exceptions.SuspiciousFileOperation: The joined path (F:\projects\ulibrary-django-server\ulibrary\tests\The_Sense_of_Style.epub) is located outside of the base path component (F:\projects\ulibrary-django-server\upload)
we need to move test file into MEDIA_ROOT folder.
Here has a pitfall.After split epub file we will save those file to epub_chapters folder with Book instance id.When we run test, it will also save file into epub_chapters and it may have bad effect in those folder.(production enviroment will not run test but we need to notice it)
So we can override_settings when we run test:
⚠ Be careful you should import settings from django.conf and DO NOT import your self settings.
override_settingswill only works on djang.conf settings. It waste me 1h time.