-
Notifications
You must be signed in to change notification settings - Fork 22
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
Add tests for config #31
Conversation
We can expect the config values to read often, lru_cache is a simple way to make it behave like a singleton property.
Need this plugin because functools.lru_cache is used and this breaks testing.
@edmundmok bump, would like this change before I dive deeper into #7, as it introduces |
_config = config.get_config() | ||
|
||
assert _config['email_address'] == '[email protected]', 'email_address should come from user config override.' | ||
assert not _config['use_keyring'], 'use_keyring should be default value from template.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I forgot to remove use_keyring
when switching over from saving passwords to saving cookies. We can remove that in another PR if you want though.
Also, as per #23 we can use optionals and defaults as a way to fix this. I'll look into that if you're good with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I noticed that but was leaving it alone in this PR. It kinda helped testing because we don't have many other configs.
I'll comment in #23
@ipwnponies Sorry, just looked at it, was out the entire day yesterday. |
No worries, I put too much useful infrastructure into this PR that is helpful for follow up work. |
I moved the config logic to a separate module and added tests.
Summary of changes, in addition to the overall goal above:
python -m mealpy reserve foo bar baz
)check-requirements
check, it checks there are no requirements missing or extra fromrequirements.txt
pyfakefs
for effectively mocking file IO fromopen
,pathlib
,os.path
, etc. Allows for running tests without accidentally reading/writing real files (which I most certainly did by accident lol)pytest-antilru
for bustinglru_cache
under test