'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.field = ItemField(name='test', label='test', field_type='text')
        self.field.set_default_user()
        self.field.save()
        self.type = ItemType(name='test')
        self.type.set_default_user()
        self.type.save()
        self.type.fields.add(self.field)
        self.status = ItemStatus(name='test')
        self.status.set_default_user()
        self.status.save()
        self.item = Item(name='test', item_type=self.type, status=self.status)
        self.item.set_default_user()
        self.item.save()
        self.value = ItemValue(field=self.field, item=self.item)
        self.value.save()
        self.servicing = ItemServicing(name='test')
        self.servicing.set_default_user()
        self.servicing.save()
        self.client = Client()
        self.prepared = True
