def test_there_is_one_student_on_waiting_list_but_there_are_no_free_places_do_nothing(
            self):
        """
        test_there_is_one_student_on_waiting_list_but_there_are_no_free_places_do_nothing

        Given:
            - there is a student in waiting list
            - there is no free spot on the wanted course
        When:
            - handle_waiting_list() is called
        Then:
            - do nothing
        """

        self.request_handler.expect_request(
            crmrequestfactory.get_project_list_for_status(
                WAITING_LIST_STATUS_NUMBER),
            responses_studentlists.WAITING_LIST_ONE_STUDENT)
        self.request_handler.expect_request(
            crmrequestfactory.get_student(FAKE_STUDENT_ID_NUMBER),
            responses_students.FAKE_STUDENT)
        self.set_participant_number_expectations()
        self.request_handler.expect_request(
            crmrequestfactory.get_course_list_by_course_code(
                FAKE_COURSE_COURSE_CODE),
            responses_courselists.COURSE_LIST_FOR_COURSE_CODE)
        self.request_handler.expect_request(
            crmrequestfactory.get_course(FAKE_COURSE_ID_NUMBER),
            responses_courses.COURSE_2019_1_Q_FULL)
        self.set_participant_number_expectations()
        handle_waiting_list(self.crm_facade)
    def test_there_is_one_student_on_waiting_list_and_there_is_one_free_place_put_student_to_info_sent(
            self):
        """
        test_there_is_one_student_on_waiting_list_and_there_is_one_free_place_put_student_to_info_sent

        Given:
            - there is a student in waiting list
            - there is one free spot on the wanted course
        When:
            - handle_waiting_list() is called
        Then:
            - INFO email is sent
            - "A spot freed up" email is sent
            - change student's status to "INFO sent"
        """

        self.request_handler.expect_request(
            crmrequestfactory.get_project_list_for_status(
                WAITING_LIST_STATUS_NUMBER),
            responses_studentlists.WAITING_LIST_ONE_STUDENT)
        self.request_handler.expect_request(
            crmrequestfactory.get_student(FAKE_STUDENT_ID_NUMBER),
            responses_students.FAKE_STUDENT)
        self.set_participant_number_expectations()
        self.request_handler.expect_request(
            crmrequestfactory.get_course_list_by_course_code(
                FAKE_COURSE_COURSE_CODE),
            responses_courselists.COURSE_LIST_FOR_COURSE_CODE)
        self.request_handler.expect_request(
            crmrequestfactory.get_course(FAKE_COURSE_ID_NUMBER),
            responses_courses.COURSE_2019_1_Q_ONE_PLACE_FREE)

        self.request_handler.expect_request(
            crmrequestfactory.set_project_data(
                FAKE_STUDENT_OTHER_ID_NUMBER,
                {u"Levelkuldesek": u"Felszabadult egy hely"}),
            responses_general.XPUT_RESPONSE)
        self.request_handler.expect_request(
            crmrequestfactory.get_location_list_by_location_name(
                LOCATION_NAME),
            responses_locationlists.LOCATION_LIST_FOR_LOCATION_NAME)
        self.request_handler.expect_request(
            crmrequestfactory.get_location(FAKE_LOCATION_ID),
            responses_locations.PANNON_KINCSTAR)
        self.request_handler.expect_request(
            crmrequestfactory.set_project_data(FAKE_STUDENT_OTHER_ID_NUMBER,
                                               crmrequestfactory._),
            responses_general.XPUT_RESPONSE)
        self.request_handler.expect_request(
            crmrequestfactory.set_project_data(
                FAKE_STUDENT_OTHER_ID_NUMBER, {
                    "StatusId": "2781",
                    crmrequestfactory.CONTAINS: {
                        u"Levelkuldesek": u"Kezd\u0151 INFO lev\u00e9l"
                    }
                }), responses_general.XPUT_RESPONSE)
        self.set_participant_number_expectations()
        handle_waiting_list(self.crm_facade)
