def test_remote_parsing(): with no_lingering_errors(): tests = ( (b':/bup', (b'file', None, None, b'/bup')), (b'file:///bup', (b'file', None, None, b'/bup')), (b'192.168.1.1:/bup', (b'ssh', b'192.168.1.1', None, b'/bup')), (b'ssh://192.168.1.1:2222/bup', (b'ssh', b'192.168.1.1', b'2222', b'/bup')), (b'ssh://[ff:fe::1]:2222/bup', (b'ssh', b'ff:fe::1', b'2222', b'/bup')), (b'bup://foo.com:1950', (b'bup', b'foo.com', b'1950', None)), (b'bup://foo.com:1950/bup', (b'bup', b'foo.com', b'1950', b'/bup')), (b'bup://[ff:fe::1]/bup', (b'bup', b'ff:fe::1', None, b'/bup')), (b'reverse://', (b'reverse', None, None, b'')), (b'reverse://host/dir', (b'reverse', b'host', None, b'/dir')), (b'config:///path/to/file.conf', (b'config', None, None, b'/path/to/file.conf')), ) for remote, values in tests: WVPASSEQ(client.parse_remote(remote), values) try: client.parse_remote(b'http://asdf.com/bup') WVFAIL() except client.ClientError: WVPASS()
def test_remote_parsing(): tests = ( (':/bup', ('file', None, None, '/bup')), ('file:///bup', ('file', None, None, '/bup')), ('192.168.1.1:/bup', ('ssh', '192.168.1.1', None, '/bup')), ('ssh://192.168.1.1:2222/bup', ('ssh', '192.168.1.1', '2222', '/bup')), ('ssh://[ff:fe::1]:2222/bup', ('ssh', 'ff:fe::1', '2222', '/bup')), ('bup://foo.com:1950', ('bup', 'foo.com', '1950', None)), ('bup://foo.com:1950/bup', ('bup', 'foo.com', '1950', '/bup')), ('bup://[ff:fe::1]/bup', ('bup', 'ff:fe::1', None, '/bup')), ) for remote, values in tests: WVPASSEQ(client.parse_remote(remote), values) try: client.parse_remote('http://asdf.com/bup') WVFAIL() except client.ClientError: WVPASS()
def test_remote_parsing(): tests = ( (b':/bup', (b'file', None, None, b'/bup')), (b'file:///bup', (b'file', None, None, b'/bup')), (b'192.168.1.1:/bup', (b'ssh', b'192.168.1.1', None, b'/bup')), (b'ssh://192.168.1.1:2222/bup', (b'ssh', b'192.168.1.1', b'2222', b'/bup')), (b'ssh://[ff:fe::1]:2222/bup', (b'ssh', b'ff:fe::1', b'2222', b'/bup')), (b'bup://foo.com:1950', (b'bup', b'foo.com', b'1950', None)), (b'bup://foo.com:1950/bup', (b'bup', b'foo.com', b'1950', b'/bup')), (b'bup://[ff:fe::1]/bup', (b'bup', b'ff:fe::1', None, b'/bup')), ) for remote, values in tests: assert client.parse_remote(remote) == values with pytest.raises(client.ClientError): client.parse_remote(b'http://asdf.com/bup')
def make_repo(address, create=False, compression_level=None, max_pack_size=None, max_pack_objects=None): protocol, host, port, dir = client.parse_remote(address) if protocol == b'config': assert compression_level is None, "command-line compression level not supported in this repo type" assert max_pack_size is None, "command-line max pack size not supported in this repo type" assert max_pack_objects is None, "command-line max pack objects not supported in this repo type" return _make_config_repo(host, port, dir, create) return RemoteRepo(address, create=create, compression_level=compression_level, max_pack_size=max_pack_size, max_pack_objects=max_pack_objects)