'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.category = Category(name='test')
        self.category.set_default_user()
        self.category.save()
        self.equity = Equity(issue_price=10, sell_price=10, issuer=self.contact, owner=self.contact)
        self.equity.set_default_user()
        self.equity.save()
        self.asset = Asset(name='test', owner=self.contact)
        self.asset.set_default_user()
        self.asset.save()
        self.tax = Tax(name='test', rate=10)
        self.tax.set_default_user()
        self.tax.save()
        self.currency = Currency(code='GBP', name='Pounds', symbol='L', is_default=True)
        self.currency.set_default_user()
        self.currency.save()
        self.account = Account(name='test', owner=self.contact, balance_currency=self.currency)
        self.account.set_default_user()
        self.account.save()
        self.liability = Liability(name='test', source=self.contact, target=self.contact, account=self.account, value=10, value_currency=self.currency)
        self.liability.set_default_user()
        self.liability.save()
        self.transaction = Transaction(name='test', account=self.account, source=self.contact, target=self.contact, value=10, value_currency=self.currency)
        self.transaction.set_default_user()
        self.transaction.save()
        self.client = Client()
        self.prepared = True
