def post_item(): if Items.objects.count() < max_items: root_count = Items.root_count() if root_count<10: text = get_text() item = Items.create(text,text) elif root_count<10: item = Items.objects.order_by('?')[0] else: item = Items.objects.filter(parent__gte=1)[0] text = get_text() item.append(text, text)
def testBasic(self): body, title = get_text(),get_text() item = Items.create(body, title) self.assertTrue(item.text , 'text value') self.assertEqual(item.parent, None, 'appending to root') body, title = get_text(),get_text() child = Items.create(body, title, item) self.assertEqual(child.parent, item, 'appending to item') item2 = Items.create(get_text(),get_text()) child.move(item2.id) self.assertEqual(child.parent, item2m, 'moving')