'bug 875349'

def test_json_data(self):

    rev = revision(is_approved=True, save=True, content='Sample    document')
    doc = rev.document
    expected_tags = sorted(['foo', 'bar', 'baz'])
    expected_review_tags = sorted(['tech', 'editorial'])
    doc.tags.set(*expected_tags)
    doc.current_revision.review_tags.set(*expected_review_tags)
    de_doc = document(parent=doc, locale='de', save=True)
    revision(document=de_doc, save=True)
    expected_l10n_tags = ['inprogress']
    de_doc.current_revision.localization_tags.set(*expected_l10n_tags)
    de_doc.tags.set(*expected_tags)
    de_doc.current_revision.review_tags.set(*expected_review_tags)
    assert (doc.json is None)
    data = doc.get_json_data()
    assert (doc.json == json.dumps(data))
    saved_doc = Document.objects.get(pk=doc.pk)
    assert (saved_doc.json == json.dumps(data))
    assert (data['title'] == doc.title)
    assert (data['label'] == doc.title)
    assert (data['url'] == doc.get_absolute_url())
    assert (data['id'] == doc.id)
    assert (data['uuid'] == str(doc.uuid))
    assert (data['slug'] == doc.slug)
    result_tags = sorted([str(x) for x in data['tags']])
    assert (result_tags == expected_tags)
    result_review_tags = sorted([str(x) for x in data['review_tags']])
    assert (result_review_tags == expected_review_tags)
    assert (data['locale'] == doc.locale)
    assert (data['summary'] == doc.current_revision.summary)
    assert (data['modified'] == doc.modified.isoformat())
    assert (data['last_edit'] == doc.current_revision.created.isoformat())
    assert ('translations' in data)
    assert (len(data['translations']) == 1)
    de_data = data['translations'][0]
    assert (de_data['locale'] == de_doc.locale)
    result_l10n_tags = sorted([str(x) for x in de_data['localization_tags']])
    assert (result_l10n_tags == expected_l10n_tags)
    result_tags = sorted([str(x) for x in de_data['tags']])
    assert (result_tags == expected_tags)
    result_review_tags = sorted([str(x) for x in de_data['review_tags']])
    assert (result_review_tags == expected_review_tags)
    assert (de_data['summary'] == de_doc.current_revision.summary)
    assert (de_data['title'] == de_doc.title)
    assert (de_data['uuid'] == str(de_doc.uuid))
