def test_get_server_list(self, monkeypatch, capsys): """ Test the get_server_list method :param monkeypatch monkeypatch: pytest patcher """ monkeypatch.setattr(barman, "__config__", build_config_from_dicts()) server_dict = get_server_list() assert server_dict # Expect 2 test servers Main and Test assert len(server_dict) == 2 # Test the method with global errors monkeypatch.setattr( barman, "__config__", build_config_from_dicts( global_conf=None, main_conf={ "basebackups_directory": "/some/barman/home/main/base", "incoming_wals_directory": "/some/barman/home/main/incoming", "wals_directory": "/some/barman/home/main/wals", "backup_directory": "/some/barman/home/main", "archiver": "on", }, test_conf={ "basebackups_directory": "/some/barman/home/test/wals", "incoming_wals_directory": "/some/barman/home/main/incoming", "wals_directory": "/some/barman/home/main/wals", "backup_directory": "/some/barman/home/main", "archiver": "on", }, ), ) # Expect the method to fail and exit with pytest.raises(SystemExit): get_server_list() out, err = capsys.readouterr() # Check for the presence of error messages assert err # Check paths in error messages assert ( "Conflicting path: " "basebackups_directory=/some/barman/home/main/base" in err ) assert ( "Conflicting path: " "incoming_wals_directory=/some/barman/home/main/incoming" in err ) assert "Conflicting path: wals_directory=/some/barman/home/main/wals" in err assert "Conflicting path: backup_directory=/some/barman/home/main" in err
def test_get_server_list_global_error_continue(self, monkeypatch): """ Test the population of the list of global errors for diagnostic purposes (diagnose invocation) :param monkeypatch monkeypatch: pytest patcher """ monkeypatch.setattr(barman, '__config__', build_config_from_dicts( global_conf=None, main_conf={ 'basebackups_directory': '/some/barman/home/main/base', 'incoming_wals_directory': '/some/barman/home/main/incoming', 'wals_directory': '/some/barman/home/main/wals', 'backup_directory': '/some/barman/home/main', }, test_conf={ 'basebackups_directory': '/some/barman/home/test/wals', 'incoming_wals_directory': '/some/barman/home/main/incoming', 'wals_directory': '/some/barman/home/main/wals', 'backup_directory': '/some/barman/home/main', })) server_dict = get_server_list(on_error_stop=False) global_error_list = barman.__config__.servers_msg_list # Check for the presence of servers assert server_dict # Check for the presence of global errors assert global_error_list assert len(global_error_list) == 4
def test_get_server_list_global_error_continue(self, monkeypatch): """ Test the population of the list of global errors for diagnostic purposes (diagnose invocation) :param monkeypatch monkeypatch: pytest patcher """ monkeypatch.setattr( barman, "__config__", build_config_from_dicts( global_conf=None, main_conf={ "backup_directory": "/some/barman/home/main", "archiver": "on", }, test_conf={ "backup_directory": "/some/barman/home/main", "archiver": "on", }, ), ) server_dict = get_server_list(on_error_stop=False) global_error_list = barman.__config__.servers_msg_list # Check for the presence of servers assert server_dict # Check for the presence of global errors assert global_error_list assert len(global_error_list) == 6
def test_get_server_list(self, monkeypatch, capsys): """ Test the get_server_list method :param monkeypatch monkeypatch: pytest patcher """ monkeypatch.setattr(barman, '__config__', build_config_from_dicts()) server_dict = get_server_list() assert server_dict # Expect 2 test servers Main and Test assert len(server_dict) == 2 # Test the method with global errors monkeypatch.setattr( barman, '__config__', build_config_from_dicts( global_conf=None, main_conf={ 'basebackups_directory': '/some/barman/home/main/base', 'incoming_wals_directory': '/some/barman/home/main/incoming', 'wals_directory': '/some/barman/home/main/wals', 'backup_directory': '/some/barman/home/main', 'archiver': 'on', }, test_conf={ 'basebackups_directory': '/some/barman/home/test/wals', 'incoming_wals_directory': '/some/barman/home/main/incoming', 'wals_directory': '/some/barman/home/main/wals', 'backup_directory': '/some/barman/home/main', 'archiver': 'on', })) # Expect the method to fail and exit with pytest.raises(SystemExit): get_server_list() out, err = capsys.readouterr() # Check for the presence of error messages assert err # Check paths in error messages assert 'Conflicting path: ' \ 'basebackups_directory=/some/barman/home/main/base' in err assert 'Conflicting path: ' \ 'incoming_wals_directory=/some/barman/home/main/incoming' in err assert 'Conflicting path: ' \ 'wals_directory=/some/barman/home/main/wals' in err assert 'Conflicting path: ' \ 'backup_directory=/some/barman/home/main' in err
def test_get_server_list(self, monkeypatch, capsys): """ Test the get_server_list method :param monkeypatch monkeypatch: pytest patcher """ monkeypatch.setattr(barman, '__config__', build_config_from_dicts()) server_dict = get_server_list() assert server_dict # Expect 2 test servers Main and Test assert len(server_dict) == 2 # Test the method with global errors monkeypatch.setattr(barman, '__config__', build_config_from_dicts( global_conf=None, main_conf={ 'basebackups_directory': '/some/barman/home/main/base', 'incoming_wals_directory': '/some/barman/home/main/incoming', 'wals_directory': '/some/barman/home/main/wals', 'backup_directory': '/some/barman/home/main', 'archiver': 'on', }, test_conf={ 'basebackups_directory': '/some/barman/home/test/wals', 'incoming_wals_directory': '/some/barman/home/main/incoming', 'wals_directory': '/some/barman/home/main/wals', 'backup_directory': '/some/barman/home/main', 'archiver': 'on', })) # Expect the method to fail and exit with pytest.raises(SystemExit): get_server_list() out, err = capsys.readouterr() # Check for the presence of error messages assert err # Check paths in error messages assert 'Conflicting path: ' \ 'basebackups_directory=/some/barman/home/main/base' in err assert 'Conflicting path: ' \ 'incoming_wals_directory=/some/barman/home/main/incoming' in err assert 'Conflicting path: ' \ 'wals_directory=/some/barman/home/main/wals' in err assert 'Conflicting path: ' \ 'backup_directory=/some/barman/home/main' in err
def __init__(self, args): cli.global_config(args) # Remove logging handlers to avoid opening # barman.log over and over again logging.disable(logging.CRITICAL) for handler in logging.root.handlers[:]: logging.root.removeHandler(handler) self.servers = cli.get_server_list(args) self.server_names = self.servers.keys()