def testAccount(self): account = Account(username="******", password="******", balance=10000, contact="9292176681") account.save() self.assertEqual(account.username, "Abdoul") self.assertEqual(account.password, "digitalcrack") self.assertEqual(account.balance, 10000) self.assertEqual(account.contact, "9292176681") account1 = Account(pk=1, username="******", password="******", balance=10.5, contact="928900998") account1.save() self.assertEqual(account1.username, "Alida") self.assertEqual(account1.password, "123rewq") self.assertEqual(account1.balance, 10.5) self.assertEqual(account1.contact, "928900998") account3 = Account(pk=3) account4 = Account(pk=4) account5 = Account(pk=5) account6 = Account(pk=6) account7 = Account(pk=7) account3.delete() account4.delete() account5.delete() account6.delete() account7.delete() self.assertEqual(account3.username, None) self.assertEqual(account3.password, None) acc = Account().one_from_pk(pk=2) self.assertEqual(acc.username, "Chris") self.assertEqual(acc.password, "4567yy") self.assertEqual(acc.balance, 200.0)
def testDelete(self): caroline = Account(username="******", password_hash="password", balance=10000, first_name="Caroline", last_name="Grabowski", email="*****@*****.**") caroline.save() alex = Account(username="******", password_hash="password", balance=20000, first_name="Alex", last_name="C", email="*****@*****.**") alex.save() caroline.delete() with sqlite3.connect(DBPATH) as connection: cursor = connection.cursor() SQL = "SELECT * FROM ACCOUNTS WHERE balance=10000;" cursor.execute(SQL) rows = cursor.fetchall() self.assertEqual(len(rows), 0, "delete should delete 1 row in the table")
def testDelete(self): account = Account(pk=2) account.delete() self.assertEqual(account.username, None)