fix tests

This commit is contained in:
Ville Brofeldt
2022-04-11 09:49:29 +03:00
parent 13e81c683e
commit 419316e84a
4 changed files with 2 additions and 50 deletions

View File

@@ -79,7 +79,7 @@ class QueryObjectFactory: # pylint: disable=too-few-public-methods
str(datasource["type"]), int(datasource["id"]), self._session_maker() str(datasource["type"]), int(datasource["id"]), self._session_maker()
) )
def _process_extras( # pylint: disable=no-self-use def _process_extras(
self, self,
extras: Optional[Dict[str, Any]], extras: Optional[Dict[str, Any]],
) -> Dict[str, Any]: ) -> Dict[str, Any]:

View File

@@ -574,7 +574,6 @@ def get_rls_for_table(
return None return None
template_processor = dataset.get_template_processor() template_processor = dataset.get_template_processor()
# pylint: disable=protected-access
predicate = " AND ".join( predicate = " AND ".join(
str(filter_) str(filter_)
for filter_ in dataset.get_sqla_row_level_filters(template_processor) for filter_ in dataset.get_sqla_row_level_filters(template_processor)

View File

@@ -630,7 +630,7 @@ class DatasourceFilter(BaseFilter): # pylint: disable=too-few-public-methods
) )
class CsvResponse(Response): class CsvResponse(Response): # pylint: disable=too-many-ancestors
""" """
Override Response to take into account csv encoding from config.py Override Response to take into account csv encoding from config.py
""" """

View File

@@ -658,53 +658,6 @@ def test_filter_on_text_column(text_column_table):
assert result_object.df["count"][0] == 1 assert result_object.df["count"][0] == 1
def test_should_generate_closed_and_open_time_filter_range():
with app.app_context():
if backend() != "postgresql":
pytest.skip(f"{backend()} has different dialect for datetime column")
table = SqlaTable(
table_name="temporal_column_table",
sql=(
"SELECT '2021-12-31'::timestamp as datetime_col "
"UNION SELECT '2022-01-01'::timestamp "
"UNION SELECT '2022-03-10'::timestamp "
"UNION SELECT '2023-01-01'::timestamp "
"UNION SELECT '2023-03-10'::timestamp "
),
database=get_example_database(),
)
TableColumn(
column_name="datetime_col",
type="TIMESTAMP",
table=table,
is_dttm=True,
)
SqlMetric(metric_name="count", expression="count(*)", table=table)
result_object = table.query(
{
"metrics": ["count"],
"is_timeseries": False,
"filter": [],
"from_dttm": datetime(2022, 1, 1),
"to_dttm": datetime(2023, 1, 1),
"granularity": "datetime_col",
}
)
""" >>> result_object.query
SELECT count(*) AS count
FROM
(SELECT '2021-12-31'::timestamp as datetime_col
UNION SELECT '2022-01-01'::timestamp
UNION SELECT '2022-03-10'::timestamp
UNION SELECT '2023-01-01'::timestamp
UNION SELECT '2023-03-10'::timestamp) AS virtual_table
WHERE datetime_col >= TO_TIMESTAMP('2022-01-01 00:00:00.000000', 'YYYY-MM-DD HH24:MI:SS.US')
AND datetime_col < TO_TIMESTAMP('2023-01-01 00:00:00.000000', 'YYYY-MM-DD HH24:MI:SS.US')
"""
assert result_object.df.iloc[0]["count"] == 2
@pytest.mark.parametrize( @pytest.mark.parametrize(
"row,dimension,result", "row,dimension,result",
[ [