implementation of config_stub fixture

This commit is contained in:
Corentin Jule 2015-12-05 01:09:11 +01:00
parent 8222a86201
commit cc946ba6e6

View File

@ -26,8 +26,7 @@ import zipfile
import pytest import pytest
from qutebrowser.browser import adblock from qutebrowser.browser import adblock
from qutebrowser.config import config from qutebrowser.config import configexc
from qutebrowser.utils import objreg
def create_text_files(files_names, directory): def create_text_files(files_names, directory):
@ -97,9 +96,16 @@ class TestGetFileObj:
class TestIsWhitelistedHost: class TestIsWhitelistedHost:
"""Test function adblock.is_whitelisted_host.""" """Test function adblock.is_whitelisted_host."""
def test_without_option(self, config_stub):
"""Option host-blocking-whitelist does not exist"""
config_stub.data = {'content': {}}
with pytest.raises(configexc.NoOptionError):
adblock.is_whitelisted_host('qutebrowser.org')
def test_with_match(self, config_stub): def test_with_match(self, config_stub):
"""Given host is in the whitelist.""" """Given host is in the whitelist."""
config_stub.data = {'content': {'host-blocking-whitelist': ['qutebrowser.org']}} config_stub.data = {'content':
{'host-blocking-whitelist': ['qutebrowser.org']}}
assert adblock.is_whitelisted_host('qutebrowser.org') assert adblock.is_whitelisted_host('qutebrowser.org')
def test_without_match(self, config_stub): def test_without_match(self, config_stub):
@ -111,5 +117,4 @@ class TestIsWhitelistedHost:
class TestHostBlocker: class TestHostBlocker:
"""Test for class HostBlocker.""" """Test for class HostBlocker."""
# TODO
pass pass