Exemplo n.º 1
0
    def test_student_did_not_finalize_and_deadline_is_more_than_1_day_away_do_nothing(
            self):
        """
        test_student_did_not_finalize_and_deadline_is_more_than_1_day_away_do_nothing

        Given:
            - there is a student in INFO sent ("INFO level kiment") state
            - they did not finalize application
            - finalization deadline has not been spent and is in more than 24 hours
        When:
            - clean_info_sent() is called
        Then:
            - do nothing
        """

        self.request_handler.expect_request(
            crmrequestfactory.get_project_list_for_status(
                INFO_SENT_STATUS_NUMBER),
            responses_studentlists.INFO_SENT_ONE_STUDENT)
        self.set_participant_number_expectations()
        self.request_handler.expect_request(
            crmrequestfactory.get_student(FAKE_STUDENT_ID_NUMBER),
            responses_students.FAKE_STUDENT)
        self.set_participant_number_expectations()

        clean_info_sent(self.crm_facade)
    def test_student_is_applied_course_doesnt_exist_raise_task_with_errormessage(
            self):
        """
        test_student_is_applied_course_doesnt_exist_raise_task_with_errormessage

        Given:
            - one beginner student is in applied ("Jelentkezett") state
            - student's course doesn't exist
        When:
            - register_new_applicants() is called
        Then:
            - task is raised on student
        """

        self.request_handler.expect_request(
            crmrequestfactory.get_project_list_for_status(
                NEW_APPLICANT_STATUS_NUMBER),
            responses_studentlists.NEW_APPLICANTS_ONE_STUDENT)
        self.set_participant_number_expectations()

        self.request_handler.expect_request(
            crmrequestfactory.get_student(FAKE_STUDENT_ID_NUMBER),
            responses_students.FAKE_STUDENT_NONEXISTENT_COURSE)

        self.request_handler.expect_request(
            crmrequestfactory.get_course_list_by_course_code(
                NONEXISTENT_COURSE_CODE), responses_general.EMPTY_LIST)

        self.request_handler.expect_request(
            crmrequestfactory.raise_task(crmrequestfactory._,
                                         crmrequestfactory._,
                                         crmrequestfactory._),
            responses_general.XPUT_RESPONSE)

        register_new_applicants(self.crm_facade)
    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_match_expectation_does_not_raise_when_correct_command_comes_exact_match(self):
        """
        test_match_expectation_does_not_raise_when_correct_command_comes_exact_match

        Given:
            - there is an expectation
        When:
            - request_handler.match_expectation() is called with the next expected command in the queue
        Then:
            - no error is raised
        """

        self.request_handler.expect_request(
            crmrequestfactory.get_student(ARBITRARY_STUDENT_ID),
            {u"fake": u"fake"}
        )
        self.request_handler.match_expectation(crmrequestfactory.get_student(ARBITRARY_STUDENT_ID))
    def test_student_is_applied_headcount_is_less_than_the_limit_put_student_to_infosent_update_headcounts_copy_course_data(
            self):
        """
        test_student_is_applied_headcount_is_less_than_the_limit_put_student_to_infosent_update_headcounts_copy_course_data

        Given:
            - one beginner student is in applied ("Jelentkezett") state
            - current headcount is less than maximal headcount. (there is at least one free spot) in the wanted course.)
        When:
            - register_new_applicants() is called
        Then:
            - student's info is filled
            - student is put to INFO sent ("INFO level kiment") state
            - beginner INFO mail is sent
            - application deadline is set
            - headcount is updated
        """

        self.request_handler.expect_request(
            crmrequestfactory.get_project_list_for_status(
                NEW_APPLICANT_STATUS_NUMBER),
            responses_studentlists.NEW_APPLICANTS_ONE_STUDENT)
        self.set_participant_number_expectations()

        self.request_handler.expect_request(
            crmrequestfactory.get_student(FAKE_STUDENT_ID_NUMBER),
            responses_students.FAKE_STUDENT_ZERO_MAILS)

        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"TanfolyamKodja": u"2019-1-Q"}),
            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(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",
                    u"Levelkuldesek": u"Kezd\u0151 INFO lev\u00e9l"
                }), responses_general.XPUT_RESPONSE)
        register_new_applicants(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)
    def test_error_is_raised_when_commands_are_matched_in_wrong_order(self):
        """
        test_error_is_raised_when_commands_are_matched_in_wrong_order

        Given:
            - series of expectations are set
        When:
            - requests are sent in the wrong order
        Then:
            - AssertionError is raised with "Unexpected command"
        """

        self.request_handler.expect_request(crmrequestfactory.get_student(ARBITRARY_STUDENT_ID), RESPONSE_1)
        self.request_handler.expect_request(crmrequestfactory.get_student(ARBITRARY_STUDENT_ID_2), RESPONSE_2)
        self.request_handler.expect_request(crmrequestfactory.get_student(ARBITRARY_STUDENT_ID_3), RESPONSE_3)
        self.request_handler.match_expectation(crmrequestfactory.get_student(ARBITRARY_STUDENT_ID))
        with self.assertRaisesRegexp(AssertionError, "Unexpected command") as cm:
            self.request_handler.match_expectation(crmrequestfactory.get_student(ARBITRARY_STUDENT_ID_3))
    def test_match_expectation_raises_when_other_command_comes(self):
        """
        test_match_expectation_raises_when_other_command_comes

        Given:
            - next expected command in expectation queue is to get student X
        When:
            - request_handler.match_expectation() is called with getting student Y, where X is not equal to T
        Then:
            - AssertionError is raised, with the text starting by "Unexpected command"
        """

        self.request_handler.expect_request(
            crmrequestfactory.get_student(ARBITRARY_STUDENT_ID),
            {u"fake": u"fake"}
        )
        with self.assertRaisesRegexp(AssertionError, "Unexpected command") as cm:
            self.request_handler.match_expectation(crmrequestfactory.get_student(137))
    def test_match_expectation_returns_expected_file_path(self):
        """
        test_match_expectation_returns_expected_file_path

        Given:
            - there is an expectation
        When:
            - request_handler.match_expectation() is called with the next expected command in the queue
        Then:
            - correct preset response is returned
        """

        self.request_handler.expect_request(
            crmrequestfactory.get_student(ARBITRARY_STUDENT_ID),
            {u"fake": u"fake"}
        )
        self.assertEqual(self.request_handler.match_expectation(
            crmrequestfactory.get_student(ARBITRARY_STUDENT_ID)),
            {u"fake": u"fake"}
        )
