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 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()