manga_up/tests/test_arguments.py

29 lines
840 B
Python
Raw Normal View History

2021-06-25 17:58:08 +00:00
from subprocess import CalledProcessError
import unittest
2021-06-25 18:45:49 +00:00
import subprocess
2021-06-25 19:37:16 +00:00
import os
2021-06-25 17:58:08 +00:00
2021-06-25 18:45:49 +00:00
class ArgumentTestClass(unittest.TestCase):
2021-06-25 17:58:08 +00:00
2021-06-25 19:37:16 +00:00
def setUp(self):
import tempfile
self.existing_dir = tempfile.mkdtemp()
2021-06-25 17:58:08 +00:00
def test_argument_required(self):
with self.assertRaises(CalledProcessError):
subprocess.check_output(['python', 'manga_up'])
2021-06-25 19:37:16 +00:00
def test_destination_exists(self):
result = subprocess.check_output(['python', 'manga_up', '--destination', 'nonexistent'])
self.assertIn('does not exist', str(result))
def test_destination_is_not_directory(self):
result = subprocess.check_output(['python', 'manga_up', '--destination', self.existing_file])
self.assertIn('not a directory', str(result))
def tearDown(self) -> None:
os.rmdir(self.existing_dir)
2021-06-25 17:58:08 +00:00
if __name__ == '__main__':
unittest.main()