'Calling POST /json/users/me/subscriptions should notify when a new stream is created.'

def test_successful_subscriptions_notifies_stream(self):

    invitee = self.example_email('iago')
    invitee_full_name = 'Iago'
    current_stream = self.get_streams(invitee, self.test_realm)[0]
    invite_streams = self.make_random_stream_names([current_stream])[:1]
    notifications_stream = get_stream(current_stream, self.test_realm)
    self.test_realm.notifications_stream = notifications_stream
    self.test_realm.save()
    cache.cache_delete(cache.user_profile_by_email_cache_key(invitee))
    result = self.common_subscribe_to_streams(invitee, invite_streams, extra_post_data=dict(announce='true', principals=('["%s"]' % (self.user_profile.email,))))
    self.assert_json_success(result)
    msg = self.get_second_to_last_message()
    self.assertEqual(msg.recipient.type, Recipient.STREAM)
    self.assertEqual(msg.sender_id, self.notification_bot().id)
    expected_msg = ('%s    just    created    a    new    stream    #**%s**.' % (invitee_full_name, invite_streams[0]))
    self.assertEqual(msg.content, expected_msg)
