Example #1
0
    def test_noneValueResetToDefault(self):
        set('autorun', False)
        value = get("autorun")
        assert type(value) is bool and not value

        set('autorun', None)
        value = get("autorun")
        assert type(value) is bool and value
Example #2
0
    def test_noneValueSetToNone(self):
        set('proxy_port', 42)
        value = get("proxy_port")
        assert type(value) is int and value == 42

        set('proxy_port', None)
        value = get("proxy_port")
        assert value is None
Example #3
0
    def test_getAStringValue(self):
        set("proxy_type", 42)
        value = get("proxy_type")
        assert (type(value) is str or type(value) is unicode) and value == "42"

        set("proxy_type", None)
        value = get("proxy_type")
        assert (type(value) is str or type(value)
                is unicode) and value == "HTTP"
Example #4
0
    def test_getABoolValue(self):
        set("autorun", False)
        value = get("autorun")
        assert type(value) is bool and not value

        set("autorun", "False")
        value = get("autorun")
        assert type(value) is bool and not value

        set("autorun", None)
        value = get("autorun")
        assert type(value) is bool and value
Example #5
0
    def test_getAnIntValue(self):
        set("proxy_port", 42)
        value = get("proxy_port")
        assert type(value) is int and value == 42

        set("proxy_port", "42")
        value = get("proxy_port")
        assert type(value) is int and value == 42

        set("proxy_port", None)
        value = get("proxy_port")
        assert value is None
Example #6
0
    def test_getADictWithInvalidValue_test1(self):
        _config_parser.set('config', "log_levels", "plop")
        assert catcher.lastLogRecord is None

        value = get("log_levels")
        assert type(value) is dict
        assert len(value) == 0
        assert catcher.lastLogRecord is not None
Example #7
0
    def test_setWithExistingFile(self):
        config_path = _get_config_file_path()

        if exists(config_path):
            os.remove(config_path)

        # create the file
        set("lang", "plop")

        # overwrite the file
        set("autorun", True)

        value = get("lang")
        assert (type(value) is str or type(value)
                is unicode) and value == "plop"

        value = get("autorun")
        assert type(value) is bool and value
Example #8
0
    def test_getADictValue(self):
        set("log_levels", "aa=bb;cc=dd")
        value = get("log_levels")
        assert type(value) is dict

        assert "aa" in value
        assert value["aa"] == "bb"

        assert "cc" in value
        assert value["cc"] == "dd"
Example #9
0
    def test_setWithoutExistingFile(self):
        config_path = _get_config_file_path()

        if exists(config_path):
            os.remove(config_path)

        set("lang", "plop")
        value = get("lang")
        assert (type(value) is str or type(value)
                is unicode) and value == "plop"
Example #10
0
    def test_getADictWithInvalidValue_test2(self):
        _config_parser.set('config', "log_levels", "plop;toto=tata")
        assert catcher.lastLogRecord is None

        value = get("log_levels")
        assert type(value) is dict
        assert len(value) == 1
        assert catcher.lastLogRecord is not None

        assert "toto" in value
        assert value["toto"] == "tata"
Example #11
0
    def test_getAkeyNotPresentInFile(self):
        config_path = _get_config_file_path()

        # delete the file
        if exists(config_path):
            os.remove(config_path)

        # create the file
        set("proxy_port", 42)

        value = get("proxy_type")
        assert (type(value) is str or type(value)
                is unicode) and value == "HTTP"
Example #12
0
    def test_loadWithoutExistingFile(self):
        config_path = _get_config_file_path()

        if exists(config_path):
            os.remove(config_path)

        # create a config file
        set('lang', 'plop')

        assert catcher.lastLogRecord is None
        load()
        assert catcher.lastLogRecord is None

        assert get('lang') == 'plop'
Example #13
0
 def test_setANotString(self):
     set("lang", 42)
     value = get("lang")
     assert (type(value) is str or type(value) is unicode) and value == "42"
Example #14
0
 def test_setAString(self):
     set("lang", "plop")
     value = get("lang")
     assert (type(value) is str or type(value)
             is unicode) and value == "plop"
Example #15
0
 def test_getABoolWithInvalidValue(self):
     set("autorun", False)
     _config_parser.set('config', "autorun", "plop")
     value = get("autorun")
     assert type(value) is bool and value
Example #16
0
 def test_getAnIntWithInvalidValue(self):
     set("proxy_port", 42)
     _config_parser.set('config', "proxy_port", "plop")
     value = get("proxy_port")
     assert value is None
Example #17
0
 def test_keyDoesNotExist(self):
     with pytest.raises(KeyError):
         get("plop")