Compare commits
6 Commits
e65e16d37b
...
main
Author | SHA1 | Date | |
---|---|---|---|
6095290195 | |||
afd46ee7d2 | |||
59f8adf860 | |||
4623f63bed | |||
074cb16b1c | |||
92dace165b |
@ -8,4 +8,7 @@ charset = utf-8
|
|||||||
|
|
||||||
[*.py]
|
[*.py]
|
||||||
indent_style = space
|
indent_style = space
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
|
|
||||||
|
[Makefile]
|
||||||
|
indent_size = tab
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,3 +1,5 @@
|
|||||||
.vscode
|
.vscode
|
||||||
dist
|
dist
|
||||||
src/*.egg-info
|
src/*.egg-info
|
||||||
|
__pycache__
|
||||||
|
.pytest_cache
|
7
Makefile
Normal file
7
Makefile
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
init:
|
||||||
|
pip install -r requirements.txt
|
||||||
|
|
||||||
|
test:
|
||||||
|
py.test tests
|
||||||
|
|
||||||
|
.PHONY: init test
|
@ -3,6 +3,7 @@ Manga checker and downloader
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
import os
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
@ -18,4 +19,11 @@ if __name__ == '__main__':
|
|||||||
'-n', '--notify', type=str, default=None, help="Apprise notification string."
|
'-n', '--notify', type=str, default=None, help="Apprise notification string."
|
||||||
)
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
destination = os.path.abspath(args.destination)
|
||||||
|
|
||||||
|
if not os.path.exists(destination):
|
||||||
|
print(f'Destination {destination} does not exist.')
|
||||||
|
if not os.path.isdir(destination):
|
||||||
|
print(f'Destination {destination} is not a directory.')
|
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
29
tests/test_arguments.py
Normal file
29
tests/test_arguments.py
Normal file
@ -0,0 +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()
|
Reference in New Issue
Block a user