-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtestingdb.py
468 lines (347 loc) · 13.2 KB
/
testingdb.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
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
import database
# statement testing for database.py
def main():
print('Inserting student!')
# raise exception
data = ''
database.insert_student(data)
# insert new student info
student_data = {}
student_data['student_email'] = '[email protected]'
student_data['student_name'] = 'Liz1-testing'
database.insert_student(student_data)
# exception email already in database
student_data = {}
student_data['student_email'] = '[email protected]'
student_data['student_name'] = 'Liz2-testing'
database.insert_student(student_data)
# -------------------------------------------------------------------#
print('Inserting admin1!')
# raise exception
data = ''
database.insert_admin(data)
# insert new admin info
admin_data = {}
admin_data['admin_email'] = '[email protected]'
admin_data['admin_name'] = 'Liz1-Admin-testing'
database.insert_admin(admin_data)
# exception email already in database
admin_data = {}
admin_data['admin_email'] = '[email protected]'
admin_data['admin_name'] = 'Liz2-Admin-testing'
database.insert_admin(admin_data)
# -------------------------------------------------------------------#
print('Deleting user!') # can delete student or admin
# user id should not be none
user_id = None
database.delete_user(user_id)
# user id should not be empty
user_id = ""
database.delete_user(user_id)
user_id = 6
database.delete_user(user_id) # deleting Catherine
# -------------------------------------------------------------------#
print("Insert program1!")
# missing data program_name
program1_data = {
"program_description": "Description",
"program_availability": "all"
}
database.insert_program(program1_data)
# create new program: Testing 101
program1_data = {
"program_name": "Tree Ambassador 101",
"program_description": "Description",
"program_availability": "all"
}
database.insert_program(program1_data)
# -------------------------------------------------------------------#
print("Insert module")
module_name = 'Liz statement testing'
module_content_type = "assessment"
module_content_link = 'statement testing link'
# missing module name
module_data = {
'program_id': 'p26', # insert module into created program
'content_type': module_content_type,
'content_link': module_content_link,
}
database.insert_module(module_data)
module_name = 'Liz statement testing'
module_content_type = "assessment"
module_content_link = 'statement testing link'
module_data = {
'program_id': 'p26', # insert module into created program
'module_name': module_name,
'content_type': module_content_type,
'content_link': module_content_link,
}
database.insert_module(module_data)
# -------------------------------------------------------------------#
print('Delete module')
# invalid module_id
id = None
database.delete_module(id)
#invalid module id
id = ''
database.delete_module(id)
# should delete module successfully
id = 'm33'
database.delete_module(id)
# -------------------------------------------------------------------#
print('Delete program1') # deletes program and associated module
# invalid program_id
id = None
database.delete_program(id)
id = ''
database.delete_program(id)
# should delete program successfully
id = 'p18'
database.delete_program(id)
# -------------------------------------------------------------------#
print('Updating program name')
# missing program id error
program_id = ''
new_program_name = 'hey'
database.update_program_name(program_id, new_program_name)
# missing program name error
program_id = 'p24'
new_program_name = None
database.update_program_name(program_id, new_program_name)
# should work
program_id = 'p24'
new_program_name = 'Liz doing statement testing'
database.update_program_name(program_id, new_program_name)
# -------------------------------------------------------------------#
print('Updating program description')
# missing program id error
program_id = ''
new_program_desc = 'hello!'
database.update_program_description(program_id, new_program_desc)
# missing program desc error
program_id = 'p24'
new_program_desc = None
database.update_program_description(program_id, new_program_desc)
# should work
program_id = 'p24'
new_program_desc = 'Liz doing statement testing'
database.update_program_description(program_id, new_program_desc)
# -------------------------------------------------------------------#
print('Updating program availability')
# missing program id error
program_id = ''
new_program_avail = 'none'
database.update_program_availability(program_id, new_program_avail)
# missing program avail error
program_id = 'p24'
new_program_avail = None
database.update_program_availability(program_id, new_program_avail)
# should work
program_id = 'p24'
new_program_avail = 'Liz doing statement testing'
database.update_program_availability(program_id, new_program_name)
# -------------------------------------------------------------------#
print('Updating module name')
# missing program id error
program_id = ''
module_id = 'm26'
new_module_name = 'statement testing'
database.update_module_name(program_id, module_id, new_module_name)
# missing module id error
program_id = 'p17'
module_id = None
new_module_name = 'statement testing'
database.update_module_name(program_id, module_id, new_module_name)
# should work
program_id = 'p17'
module_id = 'm26'
new_module_name = 'statement testing'
database.update_module_name(program_id, module_id, new_module_name)
# missing module name
program_id = 'p17'
module_id = 'm26'
new_module_name = ''
database.update_module_name(program_id, module_id, new_module_name)
# repeated name conflict
program_id = 'p17'
module_id = 'm26'
new_module_name = 'statement testing2'
database.update_module_name(program_id, module_id, new_module_name)
# -------------------------------------------------------------------#
print('Update module content type')
# invalid module id
module_id = None
new_content_type = "non-assessment"
database.update_module_content_type(module_id, new_content_type)
# missing content type
module_id = 'm26'
new_content_type = ''
database.update_module_content_type(module_id, new_content_type)
# should work
module_id = 'm26'
new_content_type = 'assessment'
database.update_module_content_type(module_id, new_content_type)
# -------------------------------------------------------------------#
print('Update module content link')
# invalid module id
module_id = None
new_content_link = 'statement-testing.com'
database.update_module_content_link(module_id, new_content_link)
# misisng content link
module_id = 'm26'
new_content_link = ''
database.update_module_content_link(module_id, new_content_link)
# should work
module_id = 'm26'
new_content_link = 'Liz-statement.com'
database.update_module_content_link(module_id, new_content_link)
# -------------------------------------------------------------------#
#! please do not use, should not be used on its own
## should only be used by edit_module_seq in oea
# print('Update module index')
# # invalid module_id
# module_id =
# new_module_index =
# database.update_module_index(module_id, new_module_index)
# # missing module index
# module_id =
# new_module_index =
# database.update_module_index(module_id, new_module_index)
# # should work
# module_id =
# new_module_index =
# database.update_module_index(module_id, new_module_index)
# -------------------------------------------------------------------#
print('update_program_status')
# invalid student id
student_id = None
program_id = 'p17'
new_program_status = 'none'
database.update_program_status(student_id, program_id, new_program_status)
# invalid program_id
student_id = 1
program_id = None
new_program_status = 'none'
database.update_program_status(student_id, program_id, new_program_status)
# missing new program status
student_id = 1
program_id = 'p17'
new_program_status = ''
database.update_program_status(student_id, program_id, new_program_status)
# should work
student_id = 1
program_id = 'p17'
new_program_status = 'all'
database.update_program_status(student_id, program_id, new_program_status)
# -------------------------------------------------------------------#
print('Update assessment status')
# invalid student id
student_id = None
module_id = 'm26'
new_assessment_status = 0
database.update_assessment_status(student_id, module_id, new_assessment_status)
# invalid module id
student_id = 1
module_id = ''
new_assessment_status = 0
database.update_assessment_status(student_id, module_id, new_assessment_status)
# missing new assessment status
student_id = 1
module_id = 'm26'
new_assessment_status = ''
database.update_assessment_status(student_id, module_id, new_assessment_status)
# should work
student_id = 1
module_id = 'm26'
new_assessment_status = 1
database.update_assessment_status(student_id, module_id, new_assessment_status)
# -------------------------------------------------------------------#
print('Is admin authorized')
username = None
database.is_admin_authorized(username)
username = ""
database.is_admin_authorized(username)
username = 'liz'
database.is_admin_authorized(username)
# -------------------------------------------------------------------#
print('Is student authorized')
username = ""
database.is_admin_authorized(username)
username = None
database.is_admin_authorized(username)
username = 'test liz'
database.is_admin_authorized(username)
# -------------------------------------------------------------------#
print('Get student info')
email = ""
database.get_student_info(email)
email = "[email protected]"
database.get_student_info(email)
# -------------------------------------------------------------------#
print('get all admins')
print('all admin = ', database.get_all_admins())
# -------------------------------------------------------------------#
print('get all students')
print('all students = ', database.get_all_students())
# -------------------------------------------------------------------#
print('get all programs')
print('all programs = ', database.get_all_programs())
# -------------------------------------------------------------------#
print('get program info')
program_id = ""
database.get_program_info(program_id)
program_id = 'p1'
database.get_program_info(program_id)
# -------------------------------------------------------------------#
print('get module info')
module_id = ""
database.get_module_info(module_id)
module_id = "m1"
database.get_module_info(module_id)
# -------------------------------------------------------------------#
print('get student program status')
student_id = ""
program_id = 'p14'
database.get_student_program_status(student_id, program_id)
student_id = 1
program_id = ''
database.get_student_program_status(student_id, program_id)
# program user status not in database
student_id = 1
program_id = 'p14'
database.get_student_program_status(student_id, program_id)
# program user status not in database
student_id = 10
program_id = 'p14' # tree embasssador 1 program with assessment
database.get_student_program_status(student_id, program_id)
# -------------------------------------------------------------------#
print('get student enrolled program info')
student_id = ""
database.get_student_enrolled_program_info(student_id)
student_id = 1
database.get_student_enrolled_program_info(student_id)
# -------------------------------------------------------------------#
print('get locked index')
user_id = ""
program_id = 'p14'
database.get_locked_index(user_id, program_id)
user_id = 1
program_id = 'p14'
database.get_locked_index(user_id, program_id)
user_id = 1
program_id = 'p14'
database.get_locked_index(user_id, program_id)
# -------------------------------------------------------------------#
print('get student program progress')
student_id = None
program_id = 'p14'
database.get_student_program_progress(student_id, program_id)
student_id = 1
program_id = ""
database.get_student_program_progress(student_id, program_id)
student_id = 1
program_id = 'p14'
database.get_student_program_progress(student_id, program_id)
# -------------------------------------------------------------------#
if __name__ == '__main__':
main()