Exemplo n.º 10
0
 def expect_send_scheduled_mails(self):
     """Sets up expectations to a valid sendscheduledmails workflow"""
     self.request_handler.expect_request(
         crmrequestfactory.get_project_list_for_status(ACTIVE_STATUS_NUMBER),
         responses_studentlists.ACTIVE_ONE_STUDENT
     )
     self.request_handler.expect_request(
         crmrequestfactory.get_project_list_for_status(SPECTATOR_STATUS),
         responses_general.EMPTY_LIST
     )
     self.request_handler.expect_request(
         crmrequestfactory.get_student(FAKE_STUDENT_ID_NUMBER),
         responses_students.FAKE_STUDENT
     )
    def test_match_expectation_raises_if_there_is_no_expectation(self):
        """
        test_match_expectation_raises_if_there_is_no_expectation

        Given:
            - there are no expectations in the queue
        When:
            - request_handler.match_expectation() is called
        Then:
            - AssertionError is raised, with the starting "No more commands were expected, but got"
        """

        with self.assertRaisesRegexp(AssertionError, "No more commands were expected, but got") as cm:
            self.request_handler.match_expectation(crmrequestfactory.get_student(ARBITRARY_STUDENT_ID))
    def test_online_frontend_student_is_applied_headcount_is_not_less_than_the_limit_put_student_to_waiting_list_and_send_mail(
            self):
        """
        test_online_frontend_student_is_applied_headcount_is_not_less_than_the_limit_put_student_to_waiting_list_and_send_mail

        Given:
            - one frontend student is in applied ("Jelentkezett") state
            - current headcount is equal to maximal headcount. (there is no free spot in the wanted course.)
        When:
            - register_new_applicants() is called
        Then:
            - student is put to waiting list ("Varolistan van") state
            - waiting list mail is sent
            - headcount is updated
        """

        self.request_handler.expect_request(
            crmrequestfactory.get_project_list_for_status(
                NEW_APPLICANT_STATUS_NUMBER),
            responses_studentlists.NEW_APPLICANTS_ONE_STUDENT)
        self.set_participant_number_expectations()

        self.request_handler.expect_request(
            crmrequestfactory.get_student(FAKE_STUDENT_ID_NUMBER),
            responses_students.FAKE_STUDENT_ONLINE_FRONTEND_ZERO_MAILS)

        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_ONLINE_FRONTEND_FULL)
        self.request_handler.expect_request(
            crmrequestfactory.set_project_data(
                FAKE_STUDENT_OTHER_ID_NUMBER,
                {u"TanfolyamKodja": u"2019-1-Q"}),
            responses_general.XPUT_RESPONSE)
        self.request_handler.expect_request(
            crmrequestfactory.set_project_data(
                FAKE_STUDENT_OTHER_ID_NUMBER, {
                    u"StatusId": u"2750",
                    crmrequestfactory.CONTAINS: {
                        u"Levelkuldesek": u"V\u00e1r\u00f3lista"
                    }
                }), responses_general.XPUT_RESPONSE)

        register_new_applicants(self.crm_facade)
    def expect_register_new_applicants(self):
        """Sets up expectations to a valid registernewapplicants workflow"""
        self.request_handler.expect_request(
            crmrequestfactory.get_project_list_for_status(NEW_APPLICANT_STATUS_NUMBER),
            responses_studentlists.NEW_APPLICANTS_ONE_STUDENT)
        self.set_participant_number_expectations()

        self.request_handler.expect_request(
            crmrequestfactory.get_student(FAKE_STUDENT_ID_NUMBER),
            responses_students.FAKE_STUDENT)

        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"TanfolyamKodja": u"2019-1-Q"}
            ),
            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(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", u"Levelkuldesek": u"Kezd\u0151 INFO lev\u00e9l"}
            ),
            responses_general.XPUT_RESPONSE
        )
 def expect_handle_waiting_list(self):
     """Sets up expectations to a valid handlewaitinglist workflow"""
     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_2),
         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()
    def test_check_if_satisfied_raises_when_there_is_expectation(self):
        """
        test_check_if_satisfied_raises_when_there_is_expectation

        Given:
            - one expectation is not fulfilled
        When:
            - request_handler.check_is_satisfied() is called
        Then:
            - AssertionError is raised starting with "Not all expectations were fulfilled when test ended."
        """

        self.request_handler.expect_request(
            crmrequestfactory.get_student(ARBITRARY_STUDENT_ID),
            {u"fake": u"fake"}
        )
        with self.assertRaisesRegexp(AssertionError, "Not all expectations were fulfilled when test ended.") as cm:
            self.request_handler.check_is_satisfied()
    def expect_clean_info_sent(self):
        """Sets up expectations to a valid cleaninfosent workflow"""
        self.crm_facade.set_today(datetime.datetime(2019, 1, 22, 12, 0))

        self.request_handler.expect_request(
            crmrequestfactory.get_project_list_for_status(INFO_SENT_STATUS_NUMBER),
            responses_studentlists.INFO_SENT_ONE_STUDENT)
        self.set_participant_number_expectations()
        self.request_handler.expect_request(
            crmrequestfactory.get_student(FAKE_STUDENT_ID_NUMBER),
            responses_students.FAKE_STUDENT)

        self.request_handler.expect_request(
            crmrequestfactory.set_project_data(
                FAKE_STUDENT_ID_NUMBER,
                {u"Levelkuldesek": u"Kezd\u0151 INFO lev\u00e9l, Egy napod van jelentkezni"}
            ),
            responses_general.XPUT_RESPONSE
        )

        self.set_participant_number_expectations()
