Skip to content
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

Merged
merged 22 commits into from
Jan 11, 2021
Merged

test: birth names #12226

merged 22 commits into from
Jan 11, 2021

Conversation

kstrz
Copy link
Contributor

@kstrz kstrz commented Dec 30, 2020

SUMMARY

Replace birth names example with fixtures for testing.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TEST PLAN

All tests should pass.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

@kstrz
Copy link
Contributor Author

kstrz commented Dec 30, 2020

Hey! Could you look at it? @willbarrett @dpgaspar

Copy link
Member

@willbarrett willbarrett left a 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.

@@ -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}")
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

@dpgaspar dpgaspar left a 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)

create_dashboard(slices)


def _set_table_metadata(obj: "BaseDatasource", database: "Database") -> None:
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

obj.database = database
obj.filter_select_enabled = True
obj.fetch_metadata()


def _add_table_metrics(obj: "BaseDatasource") -> None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: same here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

@@ -435,6 +436,11 @@ def test_create_chart(self):
"""
Chart API: Test create chart
"""
dashes = (
db.session.query(Dashboard)
Copy link
Member

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)

Copy link
Contributor Author

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")
Copy link
Member

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?

Copy link
Contributor Author

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")
Copy link
Member

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?

Copy link
Contributor Author

@kstrz kstrz Jan 5, 2021

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.

Copy link
Member

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

@@ -1147,7 +1152,12 @@ def test_export_bundle(self):
"""
Dashboard API: Test dashboard export
"""
argument = [1, 2]
dashes = (
Copy link
Member

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

Copy link
Contributor Author

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)
Copy link
Member

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

@nytai nytai closed this Jan 6, 2021
@nytai nytai reopened this Jan 6, 2021
Copy link
Member

@dpgaspar dpgaspar left a 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

@codecov-io
Copy link

codecov-io commented Jan 7, 2021

Codecov Report

Merging #12226 (09cfb37) into master (64b4977) will decrease coverage by 3.40%.
The diff coverage is 76.00%.

Impacted file tree graph

@@            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     
Flag Coverage Δ
cypress ?
javascript 60.72% <ø> (+0.02%) ⬆️
python 64.06% <76.00%> (-0.15%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
superset/examples/birth_names.py 73.19% <76.00%> (-25.65%) ⬇️
superset-frontend/src/explore/App.jsx 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/dashboard/App.jsx 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/chart/ChartContainer.jsx 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/explore/reducers/index.js 0.00% <0.00%> (-100.00%) ⬇️
...et-frontend/src/dashboard/containers/Dashboard.jsx 0.00% <0.00%> (-100.00%) ⬇️
...et-frontend/src/filters/components/Select/types.ts 0.00% <0.00%> (-100.00%) ⬇️
...t-frontend/src/explore/reducers/getInitialState.js 0.00% <0.00%> (-100.00%) ⬇️
...-frontend/src/visualizations/presets/MainPreset.js 0.00% <0.00%> (-100.00%) ⬇️
...tend/src/dashboard/containers/DashboardBuilder.jsx 0.00% <0.00%> (-100.00%) ⬇️
... and 189 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 64b4977...09cfb37. Read the comment docs.

@kstrz kstrz closed this Jan 11, 2021
@kstrz kstrz reopened this Jan 11, 2021
@willbarrett willbarrett merged commit 2ab490a into apache:master Jan 11, 2021
amitmiran137 pushed a commit to nielsen-oss/superset that referenced this pull request Jan 14, 2021
* 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
villebro pushed a commit that referenced this pull request Jan 25, 2021
* 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
@mistercrunch mistercrunch added 🍒 1.0.1 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.2.0 labels Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/XL v1.0.1 🍒 1.0.1 🚢 1.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants