Ejemplo n.º 1
0
def test_find_found_in_id_map_found_in_DB(monkeypatch):
    # Test Data
    unexpected = Waiting('room', User('name', 'password'), 'time',
                         'description', Equipment("trcyvu"), 1)
    expected = Waiting('room1', User('name2', 'password3'), 'time1',
                       'description2', Equipment("fgvkgas"), 2)

    # Mock
    def id_find(_, __):
        return expected

    def tdg_find(_):
        return [[
            unexpected.getId(),
            unexpected.getRoom(),
            unexpected.getUser(),
            unexpected.getDescription(),
            unexpected.getTimeslot()
        ]]

    monkeypatch.setattr(IdMap, 'find', id_find)
    monkeypatch.setattr(WaitingTDG, 'find', tdg_find)

    # Execute
    val = WaitingMapper.find(1)

    # Verify
    assert (val.getTimeslot() is expected.getTimeslot())
    assert (val.getRoom() is expected.getRoom())
    assert (val.getUser() is expected.getUser())
    assert (val.getDescription() is expected.getDescription())
    assert (val.getId() is expected.getId())
Ejemplo n.º 2
0
def test_equipment_getting_number_of_equipment_needed():
    equipment7 = Equipment("equipmentID_ibiubi",
                           laptops=2,
                           projectors=1,
                           whiteboards=4)
    assert 7 == len(equipment7)

    equipment1 = Equipment("equipmentID", 0, 1, 0)
    assert 1 == len(equipment1)

    equipment4 = Equipment("equipmentID_12313", 1, 2, 1)
    assert 4 == len(equipment4)
Ejemplo n.º 3
0
    def getAllEquipmentAvailableAtTimeslot(self, timeslot):
        """

        :rtype: Equipment
        """
        maxEquipmentAvailable = Equipment("equipmentID_uvu", laptops=MAX_EQUIPMENT_NUMBER, projectors=MAX_EQUIPMENT_NUMBER, whiteboards=MAX_EQUIPMENT_NUMBER)
        # iterate through reservations list, get total equipment already reserved
        for r in self.getAllReservationsForTimeslot(timeslot):
            for type, quantity in r.getEquipment().equipment.iteritems():
                amountAvailable = maxEquipmentAvailable.equipment[type]
                maxEquipmentAvailable.equipment[type] = int(amountAvailable) - int(quantity)
        return maxEquipmentAvailable
Ejemplo n.º 4
0
def test_find_found_in_id_map_not_found_in_DB(monkeypatch):
    # Test Data
    expected = Waiting("room", User("mammad", "password"),
                       Timeslot(1, 2, "date", 1, "mammad",
                                "timeID_ibuon"), 'description',
                       Equipment('equipment'), "waitingID_vubion")

    # Mock
    def id_find(_, __):
        return expected

    def no_find(_):
        return

    monkeypatch.setattr(IdMap, 'find', id_find)
    monkeypatch.setattr(WaitingTDG, 'find', no_find)

    # Execute
    val = WaitingMapper.find("waitingID_vubion")

    # Verify
    assert (val.getTimeslot() is expected.getTimeslot())
    assert (val.getRoom() is expected.getRoom())
    assert (val.getUser() is expected.getUser())
    assert (val.getDescription() is expected.getDescription())
    assert (val.getId() is expected.getId())
Ejemplo n.º 5
0
def find(equipmentId):
    result = EquipmentTDG.find(equipmentId)
    if not result:
        return
    else:
        return Equipment(result[0][0], result[0][1], result[0][2],
                         result[0][3])
Ejemplo n.º 6
0
 def reservation_not_found(_):
     room = Room(1)
     user = User('buddy', 'boy')
     time = Timeslot(1, 2, datetime(2020, 01, 01), '', 1, 1)
     equipment = Equipment("EquipmentID_iionask")
     return Reservation(room, user, time, 'description', equipment,
                        'test')
Ejemplo n.º 7
0
def makeNew(laptops, projectors, whiteboards, equipmentId):
    equipment = Equipment(equipmentId,
                          laptops=laptops,
                          projectors=projectors,
                          whiteboards=whiteboards)
    UnitOfWork.registerNew(equipment)
    return equipment
Ejemplo n.º 8
0
 def reservation_create(*args, **kwargs):
     room = Room(1)
     user = User('buddy', 'boy')
     time = Timeslot(1, 2, datetime(2020, 01, 01), 1,
                     "userID_tyvub", "timeslotID_ugvhbjk")
     return Reservation(room, user, time, 'description',
                        Equipment("equipmentID_yvhjb"),
                        "reservationID_vghjbk")
Ejemplo n.º 9
0
 def reservations_found():
     room = Room(1)
     user = User('buddy', 'boy')
     time = Timeslot(1, 2, datetime(2020, 01, 01), 1, 'buddy',
                     'timeslotID_7g8hij')
     return [
         Reservation(room, user, time, 'description',
                     Equipment("equipmentID_ionoi"),
                     "reservationID")
     ]