Exemplo n.º 17
0
    def test_student_did_not_finalize_deadline_has_spent_more_than_24_hours_ago_delete(
            self):
        """
        test_student_did_not_finalize_deadline_has_spent_more_than_24_hours_ago_delete

        Given:
            - there is a student in INFO sent ("INFO level kiment") state
            - they did not finalize application
            - finalization deadline has been spent more than 24 hours ago
        When:
            - clean_info_sent() is called
        Then:
            - "we deleted you" email is sent
            - status of student is set to deleted
        """

        self.crm_facade.set_today(datetime.datetime(2019, 1, 24, 12, 0))

        self.request_handler.expect_request(
            crmrequestfactory.get_project_list_for_status(
                INFO_SENT_STATUS_NUMBER),
            responses_studentlists.INFO_SENT_ONE_STUDENT)
        self.set_participant_number_expectations()
        self.request_handler.expect_request(
            crmrequestfactory.get_student(FAKE_STUDENT_ID_NUMBER),
            responses_students.FAKE_STUDENT)

        self.request_handler.expect_request(
            crmrequestfactory.set_project_data(
                FAKE_STUDENT_ID_NUMBER, {
                    u"StatusId":
                    u"2782",
                    u"Levelkuldesek":
                    u"Kezd\u0151 INFO lev\u00e9l, Egy napod van jelentkezni, Ma kell jelentkezni, Toroltunk"
                }), responses_general.XPUT_RESPONSE)

        self.set_participant_number_expectations()

        clean_info_sent(self.crm_facade)
