-
Notifications
You must be signed in to change notification settings - Fork 13.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: birth names #12226
test: birth names #12226
Conversation
Hey! Could you look at it? @willbarrett @dpgaspar |
d7e0984
to
5c56fb8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good - one comment on teardown, then this needs a rebase.
tests/celery_tests.py
Outdated
@@ -208,7 +214,10 @@ def test_run_sync_query_cta_config(setup_sqllab, ctas_method): | |||
results = run_sql(query.select_sql) | |||
assert QueryStatus.SUCCESS == results["status"], result | |||
|
|||
db.get_engine().execute(f"DROP {ctas_method} {CTAS_SCHEMA_NAME}.{tmp_table_name}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be refactored into a shared teardown method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but has a conflict and left a couple of comments (most non blocking for sure)
superset/examples/birth_names.py
Outdated
create_dashboard(slices) | ||
|
||
|
||
def _set_table_metadata(obj: "BaseDatasource", database: "Database") -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: obj: "BaseDatasource"
is called tbl: "BaseDatasource"
on create_slices
we could name them equally maybe datasource
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
superset/examples/birth_names.py
Outdated
obj.database = database | ||
obj.filter_select_enabled = True | ||
obj.fetch_metadata() | ||
|
||
|
||
def _add_table_metrics(obj: "BaseDatasource") -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
superset/examples/birth_names.py
Outdated
@@ -161,7 +169,7 @@ def create_slices(tbl: BaseDatasource) -> Tuple[List[Slice], List[Slice]]: | |||
} | |||
|
|||
slice_props = dict( | |||
datasource_id=tbl.id, datasource_type="table", owners=[admin], created_by=admin | |||
datasource_id=tbl.id, datasource_type="table", owners=[], created_by=admin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
tests/charts/api_tests.py
Outdated
@@ -435,6 +436,11 @@ def test_create_chart(self): | |||
""" | |||
Chart API: Test create chart | |||
""" | |||
dashes = ( | |||
db.session.query(Dashboard) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we can just select the id's here db.session.query(Dashboard.id)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -43,14 +43,12 @@ def setup_sample_data() -> Any: | |||
|
|||
examples.load_css_templates() | |||
examples.load_world_bank_health_n_pop(sample=True) | |||
examples.load_birth_names(sample=True) | |||
|
|||
yield | |||
|
|||
with app.app_context(): | |||
engine = get_example_database().get_sqla_engine() | |||
engine.execute("DROP TABLE wb_health_population") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use IF EXISTS
here also?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean leaving sth like this: engine.execute("DROP TABLE IF EXISTS birth_names")
?
@@ -730,6 +747,7 @@ def test_fetch_datasource_metadata(self): | |||
for k in keys: | |||
self.assertIn(k, resp.keys()) | |||
|
|||
@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is replicated on almost every method, can we use the fixture at the module level?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to load fresh data for each test because some tests may modify data a bit. Using module fixture may result in creating some flaky tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, will probably load fast enough also
tests/dashboards/api_tests.py
Outdated
@@ -1147,7 +1152,12 @@ def test_export_bundle(self): | |||
""" | |||
Dashboard API: Test dashboard export | |||
""" | |||
argument = [1, 2] | |||
dashes = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: would be nice to refactor and make this DRY
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -234,7 +234,8 @@ def test_import_v0_dataset_cli_export(self): | |||
assert len(dataset.metrics) == 2 | |||
assert dataset.main_dttm_col == "ds" | |||
assert dataset.filter_select_enabled | |||
assert [col.column_name for col in dataset.columns] == [ | |||
dataset.columns.sort(key=lambda obj: obj.column_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, this was probably flaky
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM after conflicts and CI passes
809b36b
to
7ed833b
Compare
Codecov Report
@@ Coverage Diff @@
## master #12226 +/- ##
==========================================
- Coverage 66.15% 62.74% -3.41%
==========================================
Files 1014 1014
Lines 49510 49506 -4
Branches 5063 5077 +14
==========================================
- Hits 32753 31063 -1690
- Misses 16607 18233 +1626
- Partials 150 210 +60
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
39e188c
to
29ec8f9
Compare
7e905de
to
fb7653f
Compare
* add birth names fixture * fix birth names related tests * fix test_import_v0_dataset_cli_export columns order * fix celery tests drop table * fix mysql datetime type * fix mysql typo in charts/api_tests * refactor * add licence * fix use fixture for presto * fix presto, hive query * fix flaky metadata * fix mysql bigint type * fix run query * fix hive datatype in metadata * fix slice owner for cypress * refactor num_boys num_girls * fix is_dttm column * debug logging * fix query offset * fix presto ds type in metadata * fix presto ds type * clean up debug logging
* add birth names fixture * fix birth names related tests * fix test_import_v0_dataset_cli_export columns order * fix celery tests drop table * fix mysql datetime type * fix mysql typo in charts/api_tests * refactor * add licence * fix use fixture for presto * fix presto, hive query * fix flaky metadata * fix mysql bigint type * fix run query * fix hive datatype in metadata * fix slice owner for cypress * refactor num_boys num_girls * fix is_dttm column * debug logging * fix query offset * fix presto ds type in metadata * fix presto ds type * clean up debug logging
SUMMARY
Replace birth names example with fixtures for testing.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TEST PLAN
All tests should pass.
ADDITIONAL INFORMATION