-
-
Notifications
You must be signed in to change notification settings - Fork 375
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
Conversation
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.
895c1ff
to
c9f8cae
Compare
Codecov ReportBase: 100.00% // Head: 100.00% // No change to project coverage 👍
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. |
@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) |
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 makes a dream come true? Thanks for insisting to steward me into this direction. It is rather heavy, yet beautiful. I like 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.
I love it! Great work
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.
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.
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.
#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 inNOTIFY_MODULE_MAP
automatically. Withautouse=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.