def test_transaction_creates_notification(self):
        user = User.objects.get(pk=1)
        newBankingPerson = BankingPerson.objects.get(user=user)
        newBankingPerson.owner = user
        newBankingPerson.save()

        acc1 = Account().create()
        acc1.accountName = "Savings Account"
        acc1.create()
        acc1.owner = user
        acc1.amount = 300
        acc1.save()

        acc2 = Account().create()
        acc2.accountName = "Savings Account"
        acc2.create()
        acc2.owner = user
        acc2.amount = 300
        acc2.save()

        acc1.transfer(name=acc2.accountName, iban=acc2.iban, sort=acc2.sortCode, amount=20, description="test")
        notification = Notification.objects.get(pk=2)

        self.assertEquals(notification.to, user)
        self.assertEquals(notification.level, 1)
        self.assertEquals(notification.title, 'Incoming transaction!')
        self.assertEquals(notification.read, False)
        self.assertEquals(notification.viewed, False)
def createSuperUser(request):

	nameList = ["Beth","Fox","Webster","Dallas","Kathleen","Steele"]

	# from http://stackoverflow.com/questions/2257441/random-string-generation-with-upper-case-letters-and-digits-in-python
	try:
		theSuperman = User.objects.get(username='******')
	except User.DoesNotExist: 
		my_admin = User.objects.create_superuser('root', '*****@*****.**', 'toor')
		my_admin.save()
		bankingRoot = BankingPerson(name = "BankingRoot", user=my_admin)
		bankingRoot.name = "Mr. Plamen Tatianski Kolev"
		bankingRoot.address = "Fenham Hall Drive, St. Marry College, NE6 5K1"
		bankingRoot.phone = "0886658547"
		bankingRoot.email = "*****@*****.**"
		bankingRoot.save()
		acc1 = Account().create()
		acc1.accountName = "Student Account"
		acc2 = Account().create()
		acc2.accountName = "Savings Account"
		acc1.owner = bankingRoot
		acc2.owner = bankingRoot
		acc1.save()
		acc2.save()

	accNames = ["Savings account", "Mortgage", "Daily Account"]

	for i in xrange(1,len(nameList)-1):
		randomName = nameList[i]
		newUser = User(username = randomName)
		newUser.set_password(randomName)
		newUser.save()

		newAccount = BankingPerson(name=randomName)
		newAccount.user = newUser
		newAccount.save()
		for i in range(0, len(accNames)-1):
			newAcc = Account()
			newAcc.accountName = accNames[i]
			newAcc.create()
			newAcc.owner = newAccount
			newAcc.save()

	return redirect('index')
    def setUp(self):
        my_admin = User.objects.create_superuser('root2', '*****@*****.**', 'toor2')
        my_admin.first_name = "Mr. Plamen Tatianski Kolev"
        my_admin.save()

        bankingRoot = BankingPerson.objects.get(user=my_admin, user__first_name = my_admin.first_name)
        bankingRoot.address = "Fenham Hall Drive, St. Marry College, NE6 5K1"
        bankingRoot.phone = "0886658547"
        bankingRoot.email = "*****@*****.**"
        bankingRoot.save()

        acc1 = Account().create()
        acc1.accountName = "Student Account"
        acc1.amount = 200
        acc2 = Account().create()
        acc2.accountName = "Savings Account"
        acc2.amount = 200
        acc1.owner = my_admin
        acc2.owner = my_admin
        acc1.save()
        acc2.save()

        randomName = "Matthew Perrie"
        newUser = User(username = randomName)
        newUser.first_name = randomName
        newUser.set_password(randomName)
        newUser.save()

        newBankingPerson = BankingPerson.objects.get(user=newUser)
        newBankingPerson.owner = newUser
        newBankingPerson.save()

        acc3 = Account().create()
        acc3.accountName = "Savings Account"
        acc3.create()
        acc3.owner = newUser
        acc3.amount = 300
        acc3.save()