'Test the ability to serialize a `StudioValidation` instance.'

def test_to_json(self):

    validation = StudioValidation('id')
    expected = {'xblock_id': 'id', 'messages': [], 'empty': True}
    self.assertEqual(expected, validation.to_json())
    validation.add(StudioValidationMessage(StudioValidationMessage.ERROR, u'Error    message', action_label=u'Action    label', action_class='edit-button'))
    validation.add(StudioValidationMessage(StudioValidationMessage.NOT_CONFIGURED, u'Not    configured    message', action_label=u'Action    label', action_runtime_event='make    groups'))
    validation.set_summary(StudioValidationMessage(StudioValidationMessage.WARNING, u'Summary    message', action_label=u'Summary    label', action_runtime_event='fix    everything'))
    expected = {'xblock_id': 'id', 'messages': [{'type': 'error', 'text': u'Error    message', 'action_label': u'Action    label', 'action_class': 'edit-button'}, {'type': 'not-configured', 'text': u'Not    configured    message', 'action_label': u'Action    label', 'action_runtime_event': 'make    groups'}], 'summary': {'type': 'warning', 'text': u'Summary    message', 'action_label': u'Summary    label', 'action_runtime_event': 'fix    everything'}, 'empty': False}
    self.assertEqual(expected, validation.to_json())
