'Initial Setup'

def setUp(self):

    if (not self.prepared):
        Object.objects.all().delete()
        User.objects.all().delete()
        (self.group, created) = Group.objects.get_or_create(name='test')
        (duser, created) = DjangoUser.objects.get_or_create(username=self.username)
        duser.set_password(self.password)
        duser.save()
        (self.user, created) = User.objects.get_or_create(user=duser)
        self.user.save()
        (perspective, created) = Perspective.objects.get_or_create(name='default')
        perspective.set_default_user()
        perspective.save()
        ModuleSetting.set('default_perspective', perspective.id)
        self.contact_type = ContactType(name='test')
        self.contact_type.set_default_user()
        self.contact_type.save()
        self.contact = Contact(name='test', contact_type=self.contact_type)
        self.contact.set_default_user()
        self.contact.save()
        self.status = TicketStatus(name='TestStatus')
        self.status.set_default_user()
        self.status.save()
        self.queue = TicketQueue(name='TestQueue', default_ticket_status=self.status)
        self.queue.set_default_user()
        self.queue.save()
        self.ticket = Ticket(name='TestTicket', status=self.status, queue=self.queue)
        self.ticket.set_default_user()
        self.ticket.save()
        self.agent = ServiceAgent(related_user=self.user, available_from=datetime.time(9), available_to=datetime.time(17))
        self.agent.set_default_user()
        self.agent.save()
        self.service = Service(name='test')
        self.service.set_default_user()
        self.service.save()
        self.sla = ServiceLevelAgreement(name='test', service=self.service, client=self.contact, provider=self.contact)
        self.sla.set_default_user()
        self.sla.save()
        self.client = Client()
        self.prepared = True
