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: autouse app_context in unit tests #20911

Merged
merged 1 commit into from
Aug 2, 2022

Conversation

ktmud
Copy link
Member

@ktmud ktmud commented Jul 29, 2022

SUMMARY

I have yet to see a test case where having an app_context is troublesome. Since it's fairly cheap to create a new context, we can just autouse the app_context fixture to save some boilerplate code.

Doing this for integration tests may have more complications. Will try it in another PR.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A

TESTING INSTRUCTIONS

CI

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@codecov
Copy link

codecov bot commented Jul 29, 2022

Codecov Report

Merging #20911 (e5fe01c) into master (e739ff5) will decrease coverage by 0.69%.
The diff coverage is n/a.

❗ Current head e5fe01c differs from pull request most recent head e0dc6be. Consider uploading reports for the commit e0dc6be to get more accurate results

@@            Coverage Diff             @@
##           master   #20911      +/-   ##
==========================================
- Coverage   66.29%   65.60%   -0.70%     
==========================================
  Files        1758     1758              
  Lines       67010    67010              
  Branches     7107     7107              
==========================================
- Hits        44426    43960     -466     
- Misses      20762    21228     +466     
  Partials     1822     1822              
Flag Coverage Δ
hive 53.25% <ø> (ø)
postgres ?
presto 53.15% <ø> (ø)
python 80.07% <ø> (-1.44%) ⬇️
sqlite 79.67% <ø> (ø)
unit 50.60% <ø> (ø)

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

Impacted Files Coverage Δ
superset/datasets/commands/update.py 25.30% <0.00%> (-68.68%) ⬇️
superset/datasets/commands/create.py 29.41% <0.00%> (-68.63%) ⬇️
superset/datasets/commands/delete.py 38.63% <0.00%> (-54.55%) ⬇️
superset/datasets/commands/bulk_delete.py 33.33% <0.00%> (-53.34%) ⬇️
superset/datasets/columns/commands/delete.py 44.11% <0.00%> (-52.95%) ⬇️
superset/datasets/metrics/commands/delete.py 44.11% <0.00%> (-52.95%) ⬇️
superset/sql_validators/postgres.py 50.00% <0.00%> (-50.00%) ⬇️
superset/datasets/dao.py 46.42% <0.00%> (-47.86%) ⬇️
superset/datasets/commands/refresh.py 43.75% <0.00%> (-43.75%) ⬇️
superset/datasets/api.py 50.22% <0.00%> (-38.12%) ⬇️
... and 22 more

Help us with your feedback. Take ten seconds to tell us how you rate us.

Copy link
Member

@justinpark justinpark 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

Copy link
Member

@betodealmeida betodealmeida left a comment

Choose a reason for hiding this comment

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

This is awesome!

Copy link
Member

@john-bodley john-bodley left a comment

Choose a reason for hiding this comment

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

@ktmud you might want to remove the importing of AppContext—used for typing in the tests. Sadly if CI is passing it means we likely aren't running Pylint in the tests.

@ktmud ktmud merged commit 7e836e9 into apache:master Aug 2, 2022
@ktmud
Copy link
Member Author

ktmud commented Aug 2, 2022

@john-bodley I didn't find any more imports of AppContext in unit_tests so merged the PR as is. Will do another sweep to see if autouse AppContext is possible on integration tests in another PR.

jinghua-qa pushed a commit to preset-io/superset that referenced this pull request Aug 5, 2022
@john-bodley john-bodley deleted the autouse-app-context branch February 17, 2023 22:16
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.1.0 and removed 🚢 2.1.3 labels Mar 13, 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 preset:2022.31 size/L 🚢 2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants