feat: add endpoint to fetch available DBs (#14208)

* feat: add endpoint to fetch available DBs

* Fix lint
This commit is contained in:
Beto Dealmeida
2021-04-23 10:51:47 -07:00
committed by GitHub
parent ffcacc3393
commit e7ad03d44f
9 changed files with 511 additions and 18 deletions

View File

@@ -388,3 +388,44 @@ psql: error: could not connect to server: Operation timed out
},
)
]
def test_base_parameters_mixin():
parameters = {
"username": "username",
"password": "password",
"host": "localhost",
"port": 5432,
"database": "dbname",
"query": {"foo": "bar"},
}
sqlalchemy_uri = PostgresEngineSpec.build_sqlalchemy_url(parameters)
assert (
sqlalchemy_uri
== "postgresql+psycopg2://username:password@localhost:5432/dbname?foo=bar"
)
parameters_from_uri = PostgresEngineSpec.get_parameters_from_uri(sqlalchemy_uri)
assert parameters_from_uri == parameters
json_schema = PostgresEngineSpec.parameters_json_schema()
assert json_schema == {
"type": "object",
"properties": {
"host": {"type": "string", "description": "Hostname or IP address"},
"username": {"type": "string", "nullable": True, "description": "Username"},
"password": {"type": "string", "nullable": True, "description": "Password"},
"database": {"type": "string", "description": "Database name"},
"query": {
"type": "object",
"description": "Additinal parameters",
"additionalProperties": {},
},
"port": {
"type": "integer",
"format": "int32",
"description": "Database port",
},
},
"required": ["database", "host", "port"],
}