mirror of https://github.com/apache/superset.git
Use py3's f-strings instead of s.format(**locals()) (#6448)
* Use py3's f-strings instead of s.format(**locals()) In light of the bug reported here https://github.com/apache/incubator-superset/issues/6347, which seems like an odd `.format()` issue in py3, I greped and replaced all instances of `.format(**locals())` using py3's f-strings * lint * fix tests
This commit is contained in:
parent
002518ba49
commit
cc3a625a4b
|
@ -115,12 +115,13 @@ def runserver(debug, console_log, use_reloader, address, port, timeout, workers,
|
||||||
addr_str = ' unix:{socket} ' if socket else' {address}:{port} '
|
addr_str = ' unix:{socket} ' if socket else' {address}:{port} '
|
||||||
cmd = (
|
cmd = (
|
||||||
'gunicorn '
|
'gunicorn '
|
||||||
'-w {workers} '
|
f'-w {workers} '
|
||||||
'--timeout {timeout} '
|
f'--timeout {timeout} '
|
||||||
'-b ' + addr_str +
|
f'-b {addr_str} '
|
||||||
'--limit-request-line 0 '
|
'--limit-request-line 0 '
|
||||||
'--limit-request-field_size 0 '
|
'--limit-request-field_size 0 '
|
||||||
'superset:app').format(**locals())
|
'superset:app'
|
||||||
|
)
|
||||||
print(Fore.GREEN + 'Starting server with command: ')
|
print(Fore.GREEN + 'Starting server with command: ')
|
||||||
print(Fore.YELLOW + cmd)
|
print(Fore.YELLOW + cmd)
|
||||||
print(Style.RESET_ALL)
|
print(Style.RESET_ALL)
|
||||||
|
@ -404,10 +405,10 @@ def flower(port, address):
|
||||||
BROKER_URL = celery_app.conf.BROKER_URL
|
BROKER_URL = celery_app.conf.BROKER_URL
|
||||||
cmd = (
|
cmd = (
|
||||||
'celery flower '
|
'celery flower '
|
||||||
'--broker={BROKER_URL} '
|
f'--broker={BROKER_URL} '
|
||||||
'--port={port} '
|
f'--port={port} '
|
||||||
'--address={address} '
|
f'--address={address} '
|
||||||
).format(**locals())
|
)
|
||||||
logging.info(
|
logging.info(
|
||||||
"The 'superset flower' command is deprecated. Please use the 'celery "
|
"The 'superset flower' command is deprecated. Please use the 'celery "
|
||||||
"flower' command instead.")
|
"flower' command instead.")
|
||||||
|
|
|
@ -450,7 +450,7 @@ DB_CONNECTION_MUTATOR = None
|
||||||
#
|
#
|
||||||
# def SQL_QUERY_MUTATOR(sql, username, security_manager):
|
# def SQL_QUERY_MUTATOR(sql, username, security_manager):
|
||||||
# dttm = datetime.now().isoformat()
|
# dttm = datetime.now().isoformat()
|
||||||
# return "-- [SQL LAB] {username} {dttm}\n sql"(**locals())
|
# return f"-- [SQL LAB] {username} {dttm}\n{sql}"
|
||||||
SQL_QUERY_MUTATOR = None
|
SQL_QUERY_MUTATOR = None
|
||||||
|
|
||||||
# When not using gunicorn, (nginx for instance), you may want to disable
|
# When not using gunicorn, (nginx for instance), you may want to disable
|
||||||
|
|
|
@ -66,7 +66,7 @@ class BaseDatasource(AuditMixinNullable, ImportMixin):
|
||||||
@property
|
@property
|
||||||
def uid(self):
|
def uid(self):
|
||||||
"""Unique id across datasource types"""
|
"""Unique id across datasource types"""
|
||||||
return '{self.id}__{self.type}'.format(**locals())
|
return f'{self.id}__{self.type}'
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def column_names(self):
|
def column_names(self):
|
||||||
|
|
|
@ -116,7 +116,7 @@ class DruidCluster(Model, AuditMixinNullable, ImportMixin):
|
||||||
def get_base_broker_url(self):
|
def get_base_broker_url(self):
|
||||||
base_url = self.get_base_url(
|
base_url = self.get_base_url(
|
||||||
self.broker_host, self.broker_port)
|
self.broker_host, self.broker_port)
|
||||||
return '{base_url}/{self.broker_endpoint}'.format(**locals())
|
return f'{base_url}/{self.broker_endpoint}'
|
||||||
|
|
||||||
def get_pydruid_client(self):
|
def get_pydruid_client(self):
|
||||||
cli = PyDruid(
|
cli = PyDruid(
|
||||||
|
@ -525,7 +525,7 @@ class DruidDatasource(Model, BaseDatasource):
|
||||||
@property
|
@property
|
||||||
def link(self):
|
def link(self):
|
||||||
name = escape(self.datasource_name)
|
name = escape(self.datasource_name)
|
||||||
return Markup('<a href="{self.url}">{name}</a>').format(**locals())
|
return Markup(f'<a href="{self.url}">{name}</a>')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def full_name(self):
|
def full_name(self):
|
||||||
|
@ -549,9 +549,9 @@ class DruidDatasource(Model, BaseDatasource):
|
||||||
|
|
||||||
@renders('datasource_name')
|
@renders('datasource_name')
|
||||||
def datasource_link(self):
|
def datasource_link(self):
|
||||||
url = '/superset/explore/{obj.type}/{obj.id}/'.format(obj=self)
|
url = f'/superset/explore/{self.type}/{self.id}/'
|
||||||
name = escape(self.datasource_name)
|
name = escape(self.datasource_name)
|
||||||
return Markup('<a href="{url}">{name}</a>'.format(**locals()))
|
return Markup(f'<a href="{url}">{name}</a>')
|
||||||
|
|
||||||
def get_metric_obj(self, metric_name):
|
def get_metric_obj(self, metric_name):
|
||||||
return [
|
return [
|
||||||
|
|
|
@ -324,8 +324,8 @@ class SqlaTable(Model, BaseDatasource):
|
||||||
@property
|
@property
|
||||||
def link(self):
|
def link(self):
|
||||||
name = escape(self.name)
|
name = escape(self.name)
|
||||||
anchor = '<a target="_blank" href="{self.explore_url}">{name}</a>'
|
anchor = f'<a target="_blank" href="{self.explore_url}">{name}</a>'
|
||||||
return Markup(anchor.format(**locals()))
|
return Markup(anchor)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def schema_perm(self):
|
def schema_perm(self):
|
||||||
|
|
|
@ -848,15 +848,15 @@ class PrestoEngineSpec(BaseEngineSpec):
|
||||||
if filters:
|
if filters:
|
||||||
l = [] # noqa: E741
|
l = [] # noqa: E741
|
||||||
for field, value in filters.items():
|
for field, value in filters.items():
|
||||||
l.append("{field} = '{value}'".format(**locals()))
|
l.append(f"{field} = '{value}'")
|
||||||
where_clause = 'WHERE ' + ' AND '.join(l)
|
where_clause = 'WHERE ' + ' AND '.join(l)
|
||||||
|
|
||||||
sql = textwrap.dedent("""\
|
sql = textwrap.dedent(f"""\
|
||||||
SHOW PARTITIONS FROM {table_name}
|
SHOW PARTITIONS FROM {table_name}
|
||||||
{where_clause}
|
{where_clause}
|
||||||
{order_by_clause}
|
{order_by_clause}
|
||||||
{limit_clause}
|
{limit_clause}
|
||||||
""").format(**locals())
|
""")
|
||||||
return sql
|
return sql
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -1070,10 +1070,10 @@ class HiveEngineSpec(PrestoEngineSpec):
|
||||||
s3.upload_file(
|
s3.upload_file(
|
||||||
upload_path, bucket_path,
|
upload_path, bucket_path,
|
||||||
os.path.join(upload_prefix, table_name, filename))
|
os.path.join(upload_prefix, table_name, filename))
|
||||||
sql = """CREATE TABLE {full_table_name} ( {schema_definition} )
|
sql = f"""CREATE TABLE {full_table_name} ( {schema_definition} )
|
||||||
ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' STORED AS
|
ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' STORED AS
|
||||||
TEXTFILE LOCATION '{location}'
|
TEXTFILE LOCATION '{location}'
|
||||||
tblproperties ('skip.header.line.count'='1')""".format(**locals())
|
tblproperties ('skip.header.line.count'='1')"""
|
||||||
logging.info(form.con.data)
|
logging.info(form.con.data)
|
||||||
engine = create_engine(form.con.data.sqlalchemy_uri_decrypted)
|
engine = create_engine(form.con.data.sqlalchemy_uri_decrypted)
|
||||||
engine.execute(sql)
|
engine.execute(sql)
|
||||||
|
@ -1220,7 +1220,7 @@ class HiveEngineSpec(PrestoEngineSpec):
|
||||||
@classmethod
|
@classmethod
|
||||||
def _partition_query(
|
def _partition_query(
|
||||||
cls, table_name, limit=0, order_by=None, filters=None):
|
cls, table_name, limit=0, order_by=None, filters=None):
|
||||||
return 'SHOW PARTITIONS {table_name}'.format(**locals())
|
return f'SHOW PARTITIONS {table_name}'
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def modify_url_for_impersonation(cls, url, impersonate_user, username):
|
def modify_url_for_impersonation(cls, url, impersonate_user, username):
|
||||||
|
|
|
@ -257,8 +257,7 @@ class Slice(Model, AuditMixinNullable, ImportMixin):
|
||||||
form_data = {'slice_id': self.id}
|
form_data = {'slice_id': self.id}
|
||||||
form_data.update(overrides)
|
form_data.update(overrides)
|
||||||
params = parse.quote(json.dumps(form_data))
|
params = parse.quote(json.dumps(form_data))
|
||||||
return (
|
return f'{base_url}/?form_data={params}'
|
||||||
'{base_url}/?form_data={params}'.format(**locals()))
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def slice_url(self):
|
def slice_url(self):
|
||||||
|
@ -278,7 +277,7 @@ class Slice(Model, AuditMixinNullable, ImportMixin):
|
||||||
def slice_link(self):
|
def slice_link(self):
|
||||||
url = self.slice_url
|
url = self.slice_url
|
||||||
name = escape(self.slice_name)
|
name = escape(self.slice_name)
|
||||||
return Markup('<a href="{url}">{name}</a>'.format(**locals()))
|
return Markup(f'<a href="{url}">{name}</a>')
|
||||||
|
|
||||||
def get_viz(self, force=False):
|
def get_viz(self, force=False):
|
||||||
"""Creates :py:class:viz.BaseViz object from the url_params_multidict.
|
"""Creates :py:class:viz.BaseViz object from the url_params_multidict.
|
||||||
|
@ -299,6 +298,17 @@ class Slice(Model, AuditMixinNullable, ImportMixin):
|
||||||
force=force,
|
force=force,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def icons(self):
|
||||||
|
return f"""
|
||||||
|
<a
|
||||||
|
href="{self.datasource_edit_url}"
|
||||||
|
data-toggle="tooltip"
|
||||||
|
title="{self.datasource}">
|
||||||
|
<i class="fa fa-database"></i>
|
||||||
|
</a>
|
||||||
|
"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def import_obj(cls, slc_to_import, slc_to_override, import_time=None):
|
def import_obj(cls, slc_to_import, slc_to_override, import_time=None):
|
||||||
"""Inserts or overrides slc in the database.
|
"""Inserts or overrides slc in the database.
|
||||||
|
@ -409,8 +419,7 @@ class Dashboard(Model, AuditMixinNullable, ImportMixin):
|
||||||
|
|
||||||
def dashboard_link(self):
|
def dashboard_link(self):
|
||||||
title = escape(self.dashboard_title)
|
title = escape(self.dashboard_title)
|
||||||
return Markup(
|
return Markup(f'<a href="{self.url}">{title}</a>')
|
||||||
'<a href="{self.url}">{title}</a>'.format(**locals()))
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def data(self):
|
def data(self):
|
||||||
|
@ -1185,11 +1194,11 @@ class DatasourceAccessRequest(Model, AuditMixinNullable):
|
||||||
for r in pv.role:
|
for r in pv.role:
|
||||||
if r.name in self.ROLES_BLACKLIST:
|
if r.name in self.ROLES_BLACKLIST:
|
||||||
continue
|
continue
|
||||||
|
# pylint: disable=no-member
|
||||||
url = (
|
url = (
|
||||||
'/superset/approve?datasource_type={self.datasource_type}&'
|
f'/superset/approve?datasource_type={self.datasource_type}&'
|
||||||
'datasource_id={self.datasource_id}&'
|
f'datasource_id={self.datasource_id}&'
|
||||||
'created_by={self.created_by.username}&role_to_grant={r.name}'
|
f'created_by={self.created_by.username}&role_to_grant={r.name}'
|
||||||
.format(**locals())
|
|
||||||
)
|
)
|
||||||
href = '<a href="{}">Grant {} Role</a>'.format(url, r.name)
|
href = '<a href="{}">Grant {} Role</a>'.format(url, r.name)
|
||||||
action_list = action_list + '<li>' + href + '</li>'
|
action_list = action_list + '<li>' + href + '</li>'
|
||||||
|
@ -1199,11 +1208,11 @@ class DatasourceAccessRequest(Model, AuditMixinNullable):
|
||||||
def user_roles(self):
|
def user_roles(self):
|
||||||
action_list = ''
|
action_list = ''
|
||||||
for r in self.created_by.roles: # pylint: disable=no-member
|
for r in self.created_by.roles: # pylint: disable=no-member
|
||||||
|
# pylint: disable=no-member
|
||||||
url = (
|
url = (
|
||||||
'/superset/approve?datasource_type={self.datasource_type}&'
|
f'/superset/approve?datasource_type={self.datasource_type}&'
|
||||||
'datasource_id={self.datasource_id}&'
|
f'datasource_id={self.datasource_id}&'
|
||||||
'created_by={self.created_by.username}&role_to_extend={r.name}'
|
f'created_by={self.created_by.username}&role_to_extend={r.name}'
|
||||||
.format(**locals())
|
|
||||||
)
|
)
|
||||||
href = '<a href="{}">Extend {} Role</a>'.format(url, r.name)
|
href = '<a href="{}">Extend {} Role</a>'.format(url, r.name)
|
||||||
if r.name in self.ROLES_BLACKLIST:
|
if r.name in self.ROLES_BLACKLIST:
|
||||||
|
|
|
@ -277,17 +277,6 @@ class AuditMixinNullable(AuditMixin):
|
||||||
def modified(self):
|
def modified(self):
|
||||||
return humanize.naturaltime(datetime.now() - self.changed_on)
|
return humanize.naturaltime(datetime.now() - self.changed_on)
|
||||||
|
|
||||||
@property
|
|
||||||
def icons(self):
|
|
||||||
return """
|
|
||||||
<a
|
|
||||||
href="{self.datasource_edit_url}"
|
|
||||||
data-toggle="tooltip"
|
|
||||||
title="{self.datasource}">
|
|
||||||
<i class="fa fa-database"></i>
|
|
||||||
</a>
|
|
||||||
""".format(**locals())
|
|
||||||
|
|
||||||
|
|
||||||
class QueryResult(object):
|
class QueryResult(object):
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ class Query(Model):
|
||||||
tab = (self.tab_name.replace(' ', '_').lower()
|
tab = (self.tab_name.replace(' ', '_').lower()
|
||||||
if self.tab_name else 'notab')
|
if self.tab_name else 'notab')
|
||||||
tab = re.sub(r'\W+', '', tab)
|
tab = re.sub(r'\W+', '', tab)
|
||||||
return 'sqllab_{tab}_{ts}'.format(**locals())
|
return f'sqllab_{tab}_{ts}'
|
||||||
|
|
||||||
|
|
||||||
class SavedQuery(Model, AuditMixinNullable):
|
class SavedQuery(Model, AuditMixinNullable):
|
||||||
|
@ -140,8 +140,8 @@ class SavedQuery(Model, AuditMixinNullable):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def pop_tab_link(self):
|
def pop_tab_link(self):
|
||||||
return Markup("""
|
return Markup(f"""
|
||||||
<a href="/superset/sqllab?savedQueryId={self.id}">
|
<a href="/superset/sqllab?savedQueryId={self.id}">
|
||||||
<i class="fa fa-link"></i>
|
<i class="fa fa-link"></i>
|
||||||
</a>
|
</a>
|
||||||
""".format(**locals()))
|
""")
|
||||||
|
|
|
@ -100,9 +100,9 @@ class SupersetQuery(object):
|
||||||
exec_sql = ''
|
exec_sql = ''
|
||||||
sql = self.stripped()
|
sql = self.stripped()
|
||||||
if overwrite:
|
if overwrite:
|
||||||
exec_sql = 'DROP TABLE IF EXISTS {table_name};\n'
|
exec_sql = f'DROP TABLE IF EXISTS {table_name};\n'
|
||||||
exec_sql += 'CREATE TABLE {table_name} AS \n{sql}'
|
exec_sql += f'CREATE TABLE {table_name} AS \n{sql}'
|
||||||
return exec_sql.format(**locals())
|
return exec_sql
|
||||||
|
|
||||||
def __extract_from_token(self, token):
|
def __extract_from_token(self, token):
|
||||||
if not hasattr(token, 'tokens'):
|
if not hasattr(token, 'tokens'):
|
||||||
|
|
|
@ -43,13 +43,15 @@ class DummyStatsLogger(BaseStatsLogger):
|
||||||
|
|
||||||
def timing(self, key, value):
|
def timing(self, key, value):
|
||||||
logging.debug((
|
logging.debug((
|
||||||
Fore.CYAN + '[stats_logger] (timing) {key} | {value} ' +
|
Fore.CYAN +
|
||||||
Style.RESET_ALL).format(**locals()))
|
f'[stats_logger] (timing) {key} | {value} ' +
|
||||||
|
Style.RESET_ALL))
|
||||||
|
|
||||||
def gauge(self, key, value):
|
def gauge(self, key, value):
|
||||||
logging.debug((
|
logging.debug((
|
||||||
Fore.CYAN + '[stats_logger] (gauge) '
|
Fore.CYAN + '[stats_logger] (gauge) ' +
|
||||||
'{key} | {value}' + Style.RESET_ALL).format(**locals()))
|
f'{key} | {value}' +
|
||||||
|
Style.RESET_ALL))
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -72,5 +74,5 @@ try:
|
||||||
# pylint: disable=no-value-for-parameter
|
# pylint: disable=no-value-for-parameter
|
||||||
self.client.gauge(key)
|
self.client.gauge(key)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -1275,9 +1275,8 @@ class Superset(BaseSupersetView):
|
||||||
'danger')
|
'danger')
|
||||||
return redirect(
|
return redirect(
|
||||||
'superset/request_access/?'
|
'superset/request_access/?'
|
||||||
'datasource_type={datasource_type}&'
|
f'datasource_type={datasource_type}&'
|
||||||
'datasource_id={datasource_id}&'
|
f'datasource_id={datasource_id}&')
|
||||||
''.format(**locals()))
|
|
||||||
|
|
||||||
viz_type = form_data.get('viz_type')
|
viz_type = form_data.get('viz_type')
|
||||||
if not viz_type and datasource.default_endpoint:
|
if not viz_type and datasource.default_endpoint:
|
||||||
|
@ -2115,7 +2114,7 @@ class Superset(BaseSupersetView):
|
||||||
'danger')
|
'danger')
|
||||||
return redirect(
|
return redirect(
|
||||||
'superset/request_access/?'
|
'superset/request_access/?'
|
||||||
'dashboard_id={dash.id}&'.format(**locals()))
|
f'dashboard_id={dash.id}&')
|
||||||
|
|
||||||
dash_edit_perm = check_ownership(dash, raise_if_false=False) and \
|
dash_edit_perm = check_ownership(dash, raise_if_false=False) and \
|
||||||
security_manager.can_access('can_save_dash', 'Superset')
|
security_manager.can_access('can_save_dash', 'Superset')
|
||||||
|
@ -2522,11 +2521,10 @@ class Superset(BaseSupersetView):
|
||||||
start_time=utils.now_as_float())
|
start_time=utils.now_as_float())
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.exception(e)
|
logging.exception(e)
|
||||||
msg = (
|
msg = _(
|
||||||
'Failed to start remote query on a worker. '
|
'Failed to start remote query on a worker. '
|
||||||
'Tell your administrator to verify the availability of '
|
'Tell your administrator to verify the availability of '
|
||||||
'the message queue.'
|
'the message queue.')
|
||||||
)
|
|
||||||
query.status = QueryStatus.FAILED
|
query.status = QueryStatus.FAILED
|
||||||
query.error_message = msg
|
query.error_message = msg
|
||||||
session.commit()
|
session.commit()
|
||||||
|
@ -2542,8 +2540,7 @@ class Superset(BaseSupersetView):
|
||||||
try:
|
try:
|
||||||
timeout = config.get('SQLLAB_TIMEOUT')
|
timeout = config.get('SQLLAB_TIMEOUT')
|
||||||
timeout_msg = (
|
timeout_msg = (
|
||||||
'The query exceeded the {timeout} seconds '
|
f'The query exceeded the {timeout} seconds timeout.')
|
||||||
'timeout.').format(**locals())
|
|
||||||
with utils.timeout(seconds=timeout,
|
with utils.timeout(seconds=timeout,
|
||||||
error_message=timeout_msg):
|
error_message=timeout_msg):
|
||||||
# pylint: disable=no-value-for-parameter
|
# pylint: disable=no-value-for-parameter
|
||||||
|
|
|
@ -273,7 +273,7 @@ class CoreTests(SupersetTestCase):
|
||||||
(slc.slice_name, 'explore_json', slc.explore_json_url),
|
(slc.slice_name, 'explore_json', slc.explore_json_url),
|
||||||
]
|
]
|
||||||
for name, method, url in urls:
|
for name, method, url in urls:
|
||||||
logging.info('[{name}]/[{method}]: {url}'.format(**locals()))
|
logging.info(f'[{name}]/[{method}]: {url}')
|
||||||
self.client.get(url)
|
self.client.get(url)
|
||||||
|
|
||||||
def test_tablemodelview_list(self):
|
def test_tablemodelview_list(self):
|
||||||
|
@ -319,8 +319,8 @@ class CoreTests(SupersetTestCase):
|
||||||
(slc.slice_name, 'slice_url', slc.slice_url),
|
(slc.slice_name, 'slice_url', slc.slice_url),
|
||||||
]
|
]
|
||||||
for name, method, url in urls:
|
for name, method, url in urls:
|
||||||
print('[{name}]/[{method}]: {url}'.format(**locals()))
|
print(f'[{name}]/[{method}]: {url}')
|
||||||
response = self.client.get(url)
|
self.client.get(url)
|
||||||
|
|
||||||
def test_doctests(self):
|
def test_doctests(self):
|
||||||
modules = [utils, models, sql_lab]
|
modules = [utils, models, sql_lab]
|
||||||
|
@ -478,8 +478,8 @@ class CoreTests(SupersetTestCase):
|
||||||
self.login('admin')
|
self.login('admin')
|
||||||
dbid = get_main_database(db.session).id
|
dbid = get_main_database(db.session).id
|
||||||
self.get_json_resp(
|
self.get_json_resp(
|
||||||
'/superset/extra_table_metadata/{dbid}/'
|
f'/superset/extra_table_metadata/{dbid}/'
|
||||||
'ab_permission_view/panoramix/'.format(**locals()))
|
'ab_permission_view/panoramix/')
|
||||||
|
|
||||||
def test_process_template(self):
|
def test_process_template(self):
|
||||||
maindb = get_main_database(db.session)
|
maindb = get_main_database(db.session)
|
||||||
|
|
|
@ -76,20 +76,20 @@ class DatabaseModelTestCase(SupersetTestCase):
|
||||||
table_name = 'energy_usage'
|
table_name = 'energy_usage'
|
||||||
sql = main_db.select_star(
|
sql = main_db.select_star(
|
||||||
table_name, show_cols=False, latest_partition=False)
|
table_name, show_cols=False, latest_partition=False)
|
||||||
expected = textwrap.dedent("""\
|
expected = textwrap.dedent(f"""\
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM {table_name}
|
FROM {table_name}
|
||||||
LIMIT 100""".format(**locals()))
|
LIMIT 100""")
|
||||||
assert sql.startswith(expected)
|
assert sql.startswith(expected)
|
||||||
|
|
||||||
sql = main_db.select_star(
|
sql = main_db.select_star(
|
||||||
table_name, show_cols=True, latest_partition=False)
|
table_name, show_cols=True, latest_partition=False)
|
||||||
expected = textwrap.dedent("""\
|
expected = textwrap.dedent(f"""\
|
||||||
SELECT source,
|
SELECT source,
|
||||||
target,
|
target,
|
||||||
value
|
value
|
||||||
FROM energy_usage
|
FROM energy_usage
|
||||||
LIMIT 100""".format(**locals()))
|
LIMIT 100""")
|
||||||
assert sql.startswith(expected)
|
assert sql.startswith(expected)
|
||||||
|
|
||||||
def test_grains_dict(self):
|
def test_grains_dict(self):
|
||||||
|
|
Loading…
Reference in New Issue