def test_analytics(): Database.initialize() Database.dropAll() assert Analytics.get_num_employees_facility_simulation('YAHOO', 'matam') == 0 Manager.manager_register("*****@*****.**", 'admin', 'Admin admin', '000000000', 'eng', 1, 'YAHOO', 'matam') manager = Manager.get_by_email('*****@*****.**') assert manager is not None assert Analytics.get_num_rooms_facility_simulation('YAHOO', facility_id=None) == 0 assert Analytics.get_meetings_number_in_facility_simulation(manager, 'matam') == 0 assert Analytics.get_all_rooms_occupancy_simulation(manager, 1) == [] Manager.user_register("*****@*****.**", '123', 'ely', '000000026', 'eng', 3, 'YAHOO', 'matam') Manager.user_register("*****@*****.**", '123', 'yosi', '023412349', 'eng', 1, 'YAHOO', 'matam') Manager.user_register("*****@*****.**", '123', 'dave', '123412348', 'eng', 1, 'YAHOO', 'matam') Manager.user_register("*****@*****.**", '123', 'foox', '000002600', 'eng', 3, 'YAHOO', 'matam') Room.add_room(2, 2, 1, 3, 'YAHOO', 'matam', True) occupancy_yahoo_matam_1 = Analytics.get_room_occupancy(1, 'YAHOO', time=datetime.now()) Analytics.get_room_occupancy_simulation(1, "YAHOO", datetime.now()) status, room_id = Room.add_room(2, 1, 3, 4, 'YAHOO', 'matam', False) status, room_id = Room.add_room(2, 1, 5, 4, 'YAHOO', 'matam', True) status, room_id = Room.add_room(2, 2, 4, 4, 'YAHOO', 'matam', True) assert Analytics.get_num_rooms_facility('YAHOO') == 4 Room.remove_room(room_id) assert Analytics.get_num_rooms_facility('YAHOO') == 3 Room.add_room(2, 2, 1, 3, 'YAHOO', 'Herzeliya', True) Room.add_room(2, 2, 2, 3, 'YAHOO', 'Herzeliya', True) Room.add_room(2, 2, 3, 3, 'YAHOO', 'Herzeliya', True) Room.add_room(2, 2, 4, 3, 'YAHOO', 'Herzeliya', True) assert Analytics.get_num_rooms_facility('YAHOO') == 7 assert Analytics.get_num_rooms_facility('YAHOO', 'matam') == 3 assert Analytics.get_num_rooms_facility('YAHOO', 'Herzeliya') == 4 assert Analytics.get_num_employees_facility('YAHOO') == 5 Manager.user_register("*****@*****.**", '123', 'avi', '000260000', 'eng', 3, 'YAHOO', 'matam') assert Analytics.get_num_employees_facility('YAHOO') == 6 assert manager.delete_user('*****@*****.**') is True assert Analytics.get_num_employees_facility('YAHOO') == 5 Analytics.get_all_participants_in_facility(manager, 'matam') meetings_number_yahoo = Analytics.get_meetings_number_in_facility(manager, "YAHOO") # assert meetings_number_yahoo == meetings_number_yahoo = Analytics.get_meeting_number(manager) # assert meetings_number_yahoo == room_occupancy_yahoo = Analytics.get_all_rooms_occupancy(manager)
def test_schedules_orders4(): User.print_values() Database.initialize() Database.dropAll() # Database.find_one('orders', {'_id' : '23/05/18' }) # num1 = Database.count('orders') # Database.remove('orders', {'_id': '23/05/18'}) # num2 = Database.count('orders') Manager.manager_register("*****@*****.**", 'admin', 'Admin admin', '000000000', 'eng', 1, 'YAHOO', 'matam') status, room_id = Room.add_room(2, 2, 1, 3, 'YAHOO', 'matam', True) ########################################changed capacity assert status is True status, room_id = Room.add_room(2, 1, 3, 4, 'YAHOO', 'matam', False) assert status is True assert Room.remove_room(room_id) is True status, room_id = Room.add_room(2, 1, 3, 4, 'YAHOO', 'matam', True) status, room_id = Room.add_room(2, 2, 4, 4, 'YAHOO', 'matam', True) num1 = Database.count('orders') Database.remove('orders', {'_id': '23/05/18'}) num2 = Database.count('orders') Database.remove('orders', {'date': '26/05/18'}) num3 = Database.count('orders') num_users1 = Database.count('users') Manager.user_register("*****@*****.**", '123', 'foox', '000002600', 'eng', 3, 'YAHOO', 'matam') Manager.user_register("*****@*****.**", '123', 'yan', '026000000', 'eng', 3, 'YAHOO', 'matam') Manager.user_register("*****@*****.**", '456', 'bim', '313324360', 'eng', 3, 'YAHOO', 'matam') num_users2 = Database.count('users') user2 = User.get_by_email('*****@*****.**') user3 = User.get_by_email('*****@*****.**') manager = Manager.get_by_email('*****@*****.**') assert manager is None manager = Manager.get_by_email('*****@*****.**') assert manager is not None try: manager.import_rooms(os.getcwd() + '\\rooms.csv') manager.import_employee(os.getcwd() + '\\employee.csv') # should'nt works on travis except Exception as e: pass num_users2 = Database.count('users') user1 = User.get_by_email('*****@*****.**') user2 = User.get_by_email('*****@*****.**') user3 = User.get_by_email('*****@*****.**') participants1 = ['*****@*****.**', '*****@*****.**'] participants2 = ['*****@*****.**'] participants3 = ['*****@*****.**', '*****@*****.**'] # date = datetime.utcnow().strftime('%d/%m/%y') date = '21/06/18' status2, string2 = user2.new_order(date, participants2, 6, 7, "YAHOO", 'matam') schedules2 = user2.get_schedule() assert status2 == True date_next = '22/06/18' status3, string3 = user2.new_order(date_next, participants2, 6, 7, "YAHOO", 'matam') # assert status3==True schedules2 = user2.get_schedule()
def test_schedules_orders(): Database.initialize() Database.dropAll() Manager.manager_register("*****@*****.**", 'admin', 'Admin admin', '000000000', 'eng', 1, 'YAHOO', 'matam') status, room_id = Room.add_room(2, 30, 1, 3, 'YAHOO', 'matam', True) assert status is True status, room_id = Room.add_room(2, 30, 3, 4, 'YAHOO', 'matam', False) assert status is True assert Room.remove_room(room_id) is True status, room_id = Room.add_room(2, 30, 3, 4, 'YAHOO', 'matam', True) num1 = Database.count('orders') Database.remove('orders', {'_id': '23/05/18'}) num2 = Database.count('orders') Database.remove('orders', {'date': '26/05/18'}) num3 = Database.count('orders') num_users1 = Database.count('users') Manager.user_register("*****@*****.**", '123', 'foox', '000002600', 'eng', 3, 'YAHOO', 'matam') Manager.user_register("*****@*****.**", '123', 'yan', '026000000', 'eng', 3, 'YAHOO', 'matam') num_users2 = Database.count('users') manager = Manager.get_by_email('*****@*****.**') assert manager is None manager = Manager.get_by_email('*****@*****.**') assert manager is not None try: manager.import_rooms(os.getcwd() + '\\rooms.csv') manager.import_employee(os.getcwd() + '\\employee.csv') # should'nt works on travis except Exception as e: pass num_users2 = Database.count('users') user = User.get_by_email('*****@*****.**') participants = ['*****@*****.**', '*****@*****.**'] date = datetime.utcnow().strftime('%d/%m/%y') date = '26/06/18' status, string = user.new_order(date, participants, 1, 2, "YAHOO", 'matam') print(string) orders = user.get_orders() num_orders = len(orders) assert len(user.get_orders()) > 0 schedules = user.get_schedule() assert len(schedules) > 0 schedules = Schedule.get_schedules('*****@*****.**') assert len(Schedule.get_by_room("YAHOO matam 1")) > 0 assert len(Room.available_rooms('11/11/11', 2, 1, 2, 2, 'YAHOO', 'matam')) > 0
def test_rooms(): Database.initialize() Database.remove('rooms', {}) status, room_id = Room.add_room(2, 30, 1, 3, 'YAHOO', 'matam', True) assert status is True status, room_id = Room.add_room(2, 30, 3, 4, 'YAHOO', 'matam', False) assert status is True assert Room.remove_room(room_id) is True status, room_id = Room.add_room(2, 30, 3, 4, 'YAHOO', 'matam', True) assert status is True assert Room.get_by_id(room_id).company == 'YAHOO' assert len(Room.get_by_company('YAHOO')) > 0 assert len(Room.get_by_facility('YAHOO', 'matam')) > 0 assert len(Room.get_by_capacity(5, 'YAHOO', 'matam', 2)) > 0 assert len(Room.get_by_capacity(50, 'YAHOO', 'matam', 2)) == 0 assert len(Room.get_by_capacity(20, 'YAHOO', 'matam', 3)) > 0 assert len(Room.get_by_capacity(20, 'YAHOO', 'matam', 1)) == 0
def remove_room(): room_to_remove = request.form['room_id'] Room.remove_room(room_to_remove)