Example #3
0
def run(crm_facade):
    """
    Calling this function will execute 3 of the functionalities:
        - clean_info_sent
        - handle_waiting_list
        - register_new_applicants

    For more details, see the documentation of those.

    This one is intended to be run frequently, for example once in every 10-15 minutes to make initial feedback faster.
    Please note that other factors also influence how fast the student gets their first reply.

    :param crm_facade: the CrmFacade instance this script is using for communication with a MiniCRM system.
    :type crm_facade: CrmFacade

    :return: None
    """

    clean_info_sent(crm_facade)
    handle_waiting_list(crm_facade)
    register_new_applicants(crm_facade)
    trace("QUICK SCRIPT EXITED")
    def test_there_are_5_students_on_the_waiting_list_and_there_are_two_free_places_put_the_earliest_two_to_info_sent(
            self):
        """
        test_there_are_5_students_on_the_waiting_list_and_there_are_two_free_places_put_the_earliest_two_to_info_sent

        Given:
            - there are 5 students in waiting list
            - there are two free spots on the wanted course
        When:
            - handle_waiting_list() is called
        Then:
            - for the two who applied the earliest:
                - INFO email is sent
                - "A spot freed up" email is sent
                - change student's status to "INFO sent"
            - for the other student:
                - do nothing
        """

        self.request_handler.expect_request(
            crmrequestfactory.get_project_list_for_status(
                WAITING_LIST_STATUS_NUMBER),
            responses_studentlists.WAITING_LIST_FIVE_STUDENTS)
        self.request_handler.expect_request(
            crmrequestfactory.get_student(FAKE_STUDENT_FIFTH_ID_NUMBER),
            responses_students.FAKE_STUDENT)
        self.request_handler.expect_request(
            crmrequestfactory.get_student(FAKE_STUDENT_ID_NUMBER),
            responses_students.FAKE_STUDENT_APPLIED_LATER)
        self.request_handler.expect_request(
            crmrequestfactory.get_student(FAKE_STUDENT_SIXTH_ID_NUMBER),
            responses_students.FAKE_STUDENT_APPLIED_LATER)
        self.request_handler.expect_request(
            crmrequestfactory.get_student(
                FAKE_STUDENT_APPLIED_LATER_ID_NUMBER),
            responses_students.FAKE_STUDENT_4TH_APPLIED)
        self.request_handler.expect_request(
            crmrequestfactory.get_student(FAKE_STUDENT_FOURTH_ID_NUMBER),
            responses_students.FAKE_STUDENT_5TH_APPLIED)

        self.set_participant_number_expectations()
        self.request_handler.expect_request(
            crmrequestfactory.get_course_list_by_course_code(
                FAKE_COURSE_COURSE_CODE),
            responses_courselists.COURSE_LIST_FOR_COURSE_CODE)
        self.request_handler.expect_request(
            crmrequestfactory.get_course(FAKE_COURSE_ID_NUMBER),
            responses_courses.COURSE_2019_1_Q_ONE_PLACE_FREE)

        self.request_handler.expect_request(
            crmrequestfactory.set_project_data(
                FAKE_STUDENT_OTHER_ID_NUMBER,
                {u"Levelkuldesek": u"Felszabadult egy hely"}),
            responses_general.XPUT_RESPONSE)

        self.request_handler.expect_request(
            crmrequestfactory.get_location_list_by_location_name(
                LOCATION_NAME),
            responses_locationlists.LOCATION_LIST_FOR_LOCATION_NAME)
        self.request_handler.expect_request(
            crmrequestfactory.get_location(FAKE_LOCATION_ID),
            responses_locations.PANNON_KINCSTAR)
        self.request_handler.expect_request(
            crmrequestfactory.set_project_data(FAKE_STUDENT_OTHER_ID_NUMBER,
                                               crmrequestfactory._),
            responses_general.XPUT_RESPONSE)
        self.request_handler.expect_request(
            crmrequestfactory.set_project_data(
                FAKE_STUDENT_OTHER_ID_NUMBER, {
                    u"StatusId": u"2781",
                    crmrequestfactory.CONTAINS: {
                        u"Levelkuldesek": u"Kezd\u0151 INFO lev\u00e9l"
                    }
                }), responses_general.XPUT_RESPONSE)

        self.set_participant_number_expectations()
        self.request_handler.expect_request(
            crmrequestfactory.get_course_list_by_course_code(
                FAKE_COURSE_COURSE_CODE),
            responses_courselists.COURSE_LIST_FOR_COURSE_CODE)
        self.request_handler.expect_request(
            crmrequestfactory.get_course(FAKE_COURSE_ID_NUMBER),
            responses_courses.COURSE_2019_1_Q_ONE_PLACE_FREE)

        self.request_handler.expect_request(
            crmrequestfactory.set_project_data(
                FAKE_STUDENT_THIRD_ID_NUMBER,
                {u"Levelkuldesek": u"Felszabadult egy hely"}),
            responses_general.XPUT_RESPONSE)
        self.request_handler.expect_request(
            crmrequestfactory.get_location_list_by_location_name(
                LOCATION_NAME),
            responses_locationlists.LOCATION_LIST_FOR_LOCATION_NAME)
        self.request_handler.expect_request(
            crmrequestfactory.get_location(FAKE_LOCATION_ID),
            responses_locations.PANNON_KINCSTAR)
        self.request_handler.expect_request(
            crmrequestfactory.set_project_data(FAKE_STUDENT_THIRD_ID_NUMBER,
                                               crmrequestfactory._),
            responses_general.XPUT_RESPONSE)
        self.request_handler.expect_request(
            crmrequestfactory.set_project_data(
                FAKE_STUDENT_THIRD_ID_NUMBER, {
                    u"StatusId": u"2781",
                    crmrequestfactory.CONTAINS: {
                        u"Levelkuldesek": u"Kezd\u0151 INFO lev\u00e9l"
                    }
                }), responses_general.XPUT_RESPONSE)

        self.set_participant_number_expectations()
        self.request_handler.expect_request(
            crmrequestfactory.get_course_list_by_course_code(
                FAKE_COURSE_COURSE_CODE),
            responses_courselists.COURSE_LIST_FOR_COURSE_CODE)
        self.request_handler.expect_request(
            crmrequestfactory.get_course(FAKE_COURSE_ID_NUMBER),
            responses_courses.COURSE_2019_1_Q_FULL)
        self.set_participant_number_expectations()
        self.request_handler.expect_request(
            crmrequestfactory.get_course_list_by_course_code(
                FAKE_COURSE_COURSE_CODE),
            responses_courselists.COURSE_LIST_FOR_COURSE_CODE)
        self.request_handler.expect_request(
            crmrequestfactory.get_course(FAKE_COURSE_ID_NUMBER),
            responses_courses.COURSE_2019_1_Q_FULL)
        self.set_participant_number_expectations()
        self.request_handler.expect_request(
            crmrequestfactory.get_course_list_by_course_code(
                FAKE_COURSE_COURSE_CODE),
            responses_courselists.COURSE_LIST_FOR_COURSE_CODE)
        self.request_handler.expect_request(
            crmrequestfactory.get_course(FAKE_COURSE_ID_NUMBER),
            responses_courses.COURSE_2019_1_Q_FULL)

        self.set_participant_number_expectations()
        handle_waiting_list(self.crm_facade)
    def test_student_gets_into_chosen_course_even_if_available_courses_changed(
            self):
        """
        test_student_gets_into_chosen_course_even_if_available_courses_changed

        Given:
            - there is a student in waiting list
            - MelyikTanfolyamErdekli and TanfolyamKodja are different
            - there is one free spot on the wanted course
        When:
            - handle_waiting_list() is called
        Then:
            - INFO email is sent
            - "A spot freed up" email is sent
            - change student's status to "INFO sent"
            - TanfolyamKodja is considered
        """

        self.request_handler.expect_request(
            crmrequestfactory.get_project_list_for_status(
                WAITING_LIST_STATUS_NUMBER),
            responses_studentlists.WAITING_LIST_ONE_STUDENT)
        self.request_handler.expect_request(
            crmrequestfactory.get_student(FAKE_STUDENT_ID_NUMBER),
            responses_students.
            FAKE_STUDENT_COURSE_CODE_AND_APPLIED_TO_ARE_DIFFERENT)
        self.set_participant_number_expectations()
        self.request_handler.expect_request(
            crmrequestfactory.get_course_list_by_course_code(
                FAKE_COURSE_COURSE_CODE),
            responses_courselists.COURSE_LIST_FOR_COURSE_CODE)
        self.request_handler.expect_request(
            crmrequestfactory.get_course(FAKE_COURSE_ID_NUMBER),
            responses_courses.COURSE_2019_1_Q_ONE_PLACE_FREE)

        self.request_handler.expect_request(
            crmrequestfactory.set_project_data(
                FAKE_STUDENT_OTHER_ID_NUMBER,
                {u"Levelkuldesek": u"Felszabadult egy hely"}),
            responses_general.XPUT_RESPONSE)
        self.request_handler.expect_request(
            crmrequestfactory.get_location_list_by_location_name(
                LOCATION_NAME),
            responses_locationlists.LOCATION_LIST_FOR_LOCATION_NAME)
        self.request_handler.expect_request(
            crmrequestfactory.get_location(FAKE_LOCATION_ID),
            responses_locations.PANNON_KINCSTAR)
        self.request_handler.expect_request(
            crmrequestfactory.set_project_data(FAKE_STUDENT_OTHER_ID_NUMBER,
                                               crmrequestfactory._),
            responses_general.XPUT_RESPONSE)
        self.request_handler.expect_request(
            crmrequestfactory.set_project_data(
                FAKE_STUDENT_OTHER_ID_NUMBER, {
                    "StatusId": "2781",
                    crmrequestfactory.CONTAINS: {
                        u"Levelkuldesek": u"Kezd\u0151 INFO lev\u00e9l"
                    }
                }), responses_general.XPUT_RESPONSE)

        self.set_participant_number_expectations()
        handle_waiting_list(self.crm_facade)