Exemplo n.º 1
0
    def test_configparser_false_callback(self):
        def parser_callback(section, option, old_value, new_value):
            return False

        ccp = CallbackConfigParser()
        ccp.read_file(self.CONFIG_FILES_DIR / 'config1.conf')
        ccp.set_callback(parser_callback)
        ccp.set('search_community', 'enabled', False)
Exemplo n.º 2
0
def test_configparser_false_callback():
    def parser_callback(*_):
        return False

    with pytest.raises(OperationNotPossibleAtRuntimeException):
        ccp = CallbackConfigParser()
        ccp.read_file(CONFIG_FILES_DIR / 'config1.conf')
        ccp.set_callback(parser_callback)
        ccp.set('search_community', 'enabled', False)
Exemplo n.º 3
0
def test_configparser_set_callback():
    def parser_callback(*_):
        return True

    ccp = CallbackConfigParser()
    ccp.set_callback(parser_callback)
    ccp.read_file(CONFIG_FILES_DIR / 'config1.conf')

    ccp.set('search_community', 'enabled', False)
    ccp.set('search_community', 'bar', 42)

    assert not ccp.get('search_community', 'enabled')
    assert ccp.get('search_community', 'bar') == 42
Exemplo n.º 4
0
    def test_configparser_set_callback(self):

        def parser_callback(section, option, old_value, new_value):
            return True

        ccp = CallbackConfigParser()
        ccp.set_callback(parser_callback)
        ccp.read_file(self.CONFIG_FILES_DIR / 'config1.conf')

        ccp.set('search_community', 'enabled', False)
        ccp.set('search_community', 'bar', 42)

        self.assertFalse(ccp.get('search_community', 'enabled'))
        self.assertEqual(ccp.get('search_community', 'bar'), 42)