def testApiAuthenticate(self): account = Account(pk=2, username="******", password_hash="password", balance=50000) api_key = account.generate_api_key() account.save() test = account.api_authenticate(api_key) self.assertAlmostEqual(account, test)
def testAPIKey(self): account = Account(pk=2, username="******", password_hash="password", balance=50000) api_key = account.generate_api_key() account.save() test = Account.one_from_where_clause("WHERE api_key=?", (account.api_key, )) self.assertEqual(test, api_key)
def testLogin(self): account3 = Account(username="******", pin="1234", balance=20.00) api = account3.generate_api_key() account3.save() get_api = account3.get_api() account4 = Account.api_authenticate(get_api) self.assertEqual(account4.username, "mike_bloom") self.assertEqual(account4.pin, "1234") self.assertEqual(account4.balance, 20.00)
def testNewAccount(self): account1 = Account() self.assertEqual(account1.tablename, "accounts") self.assertIsInstance(account1, Account) self.assertEqual(account1.fields, ["username", "pin", "balance", "api_key"]) account2 = Account(username="******", pin="4456", balance="1200.00") api = account2.generate_api_key() account2.save() get_api = account2.get_api() self.assertEqual(api, get_api)