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

Fix tests failing if run with OPTA_DISABLE_REPORTING=1 #831

Merged
merged 2 commits into from
Apr 15, 2022

Conversation

rabbitfang
Copy link
Collaborator

Description

If you run Python tests (i.e. make test) locally while OPTA_DISABLE_REPORTING=1 is set in your terminal, tests will fail because the datadog and amplitude tests rely on that env var not being set when the test is run, but they do not validate that assumption. This PR adds a pytest fixture that makes it easy to handle that case.

The hide_debug_mode fixture unsets configured env vars (currently, only OPTA_DISABLE_REPORTING) as well as sys._called_from_test during the test and restores the original values after the test. It is defined in tests/conftest.py to make it available to any test under tests/.

This PR also removes # noqa lines from the amplitude and datadog test files as part of cleanup.

Safety checklist

  • This change is backwards compatible and safe to apply by existing users
  • This change will NOT lead to data loss
  • This change will NOT lead to downtime who already has an env/service setup

How has this change been tested, beside unit tests?

This change only affects unit tests.

@codecov
Copy link

codecov bot commented Apr 15, 2022

Codecov Report

Merging #831 (75b352c) into main (34b747c) will increase coverage by 0.17%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main     #831      +/-   ##
==========================================
+ Coverage   73.89%   74.06%   +0.17%     
==========================================
  Files         117      119       +2     
  Lines        7761     7821      +60     
==========================================
+ Hits         5735     5793      +58     
- Misses       2026     2028       +2     
Flag Coverage Δ
unittests 74.06% <ø> (+0.17%) ⬆️

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

Impacted Files Coverage Δ
opta/layer.py 82.71% <0.00%> (ø)
modules/tests/test_aws_base.py 100.00% <0.00%> (ø)
modules/aws_base/aws_base.py 90.90% <0.00%> (ø)

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 34b747c...75b352c. Read the comment docs.

@rabbitfang rabbitfang merged commit ac3039a into main Apr 15, 2022
@rabbitfang rabbitfang deleted the bugfix/tests-with-disable-reporting branch April 15, 2022 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants