-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtestingfun_07_01.py
More file actions
128 lines (96 loc) · 3.81 KB
/
testingfun_07_01.py
File metadata and controls
128 lines (96 loc) · 3.81 KB
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
"""testingfun.py
Developer: Noelle Todd
Last Updated: July 1, 2014
This program will test the new_household and update_all functions,
and the select_client function.
"""
from cdbifunc import *
from cdbfunctions import *
from datetime import date
def creation_example():
#create new volunteer
new_volunteer("Henry", "York")
#create visit object
visitInfo = visitData(1, notes="No id")
#create newClient objects
ncd1 = newClientData("Harry", "Potter", date(year=1994, month=7, day=9))
ncd2 = newClientData("Ron", "Weasley", date(year=1993, month=12, day=12))
newClientInfo_list = [ncd1, ncd2]
#create household object
houseInfo = houseData("Hogwartz", city="London")
#send all objects to new_household function
new_household(houseInfo, visitInfo, newClientInfo_list)
print("Here is the list of people in the database right now: \n", list_people())
#end database session (cleanly close database)
quit_session()
def update_example():
#update household and insert client
print("\n")
visitInfo = visitData(1, visitDate=date(year=2014, month=3, day=11), notes="Brought a dog named Snuffles")
ocd1 = oldClientData(1, "Harry", "Potter", date(year=1994, month=7, day=9))
ocd2 = oldClientData(2, "Ron", "Weasley", date(year=1993, month=12, day=12))
oldClientInfo_list = [ocd1, ocd2]
ncd = newClientData("Hermione", "Granger", date(year=1994, month=9, day=7))
newClientInfo_list = [ncd]
houseInfo = houseData("Hogwartz", city="London")
update_all(1, houseInfo, visitInfo, oldClientInfo_list, newClientInfo_list)
print("After update & add: \n")
print(list_people())
quit_session()
def select_example():
info = select_client(1)
#Return should look something like this:
#info = {"visitor":visitor, "household":household, "member_list":members,
# "visit_list":visits, "agegroup_dict":agegroups}
#
#below is how to find all of the information you will need to pre-populate
#fields (entry boxes), and find the ids of every member.
#
#Example of getting data from "visitor" object
visitor = info["visitor"]
print("Visitor's id:", visitor.id)
print("Visitor's first name: ", visitor.firstname)
print("Visitor's last name: ", visitor.lastname)
print("Visitor's dob: ", visitor.dob)
print("Visitor's dob:", visitor.dob.month, visitor.dob.day, visitor.dob.year)
print("Visitor's phone:", visitor.phone)
print("Date visitor joined food pantry:", visitor.dateJoined)
print("\n")
#Example of getting data from "household" object
house = info["household"]
print("street, apt:", house.street, house.apt)
print("city, state, zip:", house.city, house.state, house.zip)
print("Date verified:", house.dateVerified)
if house.dateVerified != None:
print("Date verified:", house.dateVerified.month, house.dateVerified.day, house.dateVerified.year)
print("\n")
#Getting data from "member_list" object
for member in info["member_list"]:
print("Member's id:", member.id)
print("First name is:", member.firstname)
print("Last name is:", member.lastname)
print("dob is:", member.dob)
print("dob is:", member.dob.month, member.dob.day, member.dob.year)
print("\n")
#Getting data from "visit_list" object
for visit in info["visit_list"]:
print("Date of visit: ", visit.date)
print("Name of visitor: ", visit.visitor)
print("Name of volunteer: ", visit.volunteer)
print("Visit notes: ", visit.notes)
print("\n")
#Getting data from "agegroup_dict" object
print("Number of seniors are: ", info["agegroup_dict"]["seniors"])
print("Number of adults are: ", info["agegroup_dict"]["adults"])
print("Number of children are:", info["agegroup_dict"]["children"])
print("Number of infants are: ", info["agegroup_dict"]["infants"])
#end database session (cleanly close database)
quit_session()
def main():
creation_example()
print('\n')
update_example()
print('\n')
select_example()
if __name__ == "__main__":
main()