'You can set a message as starred/un-starred through
POST /json/messages/flags.'

def test_change_star_public_stream_historical(self):

    stream_name = 'new_stream'
    self.subscribe_to_stream(self.example_email('hamlet'), stream_name)
    self.login(self.example_email('hamlet'))
    message_ids = [self.send_message(self.example_email('hamlet'), stream_name, Recipient.STREAM, 'test')]
    other_message_ids = [self.send_message(self.example_email('hamlet'), stream_name, Recipient.STREAM, 'test_unused')]
    received_message_ids = [self.send_message(self.example_email('hamlet'), [self.example_email('cordelia')], Recipient.PERSONAL, 'test_received')]
    self.login(self.example_email('cordelia'))
    sent_message_ids = [self.send_message(self.example_email('cordelia'), [self.example_email('cordelia')], Recipient.PERSONAL, 'test_read_message')]
    result = self.client_post('/json/messages/flags', {'messages': ujson.dumps(sent_message_ids), 'op': 'add', 'flag': 'read'})
    result = self.client_post('/json/messages/flags', {'messages': ujson.dumps(message_ids), 'op': 'add', 'flag': 'read'})
    self.assert_json_error(result, 'Invalid    message(s)')
    result = self.change_star((message_ids * 2))
    self.assert_json_error(result, 'Invalid    message(s)')
    result = self.change_star(message_ids)
    self.assert_json_success(result)
    for msg in self.get_messages():
        if (msg['id'] in message_ids):
            self.assertEqual(set(msg['flags']), {'starred', 'historical', 'read'})
        elif (msg['id'] in received_message_ids):
            self.assertEqual(msg['flags'], [])
        else:
            self.assertEqual(msg['flags'], ['read'])
        self.assertNotIn(msg['id'], other_message_ids)
    result = self.change_star(message_ids, False)
    self.assert_json_success(result)
    self.login(self.mit_email('sipbtest'))
    result = self.change_star(message_ids)
    self.assert_json_error(result, 'Invalid    message(s)')
