From cc946ba6e629142bf22cb7334b4be19138da6923 Mon Sep 17 00:00:00 2001 From: Corentin Jule Date: Sat, 5 Dec 2015 01:09:11 +0100 Subject: [PATCH] implementation of config_stub fixture --- tests/unit/browser/test_adblock.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/unit/browser/test_adblock.py b/tests/unit/browser/test_adblock.py index 4204c31f4..02caca581 100644 --- a/tests/unit/browser/test_adblock.py +++ b/tests/unit/browser/test_adblock.py @@ -26,8 +26,7 @@ import zipfile import pytest from qutebrowser.browser import adblock -from qutebrowser.config import config -from qutebrowser.utils import objreg +from qutebrowser.config import configexc def create_text_files(files_names, directory): @@ -97,19 +96,25 @@ class TestGetFileObj: class TestIsWhitelistedHost: """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): """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') def test_without_match(self, config_stub): """Given host is not in the whitelist.""" config_stub.data = {'content': - {'host-blocking-whitelist':['qutebrowser.org']}} + {'host-blocking-whitelist':['qutebrowser.org']}} assert not adblock.is_whitelisted_host('cutebrowser.org') class TestHostBlocker: """Test for class HostBlocker.""" - # TODO pass