def test_open_no_pool_specified(mock_create_pool): connector = psycopg2_connector.Psycopg2Connector() connector.open() assert connector._pool_externally_set is False mock_create_pool.assert_called_once_with(connector._pool_args)
def test_open_pool_argument_specified(pool, mock_create_pool): connector = psycopg2_connector.Psycopg2Connector() connector.open(pool) assert connector._pool_externally_set is True mock_create_pool.assert_not_called() assert connector._pool == pool
def _(**kwargs): json_dumps = kwargs.pop("json_dumps", None) json_loads = kwargs.pop("json_loads", None) connection_params.update(kwargs) connector = psycopg2_connector.Psycopg2Connector(json_dumps=json_dumps, json_loads=json_loads, **connection_params) connectors.append(connector) return connector
def not_opened_psycopg2_connector(connection_params): yield psycopg2_connector_module.Psycopg2Connector(**connection_params)
def test_wrap_exceptions_applied(method_name): connector = psycopg2_connector.Psycopg2Connector() assert getattr(connector, method_name)._exceptions_wrapped is True
def test_get_pool(): connector = psycopg2_connector.Psycopg2Connector() with pytest.raises(exceptions.AppNotOpen): _ = connector.pool
def psycopg2_connector(connection_params): connector = psycopg2_connector_module.Psycopg2Connector(**connection_params) yield connector connector.close()