'Calling POST /json/users/me/subscriptions should successfully add
streams, and a stream to the
list of subscriptions and confirm the right number of events
are generated.
When \'principals\' has a bot, no notification message event or invitation email
is sent when add_subscriptions_backend is called in the above api call.'

def test_bot_add_subscription(self):

    self.login(self.example_email('hamlet'))
    request_data = {'principals': (('["' + self.example_email('iago')) + '"]')}
    events = []
    with tornado_redirected_to_list(events):
        result = self.common_subscribe_to_streams(self.example_email('hamlet'), ['Rome'], request_data)
        self.assert_json_success(result)
    msg_event = [e for e in events if (e['event']['type'] == 'message')]
    self.assert_length(msg_event, 1)
    self.assert_num_bots_equal(0)
    result = self.create_bot()
    self.assert_num_bots_equal(1)
    bot_request_data = {'principals': '["hambot-bot@zulip.testserver"]'}
    events_bot = []
    with tornado_redirected_to_list(events_bot):
        result = self.common_subscribe_to_streams(self.example_email('hamlet'), ['Rome'], bot_request_data)
        self.assert_json_success(result)
    msg_event = [e for e in events_bot if (e['event']['type'] == 'message')]
    self.assert_length(msg_event, 0)
    self.assertEqual(len(events_bot), (len(events) - 1))
    self.assertEqual(len(mail.outbox), 0)
