-
Notifications
You must be signed in to change notification settings - Fork 0
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 unittests to slack annotations #9
Conversation
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 this is going in a great direction, and I'm actually relieved to see that you've been able to refactor the one giant method into something reasonable :phew:
Just a couple of requests:
- I think you should move conditional logic out of
notify()
and into the helper functions that it calls instead. See below for specific suggestion. - Move the Slack-formatting functions into a separate file
- Group the tests for each function together into a test class
- For patching use fixtures with
autouse=True
andautospec=True
(see below for a specific suggestion)
def test_get_search_after_without_cache(): | ||
default = "2024-12-01T00:00:00+00:00" | ||
|
||
assert _get_search_after("", default) == default |
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.
There's quite a few separate functions to be tested, so it's probably worth group the tests for each function into a class. Just makes it easier to see where the tests for one function end and the next begins, and also opens up the possibility to localize fixtures into the classes that use them:
class TestGetSearchAfter:
def test_without_cache(self):
...
...
class TestNotify:
...
class TestFoo:
...
...
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'd recommend doing this in a separate PR, but if we changed cli.py
to pass an opened file object into notify()
instead of a cache_path
string, then we could add a unit test for get_search_after()
that passes in a StringIO
and properly tests how it reads the search_after
value from the JSON file contents.
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.
Alright, I made a few small suggestions but I think let's go ahead and get this merged.
For future PRs I think there'd be value in adding direct unittests for the rest of the helper functions in core.py
: looks like currently only notify()
and _get_search_after()
have unittests.
Also think there'd be value in adding docstrings to the various functions.
Fixes #6