test: check if destination exists

This commit is contained in:
2021-06-25 21:37:16 +02:00
parent afd46ee7d2
commit 6095290195
2 changed files with 25 additions and 1 deletions

View File

@ -1,13 +1,29 @@
from subprocess import CalledProcessError
import unittest
import subprocess
import os
class ArgumentTestClass(unittest.TestCase):
def setUp(self):
import tempfile
self.existing_dir = tempfile.mkdtemp()
def test_argument_required(self):
with self.assertRaises(CalledProcessError):
subprocess.check_output(['python', 'manga_up'])
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)
if __name__ == '__main__':
unittest.main()