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 cb1d0e5
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions test/io/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -999,22 +999,29 @@ def test_openapi_in_big_schema(defaultenv):
response = postgrest.session.get("/")
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 cb1d0e5

Please sign in to comment.