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
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
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, )
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
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()
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()
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)
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()
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()
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 == ""
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"]}
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
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
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()
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)
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
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
def create_factories(self): self.address = AddressFactory() self.room = RoomFactory(address=self.address)
def create_factories(self): super().create_factories() self.room = RoomFactory.create()
def room(address): return RoomFactory(address=address)
def create_factories(self): self.address = AddressFactory() self.room = RoomFactory(address=self.address) self.user = UserFactory(address=self.address, room=self.room)