Antonio-RiveroMartnez commented on code in PR #24580:
URL: https://github.com/apache/superset/pull/24580#discussion_r1253435184
##########
tests/integration_tests/databases/api_tests.py:
##########
@@ -3632,3 +3632,77 @@ def test_validate_sql_endpoint_failure(self,
get_validator_by_name):
return
self.assertEqual(rv.status_code, 422)
self.assertIn("Kaboom!", response["errors"][0]["message"])
+
+ def test_get_databases_with_extra_filters(self):
+ """
+ API: Test get database with extra query filter
+ """
+ self.login(username="admin")
+ extra = {
+ "metadata_params": {},
+ "engine_params": {},
+ "metadata_cache_timeout": {},
+ "schemas_allowed_for_file_upload": [],
+ }
+ example_db = get_example_database()
+
+ if example_db.backend == "sqlite":
+ return
+ database_data = {
+ "sqlalchemy_uri": example_db.sqlalchemy_uri_decrypted,
+ "configuration_method": ConfigurationMethod.SQLALCHEMY_FORM,
+ "server_cert": None,
+ "extra": json.dumps(extra),
+ }
+
+ uri = "api/v1/database/"
+ rv = self.client.post(
+ uri, json={**database_data, "database_name":
"dyntest-create-database-1"}
+ )
+ first_response = json.loads(rv.data.decode("utf-8"))
+ self.assertEqual(rv.status_code, 201)
+
+ uri = "api/v1/database/"
+ rv = self.client.post(
+ uri, json={**database_data, "database_name": "create-database-2"}
+ )
+ second_response = json.loads(rv.data.decode("utf-8"))
+ self.assertEqual(rv.status_code, 201)
+ dbs = db.session.query(Database).all()
+ expected_names = [db.database_name for db in dbs]
+ expected_names.sort()
+
+ uri = f"api/v1/database/"
+ rv = self.client.get(uri)
+ data = json.loads(rv.data.decode("utf-8"))
+ self.assertEqual(data["count"], len(dbs))
Review Comment:
Added explicit assertions to check whether the filter method has been called
when defined.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]