add tests for cli parser behaviour

This commit is contained in:
Rémi TAUVEL 2022-12-14 09:15:06 +01:00
parent 2a2d0dbdbb
commit f00dfea85b
3 changed files with 56 additions and 2 deletions

View File

@ -12,8 +12,6 @@ usage: delarte [-h|--help] - print this message
import sys
import time
from pprint import pprint
from . import api
from . import hls
from . import muxing

0
tests/__init__.py Normal file
View File

56
tests/tests_cli_parser.py Normal file
View File

@ -0,0 +1,56 @@
"""test for command-line args parser
"""
from unittest import TestCase, mock
import argparse
from src.delarte.cli_parser import create_parser, get_args_as_list
class TestCliParser(TestCase):
def setUp(self):
self.parser = create_parser()
def tearDown(self):
self.parser = None
def test_args_parse(self):
args = vars(
self.parser.parse_args(
[
"https://www.arte.tv/en/videos/104001-000-A/clint-eastwood/",
"-l",
"VOF-STMF",
"-r",
"216p",
],
)
)
self.assertEqual(
args,
{
"languages": "VOF-STMF",
"resolution": "216p",
"url": "https://www.arte.tv/en/videos/104001-000-A/clint-eastwood/",
},
)
@mock.patch(
"argparse.ArgumentParser.parse_args",
return_value=argparse.Namespace(
url="https://www.arte.tv/en/videos/104001-000-A/clint-eastwood/",
languages="VOF-STMF",
resolution="216p",
),
)
def test_get_args_as_list(self, *mock_args):
args = get_args_as_list(self.parser)
self.assertEqual(
args,
[
"https://www.arte.tv/en/videos/104001-000-A/clint-eastwood/",
"VOF-STMF",
"216p",
],
)