willbarrett commented on a change in pull request #9444: Implement dttm column
configuration through db extra config
URL:
https://github.com/apache/incubator-superset/pull/9444#discussion_r402461099
##########
File path: tests/core_tests.py
##########
@@ -1171,6 +1171,78 @@ def test_sqllab_backend_persistence_payload(self):
payload = views.Superset._get_sqllab_tabs(user_id=user_id)
self.assertEqual(len(payload["queries"]), 1)
+ def test_db_column_defaults(self):
+ db_extras = json.dumps(
+ {
+ "main_datetime_column": "dttm",
+ "default_dttm_column_names": ["id", "dttm"],
+ "python_date_format_by_column_name": {
+ "id": "epoch_ms",
+ "dttm": "epoch_s",
+ },
+ "expression_by_column_name": {"dttm": "CAST(dttm as INTEGER)"},
+ }
+ )
+
+ self.login(username="admin")
+ try:
+ test_db = utils.get_or_create_db(
+ "column_test_db", app.config["SQLALCHEMY_DATABASE_URI"],
extra=db_extras
+ )
+
+ resp = self.client.post(
+ "/tablemodelview/add",
+ data=dict(database=test_db.id, table_name="logs"),
+ follow_redirects=True,
+ )
+ self.assertEqual(resp.status_code, 200)
+ added_table =
db.session.query(SqlaTable).filter_by(table_name="logs").one()
+
+ # Make sure that dttm column is set properly
Review comment:
Comments like this in a test file usually indicate to me that the test
should be broken up, and that the comments are a good place to do the breaking.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]