def test_create_event_form_as_admin(admin_user): """An admin should be able to create an event form.""" form = FormFactory.build() event = EventFactory() client = get_api_client(user=admin_user) url = _get_forms_url() response = client.post(url, _get_event_form_post_data(form, event)) assert response.status_code == status.HTTP_201_CREATED
def test_bump_user_without_event_priorities(): """Test that users are not swapped when event does not have any priorities.""" event = EventFactory(limit=1) registration_not_on_waiting_list = RegistrationFactory(event=event, user=UserFactory()) registration_on_waiting_list = RegistrationFactory(event=event, user=UserFactory()) assert not registration_not_on_waiting_list.is_on_wait assert registration_on_waiting_list.is_on_wait
def test_retrieve_evaluation_event_form_as_member_when_has_not_attended_event( member): """A member should not be able to retrieve an event evaluation form if they have not attended the event.""" event = EventFactory(limit=1) registration = RegistrationFactory(user=member, event=event, is_on_wait=False, has_attended=False) form = EventFormFactory(event=registration.event, type=EventFormType.EVALUATION) client = get_api_client(user=member) url = _get_form_detail_url(form) response = client.get(url) assert response.status_code == status.HTTP_403_FORBIDDEN
def test_delete_registration_when_no_users_on_wait_are_in_a_priority_pool_bumps_first_registration_on_wait( ): """ Test that the first registration on wait is moved up when a registration is deleted and no registered users are prioritized. """ event = EventFactory(limit=1) priority = PriorityFactory(user_study=UserStudy.DATAING, user_class=UserClass.FIRST) event.registration_priorities.add(priority) user_not_in_priority_pool = UserFactory(user_study=UserStudy.DIGFOR.value, user_class=UserClass.SECOND.value) registration_to_delete = RegistrationFactory(event=event) registration_on_wait = RegistrationFactory(event=event, user=user_not_in_priority_pool) registration_to_delete.delete() registration_on_wait.refresh_from_db() assert not registration_on_wait.is_on_wait
def event(): return EventFactory()
def event_with_registrations_and_priority(priority): event = EventFactory(limit=1) event.registration_priorities.add(priority) return event
def event(priority): event = EventFactory(limit=1) event.registration_priorities.add(priority) return event