Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sherlock-project
GitHub Repository: sherlock-project/sherlock
Path: blob/master/tests/test_ux.py
761 views
1
import pytest
2
from sherlock_project import sherlock
3
from sherlock_interactives import Interactives
4
from sherlock_interactives import InteractivesSubprocessError
5
6
def test_remove_nsfw(sites_obj):
7
nsfw_target: str = 'Pornhub'
8
assert nsfw_target in {site.name: site.information for site in sites_obj}
9
sites_obj.remove_nsfw_sites()
10
assert nsfw_target not in {site.name: site.information for site in sites_obj}
11
12
13
# Parametrized sites should *not* include Motherless, which is acting as the control
14
@pytest.mark.parametrize('nsfwsites', [
15
['Pornhub'],
16
['Pornhub', 'Xvideos'],
17
])
18
def test_nsfw_explicit_selection(sites_obj, nsfwsites):
19
for site in nsfwsites:
20
assert site in {site.name: site.information for site in sites_obj}
21
sites_obj.remove_nsfw_sites(do_not_remove=nsfwsites)
22
for site in nsfwsites:
23
assert site in {site.name: site.information for site in sites_obj}
24
assert 'Motherless' not in {site.name: site.information for site in sites_obj}
25
26
def test_wildcard_username_expansion():
27
assert sherlock.check_for_parameter('test{?}test') is True
28
assert sherlock.check_for_parameter('test{.}test') is False
29
assert sherlock.check_for_parameter('test{}test') is False
30
assert sherlock.check_for_parameter('testtest') is False
31
assert sherlock.check_for_parameter('test{?test') is False
32
assert sherlock.check_for_parameter('test?}test') is False
33
assert sherlock.multiple_usernames('test{?}test') == ["test_test" , "test-test" , "test.test"]
34
35
36
@pytest.mark.parametrize('cliargs', [
37
'',
38
'--site urghrtuight --egiotr',
39
'--',
40
])
41
def test_no_usernames_provided(cliargs):
42
with pytest.raises(InteractivesSubprocessError, match=r"error: the following arguments are required: USERNAMES"):
43
Interactives.run_cli(cliargs)
44
45