Skip to content

settings config instead of global var#44

Merged
nabobalis merged 2 commits intomainfrom
url
Jul 28, 2022
Merged

settings config instead of global var#44
nabobalis merged 2 commits intomainfrom
url

Conversation

@nabobalis
Copy link
Member

No description provided.

@nabobalis nabobalis marked this pull request as ready for review July 25, 2022 18:09
Comment on lines +15 to +16
for n in self.envars:
os.environ.pop(n)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should you reset self.envars back to an empty set after this?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it would be safe to do in a unit test but I can make this take a list of keys to remove instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Wait, I can't read code. This will only remove envs that have been added by this class.
So doing this back to an empty set is ok, since it won't affect anything existing ones in os.environ

Comment on lines 28 to 33
def test_set_url_env(env):
env.set("HELIOVIEWER_API_URL", "https://fake_env_url/")

from hvpy.config import Settings

assert Settings().api_url == "https://fake_env_url/"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we add one more assertion after this that if you call set_api_url it uses the url passed in instead of the environment?

Copy link
Member Author

Choose a reason for hiding this comment

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

I can do that but I am not sure it would be useful here.

The set_api_url function will not change this specific url since this Setting is not affected by that by the LiveSettings.

@nabobalis
Copy link
Member Author

I will admit this is kind of overkill for setting the base url.

@codecov-commenter
Copy link

codecov-commenter commented Jul 27, 2022

Codecov Report

Merging #44 (bc8986e) into main (e3d7f0f) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##              main       #44   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           12        13    +1     
  Lines          196       198    +2     
=========================================
+ Hits           196       198    +2     
Impacted Files Coverage Δ
hvpy/config.py 100.00% <100.00%> (ø)
hvpy/io.py 100.00% <100.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 e3d7f0f...bc8986e. Read the comment docs.

@nabobalis nabobalis merged commit 4012c6d into main Jul 28, 2022
@nabobalis nabobalis deleted the url branch July 28, 2022 15:49
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.

3 participants

Comments