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

Convert get_config() to direct imports of CONFIG #2622

Merged
merged 23 commits into from
Feb 23, 2023

Conversation

ThomasLaPiana
Copy link
Contributor

@ThomasLaPiana ThomasLaPiana commented Feb 16, 2023

Closes #2611

Code Changes

  • find/replace imports of get_config with a direct CONFIG import (with a few exceptions where needed)
  • remove all instances of CONFIG = get_config() (with a few exceptions where needed)
  • fix the multiple "config loading" messages in the CLI by updating the verbose parameter in get_config

Steps to Confirm

  • run the CLI and confirm you only see one print of Loading config... (it only loads verbosely when called via the CLI, not on application load)
  • automated tests pass

Pre-Merge Checklist

Description Of Changes

There are a huge number of file changes here but the change itself is relatively minor, and all changes are described in the Code Changes section. The automated tests are the main way we'll know if this is functioning as expected or not.

NOTE: There is a code cov failure but I'm not sure why or how to fix it, so I'm asking the reviewer to approve in spite of this and I'll follow up separately

@ThomasLaPiana ThomasLaPiana self-assigned this Feb 16, 2023
@cypress
Copy link

cypress bot commented Feb 17, 2023

Passing run #335 ↗︎

0 3 0 0 Flakiness 0
⚠️ You've recorded test results over your free plan limit.
Upgrade your plan to view test results.

Details:

Merge f520b44 into 5f1ed28...
Project: fides Commit: 5c64049cf8 ℹ️
Status: Passed Duration: 00:38 💡
Started: Feb 23, 2023 2:42 PM Ended: Feb 23, 2023 2:43 PM

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings.

@codecov
Copy link

codecov bot commented Feb 18, 2023

Codecov Report

Base: 86.47% // Head: 86.46% // Decreases project coverage by -0.02% ⚠️

Coverage data is based on head (f520b44) compared to base (5f1ed28).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2622      +/-   ##
==========================================
- Coverage   86.47%   86.46%   -0.02%     
==========================================
  Files         289      289              
  Lines       16009    15955      -54     
  Branches     2019     2020       +1     
==========================================
- Hits        13844    13795      -49     
+ Misses       1782     1778       -4     
+ Partials      383      382       -1     
Impacted Files Coverage Δ
src/fides/api/ctl/database/database.py 86.95% <ø> (-0.37%) ⬇️
...es/api/ops/api/v1/endpoints/messaging_endpoints.py 92.56% <ø> (-0.13%) ⬇️
...s/api/ops/service/connectors/fides/fides_client.py 78.12% <ø> (-0.45%) ⬇️
.../ops/service/messaging/message_dispatch_service.py 59.70% <ø> (-0.39%) ⬇️
...api/ops/service/privacy_request/request_service.py 91.66% <ø> (-0.27%) ⬇️
...ementations/friendbuy_nextgen_request_overrides.py 58.82% <ø> (-4.34%) ⬇️
src/fides/core/user.py 100.00% <ø> (ø)
src/fides/api/ctl/database/seed.py 100.00% <100.00%> (ø)
src/fides/api/ctl/database/session.py 100.00% <100.00%> (ø)
src/fides/api/ctl/routes/admin.py 95.83% <100.00%> (-0.17%) ⬇️
... and 40 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@ThomasLaPiana ThomasLaPiana marked this pull request as ready for review February 20, 2023 05:24
@ThomasLaPiana
Copy link
Contributor Author

@sanders41 do you know how to get code cov to ignore print statements as part of coverage? Or maybe what I can do to test it to make code cov happy?

@sanders41
Copy link
Contributor

You can test prints with something like:

def my_print():
    print("My print string")


def test_my_print(capfd):
    my_print()
    out, _ = capfd.readouterr()

    assert "My print" in out

It is also possible to ignore in coverage. I try to save this for places where I here tried everything and can't get the code in a state to hit the line in tests.

def my_print():
    print("My print string")  # pragma: no cover

@ThomasLaPiana
Copy link
Contributor Author

You can test prints with something like:

def my_print():
    print("My print string")


def test_my_print(capfd):
    my_print()
    out, _ = capfd.readouterr()

    assert "My print" in out

It is also possible to ignore in coverage. I try to save this for places where I here tried everything and can't get the code in a state to hit the line in tests.

def my_print():
    print("My print string")  # pragma: no cover

I have some print statement tests elsewhere but here I don't feel it is really necessary....

Will ignore it for now, thanks!

Copy link
Contributor

@seanpreston seanpreston left a comment

Choose a reason for hiding this comment

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

A couple of nits, but a large and useful change, thanks @ThomasLaPiana

@ThomasLaPiana ThomasLaPiana merged commit ef63323 into main Feb 23, 2023
@ThomasLaPiana ThomasLaPiana deleted the ThomasLaPiana-directly-import-CONFIG branch February 23, 2023 14:58
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.

Replace get_config in most places with importing CONFIG directly
3 participants