Ejemplo n.º 1
0
def admin_leaderboard():
    print('Terminal Trader Leaderboard\n')
    accounts = Account.all()
    account_username_pk_list = []
    for account in accounts:
        account_username_pk_list.append(
            [account, account.pk, account.username])
    for item in account_username_pk_list:
        Account.leaderboard_stats_by_acct(item[0], item[1], item[2])
Ejemplo n.º 2
0
 def test_update(self):  #Tests Save - update function
     result = Account.from_pk(jimid)
     result.balance = 100
     result.save()
     result = Account.all()  #using the all fucntion to count rows in DB
     self.assertEqual(
         result[0].balance, 100,
         "all func populates attributes, checking updated first for row[0] / pk1"
     )
Ejemplo n.º 3
0
 def test_all(self):
     result = Account.all()
     self.assertEqual(
         len(result), 1,
         "all func returns list with correct number of elements")
     self.assertIsInstance(result[0], Account,
                           "all func returns account object")
     self.assertEqual(result[0].first, "Jim",
                      "all func populates attributes")
Ejemplo n.º 4
0
 def test_insert(self):  #Tests Save - insert function
     tester = Account(first='Homer',
                      last='Simpson',
                      username='******',
                      password_hash="password",
                      balance=0,
                      email='*****@*****.**')
     tester.save()
     result = Account.all()  #using the all fucntion to count rows in DB
     self.assertEqual(
         len(result), 2,
         "The first row was the set up the new row was inserted")
     self.assertEqual(
         result[0].first, "Jim",
         "all func populates attributes, checking first for row[0] / pk1")
     self.assertEqual(
         result[1].email, "*****@*****.**",
         "all func populates attributes, checking email for row[1] / pk2")