def test_query_dropped(): # reset the DB to a known state refresh_db ('test.db') # open the DB db = Database() db.open_db('test.db') # One student exists in DB after refresh, add more stud1 = Student (oyd_id=15506, first_name='Jon', last_name='Criddle', age=63, birth_date= '6/2/1954', school=1, start_date='5/30/2005', rank='3D', position='I', class_group='Instructor') assert stud1.put (db) == (0, 'New Student Added to Database') stud2 = Student (oyd_id=15523, first_name='Jane', last_name='Judy', age=36, birth_date='7/4/1981', school=1, start_date='1/1/2010', rank='2D', status='dropped', class_group='Adult') assert stud2.put (db) == (0, 'New Student Added to Database') stud3 = Student (oyd_id=15507, first_name='Mark', last_name='Martin', age=41, birth_date='7/5/1976', school=1, start_date='1/1/1997', rank='3D', position='AHI', class_group='Instructor') assert stud3.put (db) == (0, 'New Student Added to Database') st = Students_Table() st.school = 1 assert st.query_dropped (db=db) == 0 assert len(st.students_dropped) == 1
def test_drop_event_put(): # reset the DB to a known state refresh_db('test.db') # open the DB db = Database() db.open_db('test.db') de1 = Drop_Event(student_sql_id=333, oyd_id=12333, drop_date='9/1/2017', reason='moved to Albequerque, NM') assert de1.put(db) == 0 de2 = Drop_Event(student_sql_id=4444, oyd_id=12344, drop_date='9/1/2017', reason='no showers') assert de2.put(db) == 0 de3 = Drop_Event(student_sql_id=55555, oyd_id=12355, drop_date='9/1/2017', reason='abducted by aliens') assert de3.put(db) == 0 db.close_db()
def test_update(): # reset the DB to a known state refresh_db('test.db') # open the DB db = Database() db.open_db('test.db') # Create a School Object school = School(school_name='South Bellevue', main_ins_id=15500, school_region=1, street="12345 156th Ave SE", city="Bellevue", state="WA", postal_code="98009", email="*****@*****.**", school_phone="(425) 555-1212", status=0, standing=0) school.put(db) # Check if the School was retrieved from DB assert school.get(db) == 0 # Time Travel - Test setting multiple attrs and doing a commit school.attrs['school_name'] = "East Cambridge" school.attrs['main_ins_id'] = '16699' assert school.update(db) == 0 db.close_db()
def test_count(): # reset the DB to a known state refresh_db ('test.db') # open the DB db = Database() db.open_db('test.db') region1 = Region(region_name='Seattle', region_abbrev="SEA", main_reg_id = 15500, reg_team_ids = "15500, 15513, 15505", nat_area = 1, street="7858 Leary Way", city = "Redmond", state = "WA", postal_code = "98052", email="*****@*****.**", phone = "(206) 555-1212", status = 0, standing = 0) assert region1.put (db) == (0, 'Region Successfully Added!') region2 = Region(region_name='Boston', region_abbrev="BOS", main_reg_id = 16600, reg_team_ids = "16600, 16613, 16605", nat_area = 2, street="123 Main St.", city = "Boston", state = "MA", postal_code = "02134", email="*****@*****.**", phone = "(555) 555-1212", status = 0, standing = 0) assert region2.put (db) == (0, 'Region Successfully Added!') rt = Regions_Table() assert rt.count (db) == 3 db.close_db()
def test_count(): # reset the DB to a known state refresh_db ('test.db') # open the DB db = Database() db.open_db('test.db') # One student exists in DB after refresh, add more stud1 = Student (oyd_id=15506, first_name='Jon', last_name='Criddle', age=63, birth_date= '6/2/1954', school=2, start_date='5/30/2005', rank='3D', position='I') stud1.put (db) == (0, 'New Student Added to Database') stud2 = Student (oyd_id=15523, first_name='Jane', last_name='Judy', age=36, birth_date='7/4/1981', school=2, start_date='1/1/2010', rank='2D', status='dropped') stud2.put (db) == (0, 'New Student Added to Database') stud3 = Student (oyd_id=15507, first_name='Mark', last_name='Martin', age=41, birth_date='7/5/1976', school=1, start_date='1/1/1997', rank='3D', position='AHI') stud3.put (db) == (0, 'New Student Added to Database') st = Students_Table() assert st.count (db) == 4 assert st.count (db, status='active') == 3 assert st.count (db, status='dropped') == 1 db.close_db()
def test_testing_event_put(): # reset the DB to a known state refresh_db('test.db') # open the DB db = Database() db.open_db('test.db') te1 = Testing_Event(student_sql_id=333, oyd_id=12333, test_date='9/1/2017', rank_tested='1S', pass_fail='pass') assert te1.put(db) == 0 te2 = Testing_Event(student_sql_id=4444, oyd_id=12344, test_date='9/1/2017', rank_tested='2S', pass_fail='fail') assert te2.put(db) == 0 te3 = Testing_Event(student_sql_id=55555, oyd_id=12355, test_date='9/1/2017', rank_tested='1D', pass_fail='pass') assert te3.put(db) == 0 db.close_db()
def test_get(): # reset the DB to a known state refresh_db ('test.db') # open the DB db = Database() assert db.open_db('test.db') == 0 # Create a Region Object region = Region(region_name='Seattle', region_abbrev="SEA", main_reg_id = 15500, reg_team_ids = "15500, 15513, 15505", nat_area = 1, street="7858 Leary Way", city = "Redmond", state = "WA", postal_code = "98052", email="*****@*****.**", phone = "(206) 555-1212", status = 0, standing = 0) assert region.put(db) == (0, 'Region Successfully Added!') # Check if the region was retrieved from DB assert region.get (db) == 0 # Create an empty Region Object region1 = Region() # Attempt to populate an empty (unknow) region from the DB assert region1.get (db) == 1 db.close_db()
def test_update(): # reset the DB to a known state refresh_db ('test.db') # open the DB db = Database() db.open_db('test.db') # Create a Region Object region = Region(region_name='Seattle', region_abbrev="SEA", main_reg_id = 15500, reg_team_ids = "15500, 15513, 15505", nat_area = 1, street="7858 Leary Way", city = "Redmond", state = "WA", postal_code = "98052", email="*****@*****.**", phone = "(206) 555-1212", status = 0, standing = 0) region.put(db) # Check if the Region was retrieved from DB assert region.get (db) == 0 # Time Travel - Test setting multiple attrs and doing a commit region.attrs['region_name'] = "Boston" region.attrs['region_abbrev'] = 'BOS' assert region.update (db) == 0 db.close_db()
def test_update(): # reset the DB to a known state refresh_db('test.db') # open the DB db = Database() db.open_db('test.db') # Create a NatArea Object natarea = NatArea(area_name='West', area_abbrev="WST") natarea.put(db) # Check if the NatArea was retrieved from DB assert natarea.get(db) == 0 print( f"DEBUG.natarea_test test_update natarea.attrs['nat_area_id'] = {natarea.attrs['nat_area_id']} " ) # Time Travel natarea.attrs['area_name'] = "South" natarea.attrs['area_abbrev'] = 'STH' assert natarea.update(db) == 0 db.close_db()
def test_update(): # reset the DB to a known state refresh_db('test.db') # open the DB db = Database() db.open_db('test.db') # Create a Information Object information = Information(school=1, first_name='John', last_name='Doe') # Check if the information was retrieved from DB assert information.get(db) == 0 # Time Travel - Test setting multiple attrs and doing a commit information.attrs['age'] = 37 information.attrs['birth_date'] = '9/1/1980' information.attrs['class_group'] = 'adult' information.attrs['street'] = '123 Main St' information.attrs['city'] = 'Redmond' information.attrs['state'] = 'WA' information.attrs['postal_code'] = '98052' assert information.update(db) == 0 db.close_db()
def test_attendanceDaily(): # reset the DB to a known state refresh_db('test.db') # open the DB db = Database() db.open_db('test.db') sql_id_list = [1, 22, 333, 4444, 55555] now = datetime.now() txt_date = str(now.month) + '/' + str(now.day) + '/' + \ str(now.year) assert attendanceDaily(db, sql_id_list, txt_date) == 0 c = db.cursor c.execute('SELECT * FROM attendance') row = c.fetchone() assert row[1] == 1 row = c.fetchone() assert row[1] == 22 row = c.fetchone() assert row[1] == 333 row = c.fetchone() assert row[1] == 4444 row = c.fetchone() assert row[1] == 55555 db.close_db()
def test_query_range(): # reset the DB to a known state refresh_db('test.db') # open the DB db = Database() db.open_db('test.db') st = Schools_Table() st.region = 1 assert st.query_range(db=db, limit=2, offset=0, region=1) == 0 assert len(st.schools) == 2
def test_query_all(): # reset the DB to a known state refresh_db('test.db') # open the DB db = Database() db.open_db('test.db') st = Schools_Table() st.region = 1 assert st.query_all(db=db) == 0 assert len(st.schools) == 4
def test_count(): # reset the DB to a known state refresh_db('test.db') # open the DB db = Database() db.open_db('test.db') st = Schools_Table() st.region = 1 assert st.count(db) == 4 db.close_db()
def test_query_range(): # reset the DB to a known state refresh_db('test.db') # open the DB db = Database() db.open_db('test.db') natarea1 = NatArea(area_name='West', area_abbrev="WST") assert natarea1.put(db) == (0, 'Area Successfully Added!') natarea2 = NatArea(area_name='East', area_abbrev="EST") assert natarea2.put(db) == (0, 'Area Successfully Added!') na = NatAreas_Table() assert na.query_range(db=db, limit=1, offset=0) == 0 assert len(na.areas) == 1
def test_put(): # reset the DB to a known state refresh_db('test.db') # open the DB db = Database() db.open_db('test.db') natarea1 = NatArea(area_name='South', area_abbrev="STH") assert natarea1.get(db) != 0 assert natarea1.put(db) == (0, 'Area Successfully Added!') natarea2 = NatArea(area_name='East', area_abbrev="EST") assert natarea2.get(db) != 0 assert natarea2.put(db) == (0, 'Area Successfully Added!') db.close_db()
def test_put(): # reset the DB to a known state refresh_db ('test.db') # open the DB db = Database() db.open_db('test.db') course1 = Course (course_name='Bagua', course_abbrev="BGWA") assert course1.get (db) != 0 assert course1.put (db) == 0 course2 = Course (course_name='Ship Pal Gae Dan Hyung', course_abbrev="SPGDH") assert course2.get (db) != 0 assert course2.put (db) == 0 db.close_db()
def test_query_range(): # reset the DB to a known state refresh_db ('test.db') # open the DB db = Database() db.open_db('test.db') course1 = Course (course_name='Bagua', course_abbrev="BGWA") assert course1.put (db) == 0 course2 = Course (course_name='Ship Pal Gae Dan Hyung', course_abbrev="SPGDH") assert course2.put (db) == 0 ct = Courses_Table() assert ct.query_range (db=db, limit=1, offset=0) == 0 assert len(ct.courses) == 1
def test_count(): # reset the DB to a known state refresh_db('test.db') # open the DB db = Database() db.open_db('test.db') natarea1 = NatArea(area_name='West', area_abbrev="WST") assert natarea1.put(db) == (0, 'Area Successfully Added!') natarea2 = NatArea(area_name='East', area_abbrev="EST") assert natarea2.put(db) == (0, 'Area Successfully Added!') na = NatAreas_Table() assert na.count(db) == 3 db.close_db()
def test_master_event_put(): # reset the DB to a known state refresh_db('test.db') # open the DB db = Database() db.open_db('test.db') event1 = Master_Event(event='newstudent', date='9/1/2017', student_sql_id=333) assert event1.put(db) == 0 event2 = Master_Event(event='test', date='9/2/2017', student_sql_id=4444) assert event2.put(db) == 0 event3 = Master_Event(event='drop', date='9/3/2017', student_sql_id=55555) assert event3.put(db) == 0 db.close_db()
def test_get(): # reset the DB to a known state refresh_db('test.db') # open the DB db = Database() assert db.open_db('test.db') == 0 # Create a School Object school = School(school_name='Seattle') # Check if the school was retrieved from DB assert school.get(db) == 0 # Create an empty School Object school1 = School() # Attempt to populate an empty (unknow) school from the DB assert school1.get(db) == 1 db.close_db()
def test_get(): # reset the DB to a known state refresh_db('test.db') # open the DB db = Database() assert db.open_db('test.db') == 0 # Create a Information Object information = Information(school=1, first_name='John', last_name='Doe') # Check if the information was retrieved from DB assert information.get(db) == 0 # Create an empty Information Object stud1 = Information() # Attempt to populate an empty (unknow) information from the DB assert stud1.get(db) == 1 db.close_db()
def test_update(): # reset the DB to a known state refresh_db ('test.db') # open the DB db = Database() db.open_db('test.db') # Create a Course Object course = Course(course_name='Bagua', course_abbrev="BGWA") course.put(db) # Check if the Course was retrieved from DB assert course.get (db) == 0 # Time Travel - Test setting multiple attrs and doing a commit course.attrs['course_name'] = "Dan Hyung - Ship Pal Gae" course.attrs['course_abbrev'] = 'DH-SPG' assert course.update (db) == 0 db.close_db()
def test_get(): # reset the DB to a known state refresh_db ('test.db') # open the DB db = Database() assert db.open_db('test.db') == 0 # Create a Student Object student = Student(oyd_id=15505, first_name='Thomas', middle_name = 'Alan', last_name='Grate', school=1) # Check if the student was retrieved from DB assert student.get (db) == 0 # Create an empty Student Object stud1 = Student() # Attempt to populate an empty (unknow) student from the DB assert stud1.get (db) == 1 db.close_db()
def test_get(): # reset the DB to a known state refresh_db('test.db') # open the DB db = Database() assert db.open_db('test.db') == 0 # Create a NatArea Object natarea = NatArea(area_name='West', area_abbrev="WST") natarea.put(db) # Check if the natarea was retrieved from DB assert natarea.get(db) == 0 # Create an empty NatArea Object natarea1 = NatArea() # Attempt to populate an empty (unknow) natarea from the DB assert natarea1.get(db) == 1 db.close_db()
def test_put(): # reset the DB to a known state refresh_db('test.db') # open the DB db = Database() db.open_db('test.db') info1 = Information(school=2, date='9/1/2018', first_name='Jon', last_name='Criddle', age=63, birth_date='6/2/1954', class_group='adult') assert info1.get(db) != 0 assert info1.put(db) == (0, 'New Information Added to Database') info2 = Information(school=2, date='9/1/2018', first_name='Michelle', last_name='Judy', age=36, birth_date='7/4/1981', class_group='adult') assert info2.get(db) != 0 assert info2.put(db) == (0, 'New Information Added to Database') info3 = Information(school=3, date='9/1/2018', first_name='Justin', last_name='Martin', age=41, birth_date='7/5/1976', class_group='adult') assert info3.get(db) != 0 assert info3.put(db) == (0, 'New Information Added to Database') db.close_db()
def test_get(): # reset the DB to a known state refresh_db ('test.db') # open the DB db = Database() assert db.open_db('test.db') == 0 # Create a Course Object course = Course(course_name='Bagua', course_abbrev="BGWA") course.put(db) # Check if the course was retrieved from DB assert course.get (db) == 0 # Create an empty Course Object course1 = Course() # Attempt to populate an empty (unknow) course from the DB assert course1.get (db) == 1 db.close_db()
def test_update(): # reset the DB to a known state refresh_db ('test.db') # open the DB db = Database() db.open_db('test.db') # Create a Student Object student = Student(oyd_id=15505, first_name='Thomas', middle_name = 'Alan', last_name='Grate', school=1) # Check if the student was retrieved from DB assert student.get (db) == 0 # Time Travel - Test setting multiple attrs and doing a commit student.attrs['age'] = 54 student.attrs['rank'] = '4D' student.attrs['next_rank'] = '5D' student.attrs['title'] = 'ARHI' assert student.update (db) == 0 db.close_db()
def test_update_attr(): # reset the DB to a known state refresh_db('test.db') # open the DB db = Database() db.open_db('test.db') # Create a Information Object information = Information(school=1, first_name='John', last_name='Doe') # Check if the information was retrieved from DB assert information.get(db) == 0 # Lets Go back in Time - Test a single attr set and update information.attrs['age'] = 27 assert information.update_attr(db, 'age') == 0 information.attrs['birth_date'] = '9/1/1990' assert information.update_attr(db, 'birth_date') == 0 information.attrs['class_group'] = 'adult' assert information.update_attr(db, 'class_group') == 0 db.close_db()
def test_put(): # reset the DB to a known state refresh_db('test.db') # open the DB db = Database() db.open_db('test.db') school1 = School(school_name='Medford', main_ins_id=16601, school_region=2, street="7858 Leary Way", city="Medford", state="MA", postal_code="02145", email="*****@*****.**", school_phone="(206) 555-1212", status=0, standing=0) assert school1.get(db) != 0 assert school1.put(db) == (0, 'School Successfully Added!') school2 = School(school_name='West Cambridge', main_ins_id=16600, school_region=2, street="123 Main St.", city="Boston", state="MA", postal_code="02134", email="*****@*****.**", school_phone="(555) 555-1212", status=0, standing=0) assert school2.get(db) != 0 assert school2.put(db) == (0, 'School Successfully Added!') db.close_db()