'When a user edits a child document in a watched document tree, we
should send an email to users who are watching the tree.'

@pytest.mark.edit_emails
@mock.patch.object(Site.objects, 'get_current')
def test_email_for_child_edit_in_watched_tree(self, get_current):

    get_current.return_value.domain = 'dev.mo.org'
    (root_doc, child_doc, grandchild_doc) = create_document_tree()
    testuser2 = get_user(username='testuser2')
    EditDocumentInTreeEvent.notify(testuser2, root_doc)
    self.client.login(username='testuser', password='testpass')
    data = new_document_data()
    data.update({'form-type': 'rev', 'slug': child_doc.slug, 'content': 'This    edit    should    send    an    email', 'comment': 'This    edit    should    send    an    email'})
    self.client.post(reverse('wiki.edit', args=[child_doc.slug]), data)
    eq_(1, len(mail.outbox))
    message = mail.outbox[0]
    assert (testuser2.email in message.to)
    assert ('sub-articles' in message.body)
