def mock_args_syslog_port(monkeypatch, syslog_port): patch_isdir(monkeypatch, True) args = options.Args( dirs="", recursive=False, perms_mask=None, archive_path=None, syslog_port=syslog_port, syslog_server="localhost", tcp=False, stdout=False, log_file=None, debug=False, ) return args
def mock_args_dir(monkeypatch, is_dir, error=None): patch_isdir(monkeypatch, is_dir) DIR = "/tmp" args = options.Args( dirs=DIR, recursive=False, perms_mask=None, archive_path=None, syslog_port=514, syslog_server="", tcp=False, stdout=False, log_file=False, debug=False, ) return args
def test_syslog_server_is_none_port_defined(monkeypatch): args_dict = get_args_dict(monkeypatch, "syslog_server", None) args = options.Args(**args_dict) with pytest.raises(ValueError): options.Options(args)
def test_invalid_debug(sample_args): sample_args["debug"] = "bogus" args = options.Args(**sample_args) with pytest.raises(ValueError): options.Options(args)
def test_invalid_recursive(sample_args): sample_args["recursive"] = "bogus" args = options.Args(**sample_args) with pytest.raises(ValueError): options.Options(args)
def test_protocol_udp(sample_args): sample_args["tcp"] = False args = options.Args(**sample_args) opt = options.Options(args) assert opt.protocol == "udp"
def test_protocol_tcp(sample_args): sample_args["tcp"] = True args = options.Args(**sample_args) opt = options.Options(args) assert opt.protocol == "tcp"
def test_invalid_protocol(sample_args): sample_args["tcp"] = "bogus" args = options.Args(**sample_args) with pytest.raises(ValueError): options.Options(args)
def test_syslog_server_is_empty_port_defined(monkeypatch): args_dict = get_args_dict(monkeypatch, 'syslog_server', "") args = options.Args(**args_dict) with pytest.raises(ValueError): o = options.Options(args)
def test_invalid_stdout(sample_args): sample_args['stdout'] = "bogus" args = options.Args(**sample_args) with pytest.raises(ValueError): opt = options.Options(args)