aristippe / pathagar

Pathagar is a simple bookserver serving OPDS feeds
GNU General Public License v2.0
1 stars 1 forks source link

Add symbolic link option for storing epubs, tests #20

Closed sinergatis closed 8 years ago

sinergatis commented 8 years ago

This pull request, meant to works towards solving #1:

        > storage = LinkOrFileSystemStorage(...)
        > storage.save('x/symlink_file', LinkableFile(open('/x/srcfile')))
        > storage.save('x/regular_file', File(open('/x/srcfile')))

        'x/symlink_file' == symbolic link to /x/srcfile
        'x/regular_file' == copy of /x/srcfile

As a bonus, it includes 4 sample epubs in the repository (2 from https://github.com/IDPF/epub3-samples, 2 custom-made invalid ones, as an initial step for #6) and includes some basic black-box tests for addepub.

Please note that the tests are rather raw at the moment, making some essential assertions on the generation of Books and the creation of files, and they involve the mock library in order to be able to simulate the django.test.utils.override_settings() decorator, which seems not to be working on custom storages (using the decorator caused the tests to write the epubs to the real MEDIA_ROOT, which was quite messy). The good thing is that by installing the mock library (pip install mock - I deliberately left it outside of requirements.txt, as it is a test dependency and not a real dependency), something like: $ python manage.py test books

should take care of automatically testing both copy and link modes with the sample epubs.