Add unit test to ensure source_channel gets passed to execution context (currently fails)
@@ -188,9 +188,9 @@ class AliasExecutionTestCase(FunctionalTest):
return_value=(None, EXECUTION))
def test_match_and_execute_matches_one(self, mock_request):
base_data = {
- 'source_channel': 'chat',
+ 'source_channel': 'chat-channel',
'notification_route': 'hubot',
- 'user': 'chat-user'
+ 'user': 'chat-user',
}
# Command matches - should result in action execution
@@ -205,6 +205,16 @@ class AliasExecutionTestCase(FunctionalTest):
expected_parameters = {'cmd': 'date', 'hosts': 'localhost'}
self.assertEquals(mock_request.call_args[0][0].parameters, expected_parameters)
+ # Also check for source_channel - see
+ # https://github.com/StackStorm/st2/issues/4650
+ expected_context = {
+ 'action_alias_ref': '',
+ 'api_user': '',
+ 'user': 'chat-user',
+ 'source_channel': 'chat-channel',
+ }
+ self.assertEquals(mock_request.call_args[0][0].context, expected_context)
+
@mock.patch.object(action_service, 'request',
return_value=(None, EXECUTION))
def test_match_and_execute_matches_one_multiple_match(self, mock_request):
