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

Tests: Use global no_throttling_everywhere fixture #701

Merged
merged 1 commit into from
Oct 16, 2022

Conversation

amotl
Copy link
Collaborator

@amotl amotl commented Oct 15, 2022

#687 added a no_throttling function-scoped fixture, which needed to be individually attached to specific test cases.

Instead of needing to individually disable throttling on a per-plugin basis, the new no_throttling_everywhere session-scoped fixture takes care of all notifiers in NOTIFY_MODULE_MAP automatically. With autouse=True, there is no need to activate it manually.

I've broke this away from #689, in order to make the review of each patch a bit easier.

Instead of needing to individually disable throttling on a per-plugin
basis, this fixture takes care of all notifiers in `NOTIFY_MODULE_MAP`
automatically. With `autouse=True`, there is no need to activate it
manually.
@codecov-commenter
Copy link

codecov-commenter commented Oct 15, 2022

Codecov Report

Base: 100.00% // Head: 100.00% // No change to project coverage 👍

Coverage data is based on head (c9f8cae) compared to base (ed876d1).
Patch has no changes to coverable lines.

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #701   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          113       113           
  Lines        14532     14532           
  Branches      2959      2959           
=========================================
  Hits         14532     14532           

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.

Comment on lines -36 to +43
@pytest.fixture
def no_throttling():
@pytest.fixture(scope="session", autouse=True)
def no_throttling_everywhere(session_mocker):
"""
A pytest fixture which disables Apprise throttling.
A pytest session fixture which disables throttling on all notifiers.
It is automatically enabled.
"""
backup = {}
backup["NotifyBase"] = NotifyBase.request_rate_per_sec
backup["NotifyPushBullet"] = NotifyPushBullet.request_rate_per_sec
NotifyBase.request_rate_per_sec = 0
NotifyPushBullet.request_rate_per_sec = 0
yield
NotifyBase.request_rate_per_sec = backup["NotifyBase"]
NotifyPushBullet.request_rate_per_sec = backup["NotifyPushBullet"]
for notifier in NOTIFY_MODULE_MAP.values():
plugin = notifier["plugin"]
session_mocker.patch.object(plugin, "request_rate_per_sec", 0)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think this makes a dream come true? Thanks for insisting to steward me into this direction. It is rather heavy, yet beautiful. I like it.

Copy link
Owner

Choose a reason for hiding this comment

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

I love it! Great work

@amotl amotl marked this pull request as ready for review October 15, 2022 02:49
@caronc caronc merged commit c81d246 into caronc:master Oct 16, 2022
@caronc caronc deleted the amo/tests-no-throttling branch October 16, 2022 14:48
amotl added a commit to panodata/apprise that referenced this pull request Oct 17, 2022
Instead of needing to individually disable throttling on a per-plugin
basis, this fixture takes care of all notifiers in `NOTIFY_MODULE_MAP`
automatically. With `autouse=True`, there is no need to activate it
manually.
amotl added a commit to panodata/apprise that referenced this pull request Oct 18, 2022
Instead of needing to individually disable throttling on a per-plugin
basis, this fixture takes care of all notifiers in `NOTIFY_MODULE_MAP`
automatically. With `autouse=True`, there is no need to activate it
manually.
amotl added a commit to panodata/apprise that referenced this pull request Oct 18, 2022
Instead of needing to individually disable throttling on a per-plugin
basis, this fixture takes care of all notifiers in `NOTIFY_MODULE_MAP`
automatically. With `autouse=True`, there is no need to activate it
manually.
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.

None yet

3 participants