'Check users getting add_peer_event is correct'

def test_users_getting_add_peer_event(self):

    streams_to_sub = ['multi_user_stream']
    orig_emails_to_subscribe = [self.test_email, self.example_email('othello')]
    self.common_subscribe_to_streams(self.test_email, streams_to_sub, dict(principals=ujson.dumps(orig_emails_to_subscribe)))
    new_emails_to_subscribe = [self.example_email('iago'), self.example_email('cordelia')]
    events = []
    with tornado_redirected_to_list(events):
        self.common_subscribe_to_streams(self.test_email, streams_to_sub, dict(principals=ujson.dumps(new_emails_to_subscribe)))
    add_peer_events = [events[2], events[3]]
    for add_peer_event in add_peer_events:
        self.assertEqual(add_peer_event['event']['type'], 'subscription')
        self.assertEqual(add_peer_event['event']['op'], 'peer_add')
        event_sent_to_ids = add_peer_event['users']
        sent_emails = [get_user_profile_by_id(user_id).email for user_id in event_sent_to_ids]
        for email in new_emails_to_subscribe:
            self.assertNotIn(email, sent_emails)
        for old_user in orig_emails_to_subscribe:
            self.assertIn(old_user, sent_emails)
