villebro commented on code in PR #19921:
URL: https://github.com/apache/superset/pull/19921#discussion_r864752317
##########
superset-frontend/src/SqlLab/actions/sqlLab.test.js:
##########
@@ -415,10 +415,10 @@ describe('async actions', () => {
fetchMock.delete(updateTableSchemaEndpoint, {});
fetchMock.post(updateTableSchemaEndpoint, JSON.stringify({ id: 1 }));
- const getTableMetadataEndpoint = 'glob:*/api/v1/database/*';
+ const getTableMetadataEndpoint = 'glob:**/api/v1/database/*/table/*/*/';
fetchMock.get(getTableMetadataEndpoint, {});
const getExtraTableMetadataEndpoint =
- 'glob:*/superset/extra_table_metadata/*';
+ 'glob:**/api/v1/database/*/table_extra/*/*/';
Review Comment:
Same here
```suggestion
'glob:*/api/v1/database/*/table_extra/*/*/';
```
##########
superset-frontend/src/SqlLab/actions/sqlLab.test.js:
##########
@@ -415,10 +415,10 @@ describe('async actions', () => {
fetchMock.delete(updateTableSchemaEndpoint, {});
fetchMock.post(updateTableSchemaEndpoint, JSON.stringify({ id: 1 }));
- const getTableMetadataEndpoint = 'glob:*/api/v1/database/*';
+ const getTableMetadataEndpoint = 'glob:**/api/v1/database/*/table/*/*/';
Review Comment:
isn't a single asterisk here sufficient?
```suggestion
const getTableMetadataEndpoint = 'glob:*/api/v1/database/*/table/*/*/';
```
##########
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:
Should this really be a 200? Feels like 404 would be more appropriate
--
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]