Ejemplo n.º 10
0
 def find_by_room(*args, **kwargs):
     room = Room(1)
     user = User('buddy', 'boy')
     time = Timeslot(1, 2, datetime(2020, 01, 01), 1,
                     "userID_vubin", "timeslotID_hbijkn")
     return [
         Reservation(room, user, time, 'description',
                     Equipment("equipmentID_uyvbin"),
                     "reservationID_ygvuhjbk")
     ]
Ejemplo n.º 11
0
 def find_by_room(*args, **kwargs):
     room = Room(1)
     user = User('buddy', 'boy')
     time = Timeslot(1, 2, datetime(2020, 01, 01), 1, "userID_ibun",
                     "timeslotID_vuhbjk")
     return [
         Reservation(room, user, time, 'description',
                     Equipment("equipmentID_vguhbikjn"),
                     "reservationID_tcytvuhb")
     ]
Ejemplo n.º 12
0
 def find_by_user(*args, **kwargs):
     room = Room(1)
     user = User('buddy', 'boy')
     time = Timeslot(1, 2, datetime(2020, 01, 01), 1,
                     "userID_bijknklm", "timeslotID_ghvjbk")
     return [
         Reservation(room, user, time, 'description',
                     Equipment("equipmentID_hgcvjb"),
                     "reservationID_vuhbiuj")
     ]
Ejemplo n.º 13
0
def test_find_not_found_in_id_map_found_in_DB(monkeypatch):
    # Test Data
    expected_timeslot = Timeslot(1, 2, 'date', 1, 'usernameid', 'timeid')
    expected_room = Room(1)
    expected_user = User('abe', 3)
    expected_equipment = Equipment("equipmentID_uvibonpm")
    expected = Waiting(expected_room, expected_user, expected_timeslot, 'joe',
                       expected_equipment, 234)

    # Mock
    def no_find(_, __):
        return

    def yes_find(_):
        return [[
            expected.getId(),
            expected.getRoom(),
            expected.getUser(),
            expected.getDescription(),
            expected_equipment.getId(),
            expected.getTimeslot().getId()
        ]]

    def timeslot_find(_):
        return expected_timeslot

    def room_find(_):
        return expected_room

    def user_find(_):
        return expected_user

    monkeypatch.setattr(IdMap, 'find', no_find)
    monkeypatch.setattr(WaitingTDG, 'find', yes_find)
    monkeypatch.setattr(TimeslotMapper, 'find', timeslot_find)
    monkeypatch.setattr(RoomMapper, 'find', room_find)
    monkeypatch.setattr(UserMapper, 'find', user_find)

    # Execute
    val = WaitingMapper.find("iyubon")

    # Verify
    assert (val.getTimeslot() is expected_timeslot)
    assert (val.getRoom() is expected_room)
    assert (val.getUser() is expected_user)
    assert (val.getDescription() is expected.getDescription())
    assert (val.getId() is expected.getId())
Ejemplo n.º 14
0
def test_find_found_in_id_map_not_found_in_DB(monkeypatch):
    # Test Data
    expected = Reservation('room', User('name', 'password'), 'time', 'description',Equipment("dxhtcfjygv"), 1)


    # Mock
    def id_find(_, __):
        return expected

    def no_find(_):
        return

    monkeypatch.setattr(IdMap, 'find', id_find)
    monkeypatch.setattr(ReservationTDG, 'find', no_find)

    # Execute
    val = ReservationMapper.find("vuybi")

    # Verify
    assert(val.getRoom() is expected.getRoom())
    assert(val.getDescription() is expected.getDescription())
    assert(val.getTimeslot() is expected.getTimeslot())
    assert(val.getId() is expected.getId())
Ejemplo n.º 15
0
def test_find_not_found_in_id_map_found_in_DB(monkeypatch):
    # Test Data
    expected_timeslot = Timeslot(1, 2, 'date', 1, 'usernameid','timeid')
    expected_room = Room(1)
    expected = Reservation(expected_room, User('name', 'password'), expected_timeslot, 'description', Equipment("3w4ex5rcy"), "reservationID####")

    # Mock
    def no_find(_, __):
        return

    def yes_find(_):
        return [[expected.getId(), expected_room.getId(), expected.getDescription(), expected.getUser().getId(), expected.getEquipment().getId(), expected_timeslot.getId()]]

    def timeslot_find(_):
        return expected_timeslot

    def room_find(_):
        return expected_room

    monkeypatch.setattr(IdMap, 'find', no_find)
    monkeypatch.setattr(ReservationTDG, 'find', yes_find)
    monkeypatch.setattr(TimeslotMapper, 'find', timeslot_find)
    monkeypatch.setattr(RoomMapper, 'find', room_find)

    # Execute
    val = ReservationMapper.find("trcyv")

    # Verify
    assert(val.getRoom().getId() is expected_room.getId())
    assert(val.getDescription() is expected.getDescription())
    assert(val.getTimeslot().getId() is expected_timeslot.getId())
    assert(val.getId() is expected.getId())
Ejemplo n.º 16
0
def delete(equipmentId):
    UnitOfWork.registerDeleted(Equipment(equipmentId, 0, 0, 0))
Ejemplo n.º 17
0
def test_equipment_with_no_arguments_is_zero_length():
    equipment = Equipment("equipmentID_uybino")
    assert 0 == len(equipment)