def test_duplicate_seminar_different_convenor(self): system = EMS() user = system.get_user('4119998') seminar = (1,1,'Test Seminar',4119993,'Testing','2018-12-10 22:00:00',\ 'UNSW','2019-01-01 22:00:00','2019-01-30 22:00:00','2018-12-01 22:00:00',1,100,2) dbInserter.insert_Seminar(seminar) session = (1,'Hi','Tommy','Hi',50,0,1,1) dbInserter.insert_Session(session) session = (2,'Bye','Tommy','Bye',50,0,1,1) dbInserter.insert_Session(session) seminar = system.create_seminar(user, 'Test','tested',\ '2018-12-10 22:00:00','UNSW Law Library','2019-01-01 22:00:00','2019-01-30 22:00:00',\ '2018-12-1 22:00:00',1) self.assertTrue(seminar, 1) self.assertEqual(system.create_session(seminar, 'Hi','Hi','Tommy',50), 1) self.assertEqual(system.create_session(seminar, 'Bye','Bye','Tommy',50), 1) self.assertTrue(len(seminar.sessions) == 2) self.assertEqual(system.add_seminar(seminar), 1) self.assertEqual(system.add_sessions(seminar), 1) seminar_list = dbHandler.select_all_products("Seminar") session_list = dbHandler.select_all_products("Session") self.assertTrue(len(seminar_list) == 2) self.assertTrue(len(session_list) == 4) sem1 = (2,1,'Test',4119998,'tested','2018-12-10 22:00:00','UNSW Law Library',\ '2019-01-01 22:00:00','2019-01-30 22:00:00','2018-12-01 22:00:00',1,100,2) self.assertEqual(seminar_list[1], sem1) session3 = (3,'Hi','Tommy','Hi',50,0,2,1) session4 = (4,'Bye','Tommy','Bye',50,0,2,1) self.assertEqual(session_list[2], session3) self.assertEqual(session_list[3], session4)
def test_invalid_early(self): system = EMS() user = system.get_user("4119993") with pytest.raises(Exception) as e_info: seminar = system.create_seminar(user, 'Test','Testing',\ '2018-10-10 22:00:00','UNSW','2019-01-01 22:00:00','2019-01-30 22:00:00',\ '2018-10-11 22:00:00',1)
def test_successful_create_seminar(self): system = EMS() user = system.get_user('4119993') sem = (1,1,'Test',4119993,'Testing','2018-12-10 22:00:00',\ 'UNSW','2019-01-01 22:00:00','2019-01-30 22:00:00','2018-12-01 22:00:00',1,100,2) session1 = (1,'Hi','Hi','Hi',50,1,1,1) session2 = (2,'Bye','Bye','Bye',50,1,1,1) seminar = system.create_seminar(user, 'Test','Testing',\ '2018-12-10 22:00:00','UNSW','2019-01-01 22:00:00','2019-01-30 22:00:00',\ '2018-12-01 22:00:00',1) self.assertEqual(system.create_session(seminar, 'Hi','Hi','Hi', 50), 1) self.assertEqual(system.create_session(seminar, 'Bye','Bye','Bye',50), 1) self.assertTrue(len(seminar.sessions) == 2) self.assertEqual(system.add_seminar(seminar), 1) self.assertEqual(system.add_sessions(seminar), 1) seminar_list = dbHandler.select_all_products("Seminar") session_list = dbHandler.select_all_products("Session") self.assertTrue(seminar_list != []) self.assertTrue(session_list != []) self.assertEqual(seminar_list[0], sem) self.assertEqual(session_list[0], session1) self.assertEqual(session_list[1], session2)
def test_duplicate_session(self): system = EMS() user = system.get_user('4119993') seminar = system.create_seminar(user, 'Test','Testing',\ '2018-12-10 22:00:00','UNSW','2019-01-01 22:00:00','2019-01-30 22:00:00',\ '2018-12-1 22:00:00',1) self.assertEqual(system.create_session(seminar, 'Hi','Hi','Hi', 50), 1) self.assertEqual(system.create_session(seminar, 'Hi','Bye','Hi',50), 0) self.assertTrue(len(seminar.sessions) == 1)
def test_invalid_num_sessions(self): system = EMS() user = system.get_user('4119993') seminar = system.create_seminar(user, 'Test','Testing',\ '2018-12-10 22:00:00','UNSW','2019-01-01 22:00:00','2019-01-30 22:00:00',\ '2018-12-1 22:00:00',1) self.assertEqual(system.create_session(seminar, 'Hi','Hi','Hi', 50), 1) self.assertTrue(len(seminar.sessions) == 1) self.assertEqual(system.add_seminar(seminar), 0) seminar_list = dbHandler.select_all_products("Seminar") session_list = dbHandler.select_all_products("Session") self.assertTrue(seminar_list == []) self.assertTrue(session_list == [])
def test_capacity(self): system = EMS() user = system.get_user('4119993') sem = (1,1,'Test',4119993,'Testing','2018-12-10 22:00:00',\ 'UNSW','2019-01-01 22:00:00','2019-01-30 22:00:00','2018-12-1 22:00:00',1,100,0) session1 = (1,'Hi','Hi','Hi',50,0,1,1) session2 = (2,'Bye','Bye','Bye',50,0,1,1) seminar = system.create_seminar(user, 'Test','Testing',\ '2018-12-10 22:00:00','UNSW','2019-01-01 22:00:00','2019-01-30 22:00:00',\ '2018-12-1 22:00:00',1) with pytest.raises(Exception) as e_info: session = system.create_session(seminar, 'Hi','Hi','Hi', 0) with pytest.raises(Exception) as e_info: session = system.create_session(seminar, 'Bye','Bye','Bye',-1) self.assertTrue(len(seminar.sessions) == 0)
def test_duplicate_seminar(self): system = EMS() user = system.get_user('4119993') seminar = (1,1,'Test Seminar',4119993,'Testing','2018-12-10 22:00:00','UNSW','2019-01-01 22:00:00','2019-01-30 22:00:00','2018-12-1 22:00:00',1,100,2) dbInserter.insert_Seminar(seminar) session = (1,'Hi','Tommy','Hi',50,1,1,1) dbInserter.insert_Session(session) session = (2,'Bye','Tommy','Bye',50,1,1,1) dbInserter.insert_Session(session) seminar = system.create_seminar(user, 'Test','tested',\ '2018-12-10 22:00:00','UNSW Law Library','2019-01-01 22:00:00','2019-01-30 22:00:00',\ '2018-12-1 22:00:00',1) self.assertTrue(seminar, 0) seminar_list = dbHandler.select_all_products("Seminar") session_list = dbHandler.select_all_products("Session") self.assertTrue(len(seminar_list) == 1) self.assertTrue(len(session_list) == 2)