ktmud commented on code in PR #20703:
URL: https://github.com/apache/superset/pull/20703#discussion_r921632934
##########
tests/integration_tests/charts/api_tests.py:
##########
@@ -933,15 +933,27 @@ def test_admin_gets_filtered_energy_slices(self):
}
],
"keys": ["none"],
- "columns": ["slice_name"],
+ "columns": ["slice_name", "description", "table.table_name"],
}
self.login(username="admin")
uri = f"api/v1/chart/?q={prison.dumps(arguments)}"
rv = self.get_assert_metric(uri, "get_list")
- self.assertEqual(rv.status_code, 200)
- data = json.loads(rv.data.decode("utf-8"))
- self.assertEqual(data["count"], 8)
+ data = rv.json
+ assert rv.status_code == 200
+ assert data["count"] > 0
+ for chart in data["result"]:
+ print(chart)
+ assert (
+ "energy"
+ in " ".join(
+ [
+ chart["slice_name"] or "",
+ chart["description"] or "",
+ chart["table"]["table_name"] or "",
+ ]
+ ).lower()
+ )
Review Comment:
Bycatch: asserting for entity counts is probably not a good idea---as the
test database can be populated with different data for various reasons. We
should test against the actual underlying function itself----which, in this
case, is filtering by a couple of text fields.
I caught this because my refactoring failed to clean up charts added in the
import/export tests, which has now been fixed.
--
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]