Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests #4

Merged
merged 4 commits into from
Oct 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ ab.text_to_speech()

The audiobook is a python module to listen to your fav pdf book.

## Test

Run tests:

```sh
pip install -r requirements.txt
python -m unittest tests
```

## Documentation

Read Detailed [Documentation here](https://audiobook.readthedocs.io/)
Expand Down
1 change: 1 addition & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .test_audiobook import * # noqa
25 changes: 25 additions & 0 deletions tests/test_audiobook.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from audiobook import AudioBook
import unittest
from PyPDF2.utils import PdfReadError


class TestAudioBook(unittest.TestCase):
def test_invalidPathNumeric(self):
with self.assertRaises(IOError):
ab = AudioBook(123)
ab.text_to_speech()

def test_openDirectory(self):
with self.assertRaises(IsADirectoryError):
ab = AudioBook('/')
ab.text_to_speech()

def test_fileDoesNotExist(self):
with self.assertRaises(FileNotFoundError):
ab = AudioBook('oiawhgaiurgieurghergerg')
ab.text_to_speech()

def test_fileIsNotPDF(self):
with self.assertRaises(PdfReadError):
ab = AudioBook(__file__)
ab.text_to_speech()