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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Return callback from RTMClient.run_on
#490
Conversation
Codecov Report
@@ Coverage Diff @@
## master #490 +/- ##
=========================================
+ Coverage 69.58% 69.6% +0.01%
=========================================
Files 15 15
Lines 1654 1655 +1
Branches 91 91
=========================================
+ Hits 1151 1152 +1
Misses 481 481
Partials 22 22
Continue to review full report at Codecov.
|
tests/rtm/test_rtm_client.py
Outdated
def fn_used_elsewhere(**payload): | ||
pass | ||
|
||
self.assertTrue(fn_used_elsewhere != None) |
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.
self.assertIsNotNone(fn_used_elsewhere)
would be better.
tests/rtm/test_rtm_client.py
Outdated
pass | ||
|
||
self.assertTrue(fn_used_elsewhere != None) | ||
self.assertTrue(fn_used_elsewhere.__name__ == "fn_used_elsewhere") |
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.
self.assertEqual(fn_used_elsewhere.__name__, "fn_used_elsewhere")
would be better.
tests/rtm/test_rtm_client.py
Outdated
@@ -17,6 +17,14 @@ def setUp(self): | |||
def tearDown(self): | |||
slack.RTMClient._callbacks = collections.defaultdict(list) | |||
|
|||
def test_run_on_returns_callback(self): | |||
@slack.RTMClient.run_on(event="message") | |||
def fn_used_elsewhere(**_unusedPayload): |
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.
_unused_payload
would be better, as it is written with correct casing according to PEP8.
Names are important 馃槃
This seems like a useful change also for chaining multiple similar events to the same callback:
Will currently attach
But with this patchset would hook up the method to both events. |
Summary
Returns the callback passed into
RTMClient.run_on
so that it can be called elsewhere. For example:Requirements