'If a page was changed while someone was editing, but the changes
didn\'t affect the specific section being edited, then ignore the midair
warning'

@pytest.mark.midair
def test_midair_section_merge_ajax(self):

    self.client.login(username='admin', password='testpass')
    rev = revision(is_approved=True, save=True, content='\n                                                <h1    id="s1">s1</h1>\n                                                <p>test</p>\n                                                <p>test</p>\n\n                                                <h1    id="s2">s2</h1>\n                                                <p>test</p>\n                                                <p>test</p>\n\n                                                <h1    id="s3">s3</h1>\n                                                <p>test</p>\n                                                <p>test</p>\n                                ')
    replace_1 = '\n                                                <h1    id="replace1">replace1</h1>\n                                                <p>replace</p>\n                                '
    replace_2 = '\n                                                <h1    id="replace2">replace2</h1>\n                                                <p>replace</p>\n                                '
    expected = '\n                                                <h1    id="replace1">replace1</h1>\n                                                <p>replace</p>\n\n                                                <h1    id="replace2">replace2</h1>\n                                                <p>replace</p>\n\n                                                <h1    id="s3">s3</h1>\n                                                <p>test</p>\n                                                <p>test</p>\n                                '
    data = {'form-type': 'rev', 'content': rev.content, 'slug': ''}
    resp = self.client.get(('%s?section=s1' % reverse('wiki.edit', args=[rev.document.slug])), HTTP_X_REQUESTED_WITH='XMLHttpRequest')
    page = pq(resp.content)
    rev_id1 = page.find('input[name="current_rev"]').attr('value')
    resp = self.client.get(('%s?section=s2' % reverse('wiki.edit', args=[rev.document.slug])), HTTP_X_REQUESTED_WITH='XMLHttpRequest')
    page = pq(resp.content)
    rev_id2 = page.find('input[name="current_rev"]').attr('value')
    data.update({'form-type': 'rev', 'content': replace_2, 'current_rev': rev_id2, 'slug': rev.document.slug})
    resp = self.client.post(('%s?section=s2&raw=true' % reverse('wiki.edit', args=[rev.document.slug])), data, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
    eq_(json.loads(resp.content)['error'], False)
    data.update({'form-type': 'rev', 'content': replace_1, 'current_rev': rev_id1})
    resp = self.client.post(('%s?section=s1&raw=true' % reverse('wiki.edit', args=[rev.document.slug])), data, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
    eq_(205, resp.status_code)
    response = self.client.get(('%s?raw=true' % reverse('wiki.document', args=[rev.document.slug])), HTTP_X_REQUESTED_WITH='XMLHttpRequest')
    eq_(normalize_html(expected), normalize_html(response.content))
    eq_(unicode(Document.objects.get(slug=rev.document.slug, locale=rev.document.locale).current_revision.id), unicode(response['x-kuma-revision']))
