dpgaspar commented on code in PR #19921:
URL: https://github.com/apache/superset/pull/19921#discussion_r864803989
##########
tests/integration_tests/databases/api_tests.py:
##########
@@ -790,6 +810,46 @@ def test_get_table_metadata_no_db_permission(self):
rv = self.client.get(uri)
self.assertEqual(rv.status_code, 404)
+ @pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
+ def test_get_table_extra_metadata(self):
+ """
+ Database API: Test get table extra metadata info
+ """
+ example_db = get_example_database()
+ self.login(username="admin")
+ uri = f"api/v1/database/{example_db.id}/table_extra/birth_names/null/"
+ rv = self.client.get(uri)
+ self.assertEqual(rv.status_code, 200)
+ response = json.loads(rv.data.decode("utf-8"))
+ self.assertEqual(response, {})
+
+ def test_get_invalid_database_table_extra_metadata(self):
+ """
+ Database API: Test get invalid database from table extra metadata
+ """
+ database_id = 1000
+ self.login(username="admin")
+ uri =
f"api/v1/database/{database_id}/table_extra/some_table/some_schema/"
+ rv = self.client.get(uri)
+ self.assertEqual(rv.status_code, 404)
+
+ uri =
"api/v1/database/some_database/table_extra/some_table/some_schema/"
+ rv = self.client.get(uri)
+ self.assertEqual(rv.status_code, 404)
+
+ def test_get_invalid_table_table_extra_metadata(self):
+ """
+ Database API: Test get invalid table from table extra metadata
+ """
+ example_db = get_example_database()
+ uri = f"api/v1/database/{example_db.id}/table_extra/wrong_table/null/"
+ self.login(username="admin")
+ rv = self.client.get(uri)
+ data = json.loads(rv.data.decode("utf-8"))
+
+ self.assertEqual(rv.status_code, 200)
+ self.assertEqual(data, {})
Review Comment:
it would, but `extra_table_metadata` implementations on different engines
differ a bit, for examples for gsheets:
https://github.com/apache/superset/blob/master/superset/db_engine_specs/gsheets.py#L111
We have an empty Dict return value for any exception that may occur on the DB,
we can't actually return a 404 for a wrong table with confidence
--
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]