def test_db_in_querystring(): pool = ConnectionPool.from_url('unix:///socket?db=2', db=1) assert pool.connection_class == UnixDomainSocketConnection assert pool.connection_kwargs == { 'path': '/socket', 'db': 2, 'username': None, 'password': None, }
def test_db_as_argument(): pool = ConnectionPool.from_url('unix:///socket', db=1) assert pool.connection_class == UnixDomainSocketConnection assert pool.connection_kwargs == { 'path': '/socket', 'db': 1, 'username': None, 'password': None, }
def test_defaults(): pool = ConnectionPool.from_url('unix:///socket') assert pool.connection_class == UnixDomainSocketConnection assert pool.connection_kwargs == { 'path': '/socket', 'db': 0, 'username': None, 'password': None, }
def test_username_and_password(): pool = ConnectionPool.from_url('unix://*****:*****@/socket') assert pool.connection_class == UnixDomainSocketConnection assert pool.connection_kwargs == { 'path': '/socket', 'db': 0, 'username': '******', 'password': '******', }
def test_password(): pool = ConnectionPool.from_url('redis://:mypassword@localhost') assert pool.connection_class == Connection assert pool.connection_kwargs == { 'host': 'localhost', 'port': 6379, 'db': 0, 'username': '', 'password': '******', }
def test_defaults(): pool = ConnectionPool.from_url('redis://localhost') assert pool.connection_class == Connection assert pool.connection_kwargs == { 'host': 'localhost', 'port': 6379, 'db': 0, 'username': None, 'password': None, }
def test_db_in_querystring(): pool = ConnectionPool.from_url('redis://localhost/2?db=3', db='1') assert pool.connection_class == Connection assert pool.connection_kwargs == { 'host': 'localhost', 'port': 6379, 'db': 3, 'username': None, 'password': None, }
def test_db_as_argument(): pool = ConnectionPool.from_url('redis://localhost', db='1') assert pool.connection_class == Connection assert pool.connection_kwargs == { 'host': 'localhost', 'port': 6379, 'db': 1, 'username': None, 'password': None, }
def test_quoted_hostname(): pool = ConnectionPool.from_url('redis://my %2F host %2B%3D+', decode_components=True) assert pool.connection_class == Connection assert pool.connection_kwargs == { 'host': 'my / host +=+', 'port': 6379, 'db': 0, 'username': None, 'password': None, }
def test_quoted_path(): pool = ConnectionPool.from_url( 'unix://:mypassword@/my%2Fpath%2Fto%2F..%2F+_%2B%3D%24ocket', decode_components=True) assert pool.connection_class == UnixDomainSocketConnection assert pool.connection_kwargs == { 'path': '/my/path/to/../+_+=$ocket', 'db': 0, 'username': None, 'password': '******', }
def test_extra_querystring_options(): pool = ConnectionPool.from_url('unix:///socket?a=1&b=2') assert pool.connection_class == UnixDomainSocketConnection assert pool.connection_kwargs == { 'path': '/socket', 'db': 0, 'username': None, 'password': None, 'a': '1', 'b': '2', }
def test_quoted_password(): pool = ConnectionPool.from_url( 'redis://:%2Fmypass%2F%2B word%3D%24+@localhost', decode_components=True) assert pool.connection_class == Connection assert pool.connection_kwargs == { 'host': 'localhost', 'port': 6379, 'db': 0, 'username': None, 'password': '******', }
def test_extra_querystring_options(): pool = ConnectionPool.from_url('redis://localhost?a=1&b=2') assert pool.connection_class == Connection assert pool.connection_kwargs == { 'host': 'localhost', 'port': 6379, 'db': 0, 'username': None, 'password': None, 'a': '1', 'b': '2', }