mirror of
https://github.com/bellingcat/tiktok-hashtag-analysis.git
synced 2026-06-11 12:58:30 +03:00
added tests, changed __main__ to cli
This commit is contained in:
31
tests/cli.py
Normal file
31
tests/cli.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import pytest
|
||||
|
||||
from tiktok_hashtag_analysis.cli import create_parser
|
||||
|
||||
ARGUMENTS = [
|
||||
("file", "hashtags.txt", "--file"),
|
||||
("download", True, "--download"),
|
||||
("download", True, "-d"),
|
||||
("number", 20, "--number"),
|
||||
("plot", True, "--plot"),
|
||||
("plot", True, "-p"),
|
||||
("table", True, "--table"),
|
||||
("table", True, "-t"),
|
||||
("output_dir", "/tmp/tiktok_download", "--output-dir"),
|
||||
("config", "~/.tiktok", "--config"),
|
||||
("log", "../logfile.log", "--log"),
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("attribute,value,flag", ARGUMENTS)
|
||||
def test_parser(hashtags, attribute, value, flag):
|
||||
argument_list = [*hashtags, flag]
|
||||
|
||||
if not isinstance(value, bool):
|
||||
argument_list.append(str(value))
|
||||
|
||||
parser = create_parser()
|
||||
args = vars(parser.parse_args(argument_list))
|
||||
|
||||
assert args.get(attribute) == value
|
||||
assert args.get("hashtags") == hashtags
|
||||
Reference in New Issue
Block a user