'Initial Setup'

def setUp(self):

    if (not self.prepared):
        Object.objects.all().delete()
        try:
            self.group = Group.objects.get(name='test')
        except Group.DoesNotExist:
            Group.objects.all().delete()
            self.group = Group(name='test')
            self.group.save()
        try:
            self.user = DjangoUser.objects.get(username=self.username)
            self.user.set_password(self.password)
            try:
                self.profile = self.user.profile
            except Exception:
                User.objects.all().delete()
                self.user = DjangoUser(username=self.username, password='')
                self.user.set_password(self.password)
                self.user.save()
        except DjangoUser.DoesNotExist:
            User.objects.all().delete()
            self.user = DjangoUser(username=self.username, password='')
            self.user.set_password(self.password)
            self.user.save()
        try:
            perspective = Perspective.objects.get(name='default')
        except Perspective.DoesNotExist:
            Perspective.objects.all().delete()
            perspective = Perspective(name='default')
            perspective.set_default_user()
            perspective.save()
        ModuleSetting.set('default_perspective', perspective.id)
        self.folder = KnowledgeFolder(name='test', treepath='test')
        self.folder.set_default_user()
        self.folder.save()
        self.category = KnowledgeCategory(name='test', treepath='test')
        self.category.set_default_user()
        self.category.save()
        self.item = KnowledgeItem(name='test', folder=self.folder, category=self.category, treepath='test')
        self.item.set_default_user()
        self.item.save()
        self.parent = KnowledgeFolder(name='test', treepath='test')
        self.parent.set_default_user()
        self.parent.save()
        self.client = Client()
        self.prepared = True
