forked from hbeltrane/PyBank
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_agent.py
101 lines (83 loc) · 2.32 KB
/
test_agent.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
""" Term Project - PyBank
CSD 4523 - Python II
CSAM Group 02 2022S
"""
from datetime import datetime
from db.movement import get_transactions
from db.product import get_product_type
from model import util
from model.product import ProductList
from model.account import Account
from model.agent import Agent
from model.customer import Customer
from model.result import Return
config = {
'user': 'pybank',
'password': 'Lambton2022S',
'host': 'localhost',
'port': '3307',
'database': 'pybank',
'pool_name': 'pybank_conn_pool',
'pool_size': 1
}
# Test 2: Login Agent
def test_agent_login():
print("* Tests for Agent Model *")
active_agent = Agent()
result = Return()
active_agent.login("fboxe0", "ua8w6WmM", result)
print(f"Agent {active_agent.first_name} logged in")
# Test 3: Search Customers
def test_search_customers():
result = Return()
customers = util.search_customer("Nan", result)
print(customers)
print("Len: ", len(customers))
print("Code: ", result.code)
# Test 4: Search Accounts """
def test_search_accounts():
result = Return()
accounts = util.search_account("15", result)
print("Len: ", len(accounts))
print(accounts)
print("Fee: ", accounts[0].acc_type.minimum_balance)
# Test 5: Create Customer
def test_create_customer():
result = Return()
new_customer = Customer(
customer_id=0,
pin="5678",
first_name="Hugo",
last_name="Beltran",
address="Bentley",
phone_number="1234567890",
email="hugo@email.com",
creation_date=datetime.now(),
agent_id='jmisk5'
)
util.create_customer(new_customer, result)
# Test 6: Create Account """
def test_open_account():
result = Return()
new_account = Account(
acc_number="",
acc_type_id=1,
balance=0,
transfer_amount=0,
transfer_quantity=0,
customer_id=12,
open_date=datetime.now(),
agent_id="jmisk5"
)
util.open_account(new_account, result)
# Test 7: Search Products
def test_search_products():
products = get_product_type()
print(products)
# Test 8: Search Transactions
def test_get_transactions():
transactions = get_transactions()
print(transactions)
# Test 9: Products List
def test_product_list():
print(ProductList.get_list())