def test_admin_section_create_move(self):
        # Try creating a root-level node.
        self.login_and_load()
        admin_urls = self.get_admin_urls('root')
        response = self.client.post(admin_urls['create'], {
            'slug': 'bazz',
            'title': 'Bazz',
        })
        # On sucess should redirect.
        self.assertRedirects(response, admin_urls['index'])
        self.assertTrue('bazz' in \
            [node.slug for node in TestSection.get_root_nodes()]
        )
        # Try creating a node that is a child
        test_section = TestSection.objects.get(slug="2")
        admin_urls = self.get_admin_urls(test_section)
        response = self.client.get(admin_urls['create'])
        self.assertContains(response, test_section.title)
        # Create a new section, but use a bad position:
        response = self.client.post(admin_urls['create'], {
            'slug': 'foobar',
            'title': 'Foo Bar',
            'position': 'beside',
            'child': '4'
        })
        self.assertEqual(response.status_code, 400)
        try:
            section = TestSection.objects.get(slug="foobar")
            section.delete()
        except TestSection.DoesNotExist:
            pass
        # Create a new section properly via the form and verify it exists.
        child_section = TestSection.objects.get(title="2")
        response = self.client.post(admin_urls['create'], {
            'slug': 'foobar',
            'title': 'Foo Bar',
            'description': 'Foo Bar description',
            'position': 'after',
            'child': str(child_section.pk)
        })
        # On sucess should redirect.
        self.assertRedirects(response, admin_urls['index'])
        # Verify new section exists and is child of the "2" section...
        self.assertTrue(len(TestSection.objects.filter(title="Foo Bar")) == 1)
        foobar = TestSection.objects.get(slug="foobar")
        self.assertTrue(foobar.is_root())
        self.assertEqual(child_section.get_next_sibling(), foobar)
        # Now move the section...
        admin_urls = self.get_admin_urls(foobar)
        response = self.client.get(admin_urls['move'])
        self.assertEqual(response.context['obj'].pk, foobar.pk)
        # ... first with an incorrect reltionship field...
        response = self.client.post(admin_urls['move'], {
            'relationship': 'sibling',
            'to': TestSection.objects.get(slug="4").id
        })
        self.assertEqual(response.status_code, 400)
        # ... then a correct one.
        response = self.client.post(admin_urls['move'], {
            'relationship': 'child',
            'to': TestSection.objects.get(slug="4").id
        })
        # On sucess should redirect to index.
        self.assertRedirects(response, admin_urls['index'])
        # Verify section moved where it was supposed to.
        self.assertEqual(
            TestSection.objects.get(slug="foobar").get_parent(),
            TestSection.objects.get(slug="4")
        )
        # Try moving a section to itself.
        response = self.client.post(admin_urls['move'], {
            'relationship': 'child',
            'to': foobar.id
        })
        self.assertEqual(response.status_code, 400)
        # Move section to root of tree.
        response = self.client.post(admin_urls['move'], {
            'relationship': 'neighbor',
            'to': 'TOP'
        })
        self.assertEqual(
            TestSection.get_root_nodes()[0].slug,
            foobar.slug
        )
        # Move it one more time.
        response = self.client.post(admin_urls['move'], {
            'relationship': 'neighbor',
            'to': TestSection.objects.get(slug="231").id
        })
        self.assertRedirects(response, admin_urls['index'])
        # Verify section moved where it was supposed to.
        self.assertEqual(
            [u'231', u'foobar'],
            [n.slug for n in TestSection.objects.get(slug="23").get_children()]
        )
Via the admin interface, create a new section in the the tree under
dataset/ETHPy150Open mazelife/django-scaffold/scaffold/tests.py/SectionTest.test_admin_section_create_move