コード例 #1
0
def test_agenda_item_admin_get_field_queryset_no_request(agenda_item_admin):
    RoomFactory()
    RoomFactory()
    RoomFactory()

    queryset = agenda_item_admin.get_field_queryset(
        db=None, db_field=AgendaItem._meta.get_field("room"), request=None
    )

    assert queryset.count() == 3
コード例 #2
0
def test_agenda_item_admin_get_field_queryset_no_popup(
    hour, agenda_item_admin, request_builder
):
    RoomFactory()
    RoomFactory()
    room = RoomFactory()
    request = request_builder(room_id=room.id)

    queryset = agenda_item_admin.get_field_queryset(
        db=None, db_field=AgendaItem._meta.get_field("room"), request=request
    )

    assert queryset.count() == 3
コード例 #3
0
 def create_factories(self):
     self.admin = UserFactory()
     self.old_room = RoomFactory()
     self.new_room = RoomFactory()
     self.user = UserFactory(room=self.old_room)
     self.task = UserTaskFactory(
         user=self.user,
         type=TaskType.USER_MOVE,
         created=datetime.datetime.now() - datetime.timedelta(days=1),
         due=datetime.datetime.now() + datetime.timedelta(days=7),
         parameters=UserMoveParams(room_number=self.new_room.number,
                                   level=self.new_room.level,
                                   building_id=self.new_room.building_id),
         creator=self.admin,
     )
コード例 #4
0
 def _build_room(start, end):
     room = RoomFactory()
     time_slot = room.festival.time_slots.last()
     time_slot.start_time = hour(start)
     time_slot.end_time = hour(end)
     time_slot.save()
     return room
コード例 #5
0
def test_agenda_item_admin_get_field_queryset_room(
    hour, request_builder, agenda_item_admin
):
    RoomFactory()
    festival = FestivalFactory()
    room1 = RoomFactory(festival=festival)
    room2 = RoomFactory(festival=festival)
    request = request_builder(room_id=room1.id, popup=1)

    queryset = agenda_item_admin.get_field_queryset(
        db=None, db_field=AgendaItem._meta.get_field("room"), request=request
    )

    assert queryset.count() == 1
    assert room1 in queryset.all()
    assert room2 not in queryset.all()
コード例 #6
0
def test_agenda_item_admin_get_field_queryset_meeting(
    hour, request_builder, agenda_item_admin, proposal_end_time, expected
):
    AgendaItemFactory()
    room = RoomFactory()
    AgendaItemFactory(room__festival=room.festival)
    agenda_item = AgendaItemFactory(
        room=room,
        meeting__publication_time=hour(1),
        meeting__start_time=hour(2),
        meeting__end_time=hour(3),
    )
    proposal = ProposalFactory(waitlist__festival=room.festival)
    proposal.time_slots.add(
        TimeSlot.objects.create(
            festival=room.festival, start_time=hour(0), end_time=hour(proposal_end_time)
        )
    )
    request = request_builder(room_id=room.id, popup=1)

    queryset = agenda_item_admin.get_field_queryset(
        db=None, db_field=AgendaItem._meta.get_field("meeting"), request=request
    )

    assert queryset.count() == expected
    assert agenda_item.meeting in queryset.all()
    if expected == 2:
        assert proposal.meeting in queryset.all()
コード例 #7
0
 def create_factories(self):
     super().create_factories()
     self.room = RoomFactory()
     self.subnet = SubnetFactory()
     self.patch_port = PatchPortFactory(room=self.room, patched=True,
                                        switch_port__switch__host__owner=self.admin)
     # 2. A pool of default vlans so an IP can be found
     self.patch_port.switch_port.default_vlans.append(self.subnet.vlan)
コード例 #8
0
ファイル: test_dormant_user.py プロジェクト: agdsn/pycroft
 def create_factories(self):
     # We want a user who lives somewhere with a membership!
     super().create_factories()
     self.processor = UserFactory.create()
     self.user = UserWithHostFactory.create()
     self.membership = MembershipFactory.create(user=self.user,
                                                group=self.config.member_group)
     self.other_room = RoomFactory.create()
コード例 #9
0
ファイル: test_room_history.py プロジェクト: agdsn/pycroft
    def create_factories(self):
        ConfigFactory.create()

        self.processor = UserFactory.create()

        self.user = UserFactory()
        self.user_no_room = UserFactory(room=None, address=AddressFactory())
        self.room = RoomFactory()
