'PUT API should allow creation of a document whose path would make it
a child of an existing parent.'

def test_put_new_child(self):

    data = dict(title='This    is    the    title    of    a    new    page', content='\n                                                                <p>This    is    a    new    page,    hooray!</p>\n                                                ', tags='hello,quux,xyzzy', review_tags='technical')
    url = ('%s/nonexistent/newchild' % self.url)
    resp = self._put(url, data, HTTP_AUTHORIZATION=self.basic_auth)
    eq_(404, resp.status_code)
    p_doc = document(slug=('%s/nonexistent' % self.doc.slug), locale=settings.WIKI_DEFAULT_LANGUAGE, parent_topic=self.doc)
    p_doc.save()
    p_rev = revision(document=p_doc, slug=('%s/nonexistent' % self.doc.slug), title='I    EXIST    NOW', save=True)
    p_rev.save()
    resp = self._put(url, data, HTTP_AUTHORIZATION=self.basic_auth)
    eq_(201, resp.status_code)
    new_slug = ('%s/nonexistent/newchild' % self.doc.slug)
    new_doc = Document.objects.get(locale=settings.WIKI_DEFAULT_LANGUAGE, slug=new_slug)
    eq_(p_doc.pk, new_doc.parent_topic.pk)
