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

Add tests for config #31

Merged
merged 5 commits into from
May 1, 2019
Merged

Conversation

ipwnponies
Copy link
Collaborator

I moved the config logic to a separate module and added tests.

Summary of changes, in addition to the overall goal above:

  • made this an executable package (python -m mealpy reserve foo bar baz)
  • Added check-requirements check, it checks there are no requirements missing or extra from requirements.txt
  • pyfakefs for effectively mocking file IO from open, 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 busting lru_cache under test

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.
@ipwnponies
Copy link
Collaborator Author

@edmundmok bump, would like this change before I dive deeper into #7, as it introduces pyfakefs, which will make it easier to test caching files to disk.

_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.'
Copy link
Owner

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.

Copy link
Collaborator Author

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

@edmundmok
Copy link
Owner

@ipwnponies Sorry, just looked at it, was out the entire day yesterday.

@ipwnponies
Copy link
Collaborator Author

No worries, I put too much useful infrastructure into this PR that is helpful for follow up work.

@ipwnponies ipwnponies merged commit c252fd7 into edmundmok:master May 1, 2019
@ipwnponies ipwnponies deleted the test-config branch May 1, 2019 16: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.

2 participants