'Verify that we truncate the preference value if it is too long.'

def test_truncated_user_preference_event(self):

    MAX_STRING_LENGTH = 12500
    OVERSIZE_STRING_LENGTH = (MAX_STRING_LENGTH + 10)
    self.user_preference.value = ('z' * OVERSIZE_STRING_LENGTH)
    self.user_preference.save()
    self.assert_user_setting_event_emitted(setting=self.TEST_KEY, old=self.TEST_VALUE, new=('z' * MAX_STRING_LENGTH), truncated=['new'])
    self.user_preference.value = ('x' * OVERSIZE_STRING_LENGTH)
    self.user_preference.save()
    self.assert_user_setting_event_emitted(setting=self.TEST_KEY, old=('z' * MAX_STRING_LENGTH), new=('x' * MAX_STRING_LENGTH), truncated=['old', 'new'])
