mirror of
https://github.com/santinic/audiblez.git
synced 2025-09-18 21:40:39 +00:00
more tests
This commit is contained in:
parent
0580a9b337
commit
4f295c2b97
3 changed files with 57 additions and 2 deletions
|
@ -235,7 +235,7 @@ def create_m4b(chapter_files, filename, cover_image, output_folder):
|
|||
combined_audio += audio
|
||||
print('Converting to Mp4...')
|
||||
combined_audio.export(tmp_file_path, format="mp4", codec="aac", bitrate="64k")
|
||||
final_filename = filename.replace('.epub', '.m4b')
|
||||
final_filename = Path(output_folder) / filename.replace('.epub', '.m4b')
|
||||
print('Creating M4B file...')
|
||||
|
||||
if cover_image:
|
||||
|
@ -248,6 +248,7 @@ def create_m4b(chapter_files, filename, cover_image, output_folder):
|
|||
|
||||
proc = subprocess.run([
|
||||
'ffmpeg',
|
||||
'-y',
|
||||
'-i', f'{tmp_file_path}',
|
||||
'-i', 'chapters.txt',
|
||||
*cover_image_args,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env python3
|
||||
# This is a simple wxWidgets UI for audiblez
|
||||
# A simple wxWidgets UI for audiblez
|
||||
import io
|
||||
import os
|
||||
import subprocess
|
||||
|
|
54
test/test_cli.py
Normal file
54
test/test_cli.py
Normal file
|
@ -0,0 +1,54 @@
|
|||
import os
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from tempfile import NamedTemporaryFile
|
||||
|
||||
|
||||
class CliTest(unittest.TestCase):
|
||||
def cli(self, args):
|
||||
cmd = f'cd .. && python -m audiblez.cli {args}'
|
||||
f = os.popen(cmd)
|
||||
out, ret = f.read(), f.close()
|
||||
return out, ret
|
||||
|
||||
def test_help(self):
|
||||
out, ret = self.cli('--help')
|
||||
self.assertIn('af_sky', out)
|
||||
self.assertIn('usage:', out)
|
||||
self.assertEqual(ret, None)
|
||||
|
||||
def test_epub(self):
|
||||
out, ret = self.cli('epub/mini.epub')
|
||||
self.assertIn('Found cover image', out)
|
||||
self.assertIn('Creating M4B file', out)
|
||||
self.assertEqual(ret, None)
|
||||
self.assertTrue(Path('../mini.m4b').exists())
|
||||
self.assertTrue(Path('../mini.m4b').stat().st_size > 256 * 1024)
|
||||
|
||||
def test_epub_voice_and_output_folder(self):
|
||||
out, ret = self.cli('epub/mini.epub -v af_sky -o prova')
|
||||
self.assertIn('Found cover image', out)
|
||||
self.assertIn('Creating M4B file', out)
|
||||
self.assertEqual(ret, None)
|
||||
self.assertTrue(Path('../prova/mini.m4b').exists())
|
||||
self.assertTrue(Path('../prova/mini.m4b').stat().st_size > 256 * 1024)
|
||||
|
||||
def test_md(self):
|
||||
out, ret = self.cli('markdown.md')
|
||||
self.assertIn('Creating M4B file', out)
|
||||
self.assertEqual(ret, None)
|
||||
self.assertTrue(Path('markdown.mp4').exists())
|
||||
self.assertTrue(Path('markdown.mp4').stat().st_size > 256 * 1024)
|
||||
|
||||
def test_txt(self):
|
||||
content = (
|
||||
'Italy, officially the Italian Republic, is a country in Southern and Western Europe. '
|
||||
'It consists of a peninsula that extends into the Mediterranean Sea, '
|
||||
'with the Alps on its northern land border, '
|
||||
'as well as nearly 800 islands, notably Sicily and Sardinia.')
|
||||
file_name = NamedTemporaryFile('w', suffix='.txt', delete=False).write(content)
|
||||
out, ret = self.cli(file_name)
|
||||
self.assertIn('Creating M4B file', out)
|
||||
self.assertEqual(ret, None)
|
||||
self.assertTrue(Path('text.mp4').exists())
|
||||
self.assertTrue(Path('text.mp4').stat().st_size > 256 * 1024)
|
Loading…
Add table
Reference in a new issue