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')
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)
def test_str_in_port_arg_str(): connect_params = (("port=foobar", ), {}) output = _parse_connect_params(*connect_params) assert output == (None, None, 'foobar', None)
def test_malformed_arg_str(): connect_params = (("this_is_malformed", ), {}) output = _parse_connect_params(*connect_params) assert output == ('unknown', 'unknown', 'unknown', 'unknown')
def test_arg_str_missing_host_and_port(): connect_params = (("nothing=here", ), {}) output = _parse_connect_params(*connect_params) assert output == (None, None, None, None)
def test_arg_str_missing_host(): connect_params = (("port=5555", ), {}) output = _parse_connect_params(*connect_params) assert output == (None, None, '5555', None)
def test_arg_str_multiple_port(): connect_params = (("port=5555 port=7777", ), {}) output = _parse_connect_params(*connect_params) assert output == (None, None, '7777', None)
def test_arg_str_multiple_host(): connect_params = (("host=foobar host=barbaz", ), {}) output = _parse_connect_params(*connect_params) assert output == ('barbaz', None, None, None)
def test_arg_str_missing_port(): connect_params = (("host=foobar", ), {}) output = _parse_connect_params(*connect_params) assert output == ('foobar', None, None, None)
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)
def test_bind_dsn(): connect_params = ((), {'dsn': 'host=foobar port=9876'}) output = _parse_connect_params(*connect_params) assert output == ('foobar', None, '9876', None)
def test_arg_str(): connect_params = (("host=foobar port=9876", ), {}) output = _parse_connect_params(*connect_params) assert output == ('foobar', None, '9876', None)
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)
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)
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)