forked from soxoj/maigret
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_cli.py
98 lines (79 loc) · 2.37 KB
/
test_cli.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
"""Maigret command-line arguments parsing tests"""
from argparse import Namespace
from typing import Dict, Any
DEFAULT_ARGS: Dict[str, Any] = {
'all_sites': False,
'connections': 100,
'cookie_file': None,
'csv': False,
'db_file': 'resources/data.json',
'debug': False,
'disable_extracting': False,
'disable_recursive_search': False,
'folderoutput': 'reports',
'html': False,
'graph': False,
'id_type': 'username',
'ignore_ids_list': [],
'info': False,
'json': '',
'new_site_to_submit': False,
'no_color': False,
'no_progressbar': False,
'parse_url': '',
'pdf': False,
'print_check_errors': False,
'print_not_found': False,
'proxy': None,
'reports_sorting': 'default',
'retries': 1,
'self_check': False,
'site_list': [],
'stats': False,
'tags': '',
'timeout': 30,
'tor_proxy': 'socks5://127.0.0.1:9050',
'i2p_proxy': 'http://127.0.0.1:4444',
'top_sites': 500,
'txt': False,
'use_disabled_sites': False,
'username': [],
'verbose': False,
'with_domains': False,
'xmind': False,
}
def test_args_search_mode(argparser):
args = argparser.parse_args('username'.split())
assert args.username == ['username']
want_args = dict(DEFAULT_ARGS)
want_args.update({'username': ['username']})
assert args == Namespace(**want_args)
def test_args_search_mode_several_usernames(argparser):
args = argparser.parse_args('username1 username2'.split())
assert args.username == ['username1', 'username2']
want_args = dict(DEFAULT_ARGS)
want_args.update({'username': ['username1', 'username2']})
assert args == Namespace(**want_args)
def test_args_self_check_mode(argparser):
args = argparser.parse_args('--self-check --site GitHub'.split())
want_args = dict(DEFAULT_ARGS)
want_args.update(
{
'self_check': True,
'site_list': ['GitHub'],
'username': [],
}
)
assert args == Namespace(**want_args)
def test_args_multiple_sites(argparser):
args = argparser.parse_args(
'--site GitHub VK --site PornHub --site Taringa,Steam'.split()
)
want_args = dict(DEFAULT_ARGS)
want_args.update(
{
'site_list': ['GitHub', 'PornHub', 'Taringa,Steam'],
'username': ['VK'],
}
)
assert args == Namespace(**want_args)