Exemplo n.º 18
0
    def test_student_did_not_finalize_deadline_has_spent_but_not_more_than_24_hours_ago_send_reminder_raise_task(
            self):
        """
        test_student_did_not_finalize_deadline_has_spent_but_not_more_than_24_hours_ago_send_reminder_raise_task

        Given:
            - there is a student in INFO sent ("INFO level kiment") state
            - they did not finalize application
            - finalization deadline has been spent, but is within less than 24 hours
        When:
            - clean_info_sent() is called
        Then:
            - 2nd reminder email ("Egy napod van jelentkezni") is sent
            - task is raised on the student
        """

        self.crm_facade.set_today(datetime.datetime(2019, 1, 23, 12, 0))

        self.request_handler.expect_request(
            crmrequestfactory.get_project_list_for_status(
                INFO_SENT_STATUS_NUMBER),
            responses_studentlists.INFO_SENT_ONE_STUDENT)
        self.set_participant_number_expectations()
        self.request_handler.expect_request(
            crmrequestfactory.get_student(FAKE_STUDENT_ID_NUMBER),
            responses_students.FAKE_STUDENT)

        self.request_handler.expect_request(
            crmrequestfactory.set_project_data(
                FAKE_STUDENT_ID_NUMBER, {
                    u"Levelkuldesek":
                    u"Kezd\u0151 INFO lev\u00e9l, Egy napod van jelentkezni, Ma kell jelentkezni"
                }), responses_general.XPUT_RESPONSE)

        self.set_participant_number_expectations()

        clean_info_sent(self.crm_facade)
    def test_expectations_are_matched_in_correct_order(self):
        """
        test_expectations_are_matched_in_correct_order

        Given:
            - series of expectations are set
        When:
            - requests are sent in the same order
            - check_if_ssatisfied is called
        Then:
            - no error is raised
        """

        self.request_handler.expect_request(crmrequestfactory.get_student(ARBITRARY_STUDENT_ID), RESPONSE_1)
        self.request_handler.expect_request(crmrequestfactory.get_student(ARBITRARY_STUDENT_ID_2), RESPONSE_2)
        self.request_handler.expect_request(crmrequestfactory.get_student(ARBITRARY_STUDENT_ID_3), RESPONSE_3)
        self.request_handler.match_expectation(crmrequestfactory.get_student(ARBITRARY_STUDENT_ID))
        self.request_handler.match_expectation(crmrequestfactory.get_student(ARBITRARY_STUDENT_ID_2))
        self.request_handler.match_expectation(crmrequestfactory.get_student(ARBITRARY_STUDENT_ID_3))
        self.request_handler.check_is_satisfied()
    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)