Correct test_config_change
This commit is contained in:
parent
47261dbd30
commit
6fd8dc4e57
@ -50,9 +50,10 @@ URLS_TO_CHECK = ('http://localhost',
|
|||||||
'http://4-verybadhost.com',
|
'http://4-verybadhost.com',
|
||||||
'http://ads.worsthostever.net',
|
'http://ads.worsthostever.net',
|
||||||
'http://goodhost.gov',
|
'http://goodhost.gov',
|
||||||
'ftp://verygoodhost.com'
|
'ftp://verygoodhost.com',
|
||||||
'http://qutebrowser.org')
|
'http://qutebrowser.org')
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def data_tmpdir(monkeypatch, tmpdir):
|
def data_tmpdir(monkeypatch, tmpdir):
|
||||||
"""Set tmpdir as datadir"""
|
"""Set tmpdir as datadir"""
|
||||||
@ -147,7 +148,7 @@ def create_blocklist(directory, blocked_hosts=BLOCKLIST_HOSTS,
|
|||||||
with open(str(blocklist_file), 'w', encoding='UTF-8') as blocklist:
|
with open(str(blocklist_file), 'w', encoding='UTF-8') as blocklist:
|
||||||
# ensure comments are ignored when processing blocklist
|
# ensure comments are ignored when processing blocklist
|
||||||
blocklist.write('# Blocked Hosts List #\n\n')
|
blocklist.write('# Blocked Hosts List #\n\n')
|
||||||
if line_format == 'etc_hosts': # /etc/hosts like format
|
if line_format == 'etc_hosts': # /etc/hosts like format
|
||||||
for host in blocked_hosts:
|
for host in blocked_hosts:
|
||||||
blocklist.write('127.0.0.1 ' + host + '\n')
|
blocklist.write('127.0.0.1 ' + host + '\n')
|
||||||
elif line_format == 'one_per_line':
|
elif line_format == 'one_per_line':
|
||||||
@ -263,7 +264,7 @@ def test_no_blocklist_update(config_stub, download_stub,
|
|||||||
data_tmpdir, basedir, tmpdir, win_registry):
|
data_tmpdir, basedir, tmpdir, win_registry):
|
||||||
"""Ensure no Url is blocked when no block list exists."""
|
"""Ensure no Url is blocked when no block list exists."""
|
||||||
config_stub.data = {'content':
|
config_stub.data = {'content':
|
||||||
{'host-block-lists' : None,
|
{'host-block-lists': None,
|
||||||
'host-blocking-enabled': True}}
|
'host-blocking-enabled': True}}
|
||||||
host_blocker = adblock.HostBlocker()
|
host_blocker = adblock.HostBlocker()
|
||||||
host_blocker.adblock_update(0)
|
host_blocker.adblock_update(0)
|
||||||
@ -354,13 +355,13 @@ def test_blocking_with_whitelist(config_stub, basedir, download_stub,
|
|||||||
def test_config_change(config_stub, basedir, download_stub,
|
def test_config_change(config_stub, basedir, download_stub,
|
||||||
data_tmpdir, tmpdir):
|
data_tmpdir, tmpdir):
|
||||||
"""Ensure blocked-hosts resets if host-block-list is changed to None."""
|
"""Ensure blocked-hosts resets if host-block-list is changed to None."""
|
||||||
filtered_blocked_hosts = BLOCKLIST_HOSTS[1:] # Exclude localhost
|
filtered_blocked_hosts = BLOCKLIST_HOSTS[1:] # Exclude localhost
|
||||||
blocklist = create_blocklist(tmpdir,
|
blocklist = QUrl(create_blocklist(tmpdir,
|
||||||
blocked_hosts=filtered_blocked_hosts,
|
blocked_hosts=filtered_blocked_hosts,
|
||||||
name='blocked-hosts',
|
name='blocked-hosts',
|
||||||
line_format='one_per_line')
|
line_format='one_per_line'))
|
||||||
config_stub.data = {'content':
|
config_stub.data = {'content':
|
||||||
{'host-block-lists': [],
|
{'host-block-lists': [blocklist],
|
||||||
'host-blocking-enabled': True,
|
'host-blocking-enabled': True,
|
||||||
'host-blocking-whitelist': None}}
|
'host-blocking-whitelist': None}}
|
||||||
host_blocker = adblock.HostBlocker()
|
host_blocker = adblock.HostBlocker()
|
||||||
|
Loading…
Reference in New Issue
Block a user