コード例 #1
0
def test_kwargs_str_for_port():
    connect_params = ((), {
        'database': 'foo',
        'host': '1.2.3.4',
        'port': '1234'
    })
    output = _parse_connect_params(*connect_params)
    assert output == ('1.2.3.4', None, '1234', 'foo')
コード例 #2
0
def test_host_and_hostaddr_in_arg_str():
    connect_params = (("host=foobar hostaddr=1.2.3.4", ), {})
    output = _parse_connect_params(*connect_params)
    assert output == ('foobar', '1.2.3.4', None, None)
コード例 #3
0
def test_str_in_port_arg_str():
    connect_params = (("port=foobar", ), {})
    output = _parse_connect_params(*connect_params)
    assert output == (None, None, 'foobar', None)
コード例 #4
0
def test_malformed_arg_str():
    connect_params = (("this_is_malformed", ), {})
    output = _parse_connect_params(*connect_params)
    assert output == ('unknown', 'unknown', 'unknown', 'unknown')
コード例 #5
0
def test_arg_str_missing_host_and_port():
    connect_params = (("nothing=here", ), {})
    output = _parse_connect_params(*connect_params)
    assert output == (None, None, None, None)
コード例 #6
0
def test_arg_str_missing_host():
    connect_params = (("port=5555", ), {})
    output = _parse_connect_params(*connect_params)
    assert output == (None, None, '5555', None)
コード例 #7
0
def test_arg_str_multiple_port():
    connect_params = (("port=5555 port=7777", ), {})
    output = _parse_connect_params(*connect_params)
    assert output == (None, None, '7777', None)
コード例 #8
0
def test_arg_str_multiple_host():
    connect_params = (("host=foobar host=barbaz", ), {})
    output = _parse_connect_params(*connect_params)
    assert output == ('barbaz', None, None, None)
コード例 #9
0
def test_arg_str_missing_port():
    connect_params = (("host=foobar", ), {})
    output = _parse_connect_params(*connect_params)
    assert output == ('foobar', None, None, None)
コード例 #10
0
def test_bind_dsn_ignore_kwargs():
    connect_params = ((), {'dsn': "host=foobar", 'port': 1234})
    output = _parse_connect_params(*connect_params)
    assert output == ('foobar', None, None, None)
コード例 #11
0
def test_bind_dsn():
    connect_params = ((), {'dsn': 'host=foobar port=9876'})
    output = _parse_connect_params(*connect_params)
    assert output == ('foobar', None, '9876', None)
コード例 #12
0
def test_arg_str():
    connect_params = (("host=foobar port=9876", ), {})
    output = _parse_connect_params(*connect_params)
    assert output == ('foobar', None, '9876', None)
コード例 #13
0
def test_only_hostaddr_in_arg_str():
    connect_params = (("hostaddr=1.2.3.4", ), {})
    output = _parse_connect_params(*connect_params)
    assert output == (None, '1.2.3.4', None, None)
コード例 #14
0
def test_only_hostaddr_in_kwarg():
    connect_params = ((), {'hostaddr': '1.2.3.4'})
    output = _parse_connect_params(*connect_params)
    assert output == (None, '1.2.3.4', None, None)
コード例 #15
0
def test_host_and_hostaddr_in_kwarg():
    connect_params = ((), {'host': 'foobar', 'hostaddr': '1.2.3.4'})
    output = _parse_connect_params(*connect_params)
    assert output == ('foobar', '1.2.3.4', None, None)