예제 #1
0
    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)
예제 #2
0
    def test_automatic_close(self):
        system = EMS()
        user = system.get_user('6119988')
        seminar = (1,1,'Test Seminar',4119993,'Testing','2018-05-25 22:00:00','UNSW','2018-05-26 10:00:00','2018-05-26 22:00:00','2018-05-25 21: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)

        events_left = system.open_events_list("Seminar")

        self.assertTrue(events_left == [])
예제 #3
0
 def add_sessions(self, seminar):
     """
     Creates a session entry in the database
     Input: {seminar}->seminar object
     Output: N/A
     """
     SessionID = len(dbHandler.select_all_products('Session'))
     for session in seminar.sessions:
         SessionID += 1
         data = (SessionID, session.topic, session.presenter, session.detail,\
         session.capacity, session.noAttendees, seminar.event_id, session.status)
         dbInserter.insert_Session(data)
         self.update_attendees('register', session, "Session",
                               session.presenter)
     return 1
예제 #4
0
    def test_close_registrations(self):
        system = EMS()
        user = system.get_user('4119998')
        seminar = (1,0,'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,0)
        dbInserter.insert_Seminar(seminar)
        session1 = (1,'Hi','Tommy','Hi',50,0,1,0)
        dbInserter.insert_Session(session1)
        session2 = (2,'Bye','Tommy','Bye',50,0,1,0)
        dbInserter.insert_Session(session2)

        test_sess = system.get_event('Session', 1)

        with pytest.raises(Exception) as e_info:
            updated = system.update_attendees('register', test_sess, 'Session', user.email)

        test_sess = system.get_event('Session',1)
        self.assertEqual(test_sess.noAttendees, 0)
        session_list = dbHandler.select_all_products("Session")
        self.assertEqual(session_list[0], session1)
예제 #5
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)
예제 #6
0
    def test_active_register_seminar(self):
        system = EMS()
        user = system.get_user('6119988')
        date_format = "%Y-%m-%d %H:%M:%S"
        yesterday = str(datetime.strftime(datetime.now() - timedelta(1), date_format))
        tomorrow = str(datetime.strftime(datetime.now() + timedelta(1), date_format))
        seminar = (1,1,'Test Seminar',4119993,'Testing','2018-12-10 22:00:00','UNSW',yesterday,tomorrow,'2018-12-1 22:00:00',1,100,0)
        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)

        test_sess = system.get_event('Session', 1)

        with pytest.raises(Exception) as e_info:
            updated = system.update_attendees('register', test_sess, 'Session', user.email)

        seminar_registration = dbHandler.select_all_products("User_Seminar")
        self.assertEqual(seminar_registration, [])
        session_registration = dbHandler.select_all_products("User_Session")
        self.assertEqual(session_registration, [])
예제 #7
0
    def test_full_register_seminar(self):
        system = EMS()
        user = system.get_user('6119988')
        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,100)
        dbInserter.insert_Seminar(seminar)
        session1 = (1,'Hi','Tommy','Hi',50,50,1,1)
        dbInserter.insert_Session(session1)
        session2 = (2,'Bye','Tommy','Bye',50,50,1,1)
        dbInserter.insert_Session(session2)

        test_sess = system.get_event('Session', 1)

        self.assertTrue(system.update_attendees('register', test_sess, 'Session', user.email) == 0)
        test_sess = system.get_event('Session',1)
        self.assertEqual(test_sess.noAttendees, 50)
        session1 = (1,'Hi','Tommy','Hi',50,50,1,1)
        session_list = dbHandler.select_all_products("Session")
        self.assertEqual(session_list[0], session1)

        seminar_registration = dbHandler.select_products("User_Seminar", "Email", "*****@*****.**")
        self.assertTrue(seminar_registration == [])
        session_registration = dbHandler.select_products("User_Session", "Email", "*****@*****.**")
        self.assertTrue(session_registration == [])
예제 #8
0
dbCreator.create_session_table(db_name)
dbCreator.create_user_course_table(db_name)
dbCreator.create_user_seminar_table(db_name)
dbCreator.create_user_session_table(db_name)

course = (1, 1, 't', 4119988, 't', '2018-12-10 22:00:00', 100, 0, 't',
          '2019-01-01 22:00:00', '2019-01-30 22:00:00', '2018-12-01 22:00:00',
          100)
dbInserter.insert_Course(course)
course = (2, 1, 's', 4119989, 's', '2018-12-10 22:00:00', 1, 0, 's',
          '2019-01-01 22:00:00', '2019-01-30 22:00:00', '2018-12-01 22:00:00',
          100)
dbInserter.insert_Course(course)
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, 0)
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)

with open("user.csv", "r") as w:
    for i in range(0, 24):
        (name, zID, email, password, role) = w.readline().split(",")
        print((name, zID, email, password, role.rstrip('\n')))
        user = (name, zID, email, password, role.rstrip('\n'))
        dbInserter.insert_User(user)

import routes