Skip to content

Commit

Permalink
Complete io tests
Browse files Browse the repository at this point in the history
  • Loading branch information
laurenceisla committed Jul 1, 2023
1 parent 262420a commit 7bfdb64
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions test/io/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -1000,21 +1000,27 @@ def test_openapi_in_big_schema(defaultenv):
assert response.status_code == 200


def test_get_pgrst_version_with_uri_connection_string(dburi, defaultenv):
@pytest.mark.parametrize("dburiType", ["noParams", "noParamsQMark", "withParams"])
def test_get_pgrst_version_with_uri_connection_string(dburiType, dburi, defaultenv):
"The fallback_application_name should be added to the db-uri if it has a URI format"
defaultenv_without_libpq = {
key: value
for key, value in defaultenv.items()
if key not in ["PGDATABASE", "PGHOST", "PGUSER"]
}
env = {**defaultenv_without_libpq, "PGRST_DB_URI": dburi.decode()}

with run(env=env) as postgrest:
env = {
"noParams": {**defaultenv, "PGRST_DB_URI": "postgresql://"},
"noParamsQMark": {**defaultenv, "PGRST_DB_URI": "postgresql://?"},
"withParams": {**defaultenv_without_libpq, "PGRST_DB_URI": dburi.decode()},
}

with run(env=env[dburiType]) as postgrest:
response = postgrest.session.post("/rpc/get_pgrst_version")
assert response.text.startswith('"PostgREST ')


def test_get_pgrst_version_with_keyval_connection_string(dburi, defaultenv):
def test_get_pgrst_version_with_keyval_connection_string(defaultenv):
"The fallback_application_name should be added to the db-uri if it has a keyword/value format"
uri = f'dbname={defaultenv["PGDATABASE"]} host={defaultenv["PGHOST"]} user={defaultenv["PGUSER"]}'
defaultenv_without_libpq = {
Expand Down

0 comments on commit 7bfdb64

Please sign in to comment.