Ejemplo n.º 1
0
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()
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
0
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
Ejemplo n.º 4
0
def test_friends():
    Database.initialize()
    Database.dropAll()

    Manager.manager_register("*****@*****.**", 'admin', 'Admin admin', '000000000', 'eng', 1, 'YAHOO', 'matam')
    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')
    Manager.user_register("*****@*****.**", '123', 'avi', '000260000', 'eng', 3, 'YAHOO', 'matam')
    Manager.user_register("*****@*****.**", '123', 'yin', '000000026', 'eng', 3, 'YAHOO', 'matam')
    Manager.user_register("*****@*****.**", '123', 'yan', '026000000', 'eng', 3, 'YAHOO', 'matam')

    user1 = User.get_by_email("*****@*****.**")
    user2 = User.get_by_email('*****@*****.**')
    user3 = User.get_by_email('*****@*****.**')
    user4 = User.get_by_email('*****@*****.**')

    emails = ["*****@*****.**", '*****@*****.**', '*****@*****.**', '*****@*****.**', "*****@*****.**"]
    permission = User.min_permission(emails)
    assert permission == 1

    user1.add_friend('*****@*****.**')
    status, string = user1.add_friend('*****@*****.**')
    assert status is False
    user1.add_friend('*****@*****.**')

    assert user2.email in user1.get_friends_emails()
    assert user3 not in user1.get_friends_emails()
    assert user4.email in user1.get_friends_emails()

    user1.remove_friend('*****@*****.**')
    assert '*****@*****.**' not in user1.get_friends_emails()

    assert '*****@*****.**' in user2.get_friends_emails()
    assert not Friends.is_friends('*****@*****.**', '*****@*****.**')
    assert Friends.is_friends('*****@*****.**', '*****@*****.**')

    manager = Manager.get_by_email('*****@*****.**')

    assert len(user1.get_friends()) > 0

    manager.add_friend('*****@*****.**')

    assert user2 is not None
    assert manager.delete_user('*****@*****.**') is True
Ejemplo n.º 5
0
def test_user():
    Database.initialize()
    Database.dropAll()
    Manager.manager_register("*****@*****.**", 'admin', 'Admin admin', '000000000', 'eng', 1, 'YAHOO', 'matam')
    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')
    Manager.user_register("*****@*****.**", '123', 'avi', '000260000', 'eng', 3, 'YAHOO', 'matam')
    Manager.user_register("*****@*****.**", '123', 'yin', '000000026', 'eng', 3, 'YAHOO', 'matam')
    Manager.user_register("*****@*****.**", '123', 'yan', '026000000', 'eng', 3, 'YAHOO', 'matam')

    assert User.get_by_id("*****@*****.**") is None
    # assert User.get_by_id("000000000") is not None
    assert Manager.get_by_email("*****@*****.**").company == 'YAHOO'
    assert User.get_by_email('*****@*****.**').company == 'YAHOO'
    assert User.get_by_email("*****@*****.**").company == 'YAHOO'

    assert User.login_valid('*****@*****.**', '123') is True
    assert User.login_valid('*****@*****.**', 'username__') is False

    manager = Manager.get_by_email('*****@*****.**')
    assert manager is None
    manager = Manager.get_by_email('*****@*****.**')
    assert manager is not None
    assert manager.delete_user('*****@*****.**') is True
    assert User.get_by_email('*****@*****.**') is None
    assert manager.delete_user('*****@*****.**') is False

    assert manager.delete_user('aaaaaaaaaaaaa') is False
    assert User.min_permission(['*****@*****.**', "*****@*****.**", "*****@*****.**"]) == 1
    assert User.min_permission(['*****@*****.**', '*****@*****.**']) == 3
    assert manager.update_user('manager') is True
    print(os.getcwd() + '/rooms.csv')
    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