コード例 #10
0
def test_agenda_item_admin_delete(hour, agenda_item_admin, request_builder):
    RoomFactory()
    RoomFactory()
    proposal = ProposalFactory(
        duration_minutes=2, meeting=MeetingFactory(publication_time=hour(-1))
    )
    agenda_item = AgendaItemFactory(meeting=proposal.meeting)
    meeting_id = agenda_item.meeting.id
    room = RoomFactory()
    request = request_builder(room_id=room.id)

    agenda_item_admin.delete_model(request=request, obj=agenda_item)

    meeting = Meeting.objects.get(id=meeting_id)
    assert meeting.start_time is None
    assert meeting.end_time is None
    assert meeting.location == ""
コード例 #11
0
def test_agenda_item_no_hour():
    room = RoomFactory()
    proposal = ProposalFactory(waitlist__festival=room.festival, duration_minutes=8)

    form = AgendaItemForm(data={"meeting": proposal.meeting, "room": room})

    assert form.is_valid() is False
    assert form.errors == {"__all__": ["Missing hour field value"]}
コード例 #12
0
def test_agenda_item_admin_save_model(hour, agenda_item_admin, request_builder):
    RoomFactory()
    RoomFactory()
    proposal = ProposalFactory(
        duration_minutes=2, meeting=MeetingFactory(publication_time=hour(-1))
    )
    room = RoomFactory()
    request = request_builder(room_id=room.id)
    agenda_item = AgendaItemFactory(meeting=proposal.meeting)

    agenda_item_admin.save_model(
        request=request, obj=agenda_item, form=Mock(), change=True
    )

    meeting = Meeting.objects.get(id=agenda_item.meeting.id)
    assert meeting.start_time == hour(2)
    assert meeting.end_time == hour(3)
    assert meeting.location == agenda_item.room.name
コード例 #13
0
ファイル: test_facilities.py プロジェクト: LukasGibeh/pycroft
 def create_factories(self):
     super().create_factories()
     self.user = UserWithMembershipFactory(
         login=self.login,
         password=self.password,
         membership__group=AdminPropertyGroupFactory.create(),
     )
     self.room = RoomFactory()
     self.building = self.room.building
コード例 #14
0
ファイル: test_move.py プロジェクト: agdsn/pycroft
 def create_factories(self):
     # We want a user who lives somewhere with a membership!
     super().create_factories()
     self.user = UserWithHostFactory.create(
         with_membership=True,
         membership__group=self.config.member_group,
     )
     self.old_room = self.user.room
     self.new_room: Room = RoomFactory.create()
コード例 #15
0
ファイル: __init__.py プロジェクト: JuKu/pycroft
 def create_factories(self):
     super().create_factories()
     # To move in a user we need to ensure:
     # 1. default traffic groups for a building
     self.room = RoomFactory(building__with_traffic_group=True)
     self.subnet = SubnetFactory()
     self.patch_port = PatchPortFactory(
         room=self.room,
         patched=True,
         switch_port__switch__host__owner=self.admin)
     # 2. A pool of default vlans so an IP can be found
     self.patch_port.switch_port.default_vlans.append(self.subnet.vlan)
コード例 #16
0
def test_agenda_item_status(kwargs, status):
    festival = FestivalFactory()
    base_kwargs = {
        "helper": HelperFactory(festival=festival),
        "room": RoomFactory(festival=festival),
        "meeting": MeetingFactory(),
        "meeting_confirmed": False,
        "helper_confirmed": False,
    }
    base_kwargs.update(kwargs)

    agenda_item = AgendaItem.objects.create(**base_kwargs)

    assert agenda_item.status == status
コード例 #17
0
def test_agenda_item_admin_get_field_queryset_helper(
    hour, request_builder, agenda_item_admin
):
    HelperFactory()
    festival = FestivalFactory(
        start_proposal=hour(-6),
        end_proposal=hour(-5),
        start_publication=hour(-5),
        start_time=hour(-4),
        end_time=hour(4),
    )
    room = RoomFactory(festival=festival)
    helper2 = HelperFactory(festival=festival)
    helper2.time_slots.add(festival.time_slots.get(start_time__lt=hour()))
    helper = HelperFactory(festival=festival)
    helper.time_slots.add(festival.time_slots.get(start_time__gte=hour()))
    request = request_builder(room_id=room.id, popup=1)

    queryset = agenda_item_admin.get_field_queryset(
        db=None, db_field=AgendaItem._meta.get_field("helper"), request=request
    )

    assert queryset.count() == 1
    assert queryset.last() == helper
コード例 #18
0
 def create_factories(self):
     self.address = AddressFactory()
     self.room = RoomFactory(address=self.address)
コード例 #19
0
 def create_factories(self):
     super().create_factories()
     self.room = RoomFactory.create()
コード例 #20
0
ファイル: test_address.py プロジェクト: agdsn/pycroft
def room(address):
    return RoomFactory(address=address)
コード例 #21
0
 def create_factories(self):
     self.address = AddressFactory()
     self.room = RoomFactory(address=self.address)
     self.user = UserFactory(address=self.address, room=self.room)