def test_there_are_2_info_sent_3_active_2_waiting_list_1_did_not_answer_1_spectator_count_is_set_to_5(self): """ Given: - there is one course in Application Open ("Jelentkezes nyitva") state - there are 2 info sent students registered to this course - there are 3 active students registered to this course - there are 2 waiting list students registered to this course - there is 1 did not answer student registered to this course - there is 1 spectator student registered to this course When: - update_headcounts() is called Then: - headcount is updated to 5 """ self.request_handler.expect_request( crmrequestfactory.get_project_list_for_status(APPLICATION_OPEN_STATUS_NUMBER), responses_courselists.LIST_OF_OPEN_COURSES_2753_ONE_COURSE_OPEN) self.request_handler.expect_request( crmrequestfactory.get_course(FAKE_COURSE_ID_NUMBER), responses_courses.COURSE_2019_1_Q_0_STUDENTS) self.request_handler.expect_request( crmrequestfactory.get_student_list_by_course_code(FAKE_COURSE_COURSE_CODE), responses_studentlists.COMPLEX_LIST) self.request_handler.expect_request( crmrequestfactory.set_project_data(FAKE_COURSE_ID_NUMBER, {u"AktualisLetszam": 5}), responses_general.XPUT_RESPONSE) self.crm_facade.update_headcounts()
def test_headcount_is_0_when_there_is_1_info_sent_student_and_noone_else_count_is_set_to_1(self): """ Given: - there is one course in Application Open ("Jelentkezes nyitva") state - current headcount is 0 - there is 1 info sent student registered to the course When: - update_headcounts() is called Then: - headcount is updated to 1 """ self.request_handler.expect_request( crmrequestfactory.get_project_list_for_status(APPLICATION_OPEN_STATUS_NUMBER), responses_courselists.LIST_OF_OPEN_COURSES_2753_ONE_COURSE_OPEN) self.request_handler.expect_request( crmrequestfactory.get_course(FAKE_COURSE_ID_NUMBER), responses_courses.COURSE_2019_1_Q_0_STUDENTS) self.request_handler.expect_request( crmrequestfactory.get_student_list_by_course_code(FAKE_COURSE_COURSE_CODE), responses_studentlists.INFO_SENT_ONE_STUDENT) self.request_handler.expect_request( crmrequestfactory.set_project_data(FAKE_COURSE_ID_NUMBER, {u"AktualisLetszam": 1}), responses_general.XPUT_RESPONSE) self.crm_facade.update_headcounts()
def test_headcount_is_2_when_there_are_no_students_for_this_course_count_is_set_to_0(self): """ Given: - there is one course in Application Open ("Jelentkezes nyitva") state - current headcount is 2 - no students applied to this course When: - update_headcounts() is called Then: - headcount is updated to 0 """ self.request_handler.expect_request( crmrequestfactory.get_project_list_for_status(APPLICATION_OPEN_STATUS_NUMBER), responses_courselists.LIST_OF_OPEN_COURSES_2753_ONE_COURSE_OPEN) self.request_handler.expect_request( crmrequestfactory.get_course(FAKE_COURSE_ID_NUMBER), responses_courses.COURSE_2019_1_Q_2_STUDENTS) self.request_handler.expect_request( crmrequestfactory.get_student_list_by_course_code(FAKE_COURSE_COURSE_CODE), responses_general.EMPTY_LIST) self.request_handler.expect_request( crmrequestfactory.set_project_data(FAKE_COURSE_ID_NUMBER, {u"AktualisLetszam": 0}), responses_general.XPUT_RESPONSE) self.crm_facade.update_headcounts()
def set_participant_number_expectations(self): """ Sets expectations for the update_headcounts() method of CrmFacade. CrmFacade's update_headcounts() is a commonly used method, which creates a typical pattern of API requests. This pattern has to be expected again and again in every test which uses the update_headcounts() method, maybe multiple times in a use case. This method provides a single line to set those expectations, and also logically group these expectations, and make the code easier to read. """ self.request_handler.expect_request( crmrequestfactory.get_project_list_for_status( COURSE_OPEN_STATUS_NUMBER), responses_courselists.LIST_OF_OPEN_COURSES_2753_ONE_COURSE_OPEN) self.request_handler.expect_request( crmrequestfactory.get_project(FAKE_COURSE_ID_NUMBER), responses_courses.COURSE_2019_1_Q) self.request_handler.expect_request( crmrequestfactory.get_student_list_by_course_code( FAKE_COURSE_COURSE_CODE), responses_studentlists.COURSE_CODE_IS_2019_1_Q) self.request_handler.expect_request( crmrequestfactory.set_project_data(FAKE_COURSE_ID_NUMBER, {u"AktualisLetszam": 6}), responses_general.XPUT_RESPONSE)
def test_there_is_1_student_in_unsubscribed_is_set_to_0(self): """ Given: - there is one course in Application Open ("Jelentkezes nyitva") state - there is 1 student in Unsubscribed ("Leiratkozott") state When: - update_headcounts() is called Then: - headcount is updated to 0 """ self.request_handler.expect_request( crmrequestfactory.get_project_list_for_status(APPLICATION_OPEN_STATUS_NUMBER), responses_courselists.LIST_OF_OPEN_COURSES_2753_ONE_COURSE_OPEN) self.request_handler.expect_request( crmrequestfactory.get_course(FAKE_COURSE_ID_NUMBER), responses_courses.COURSE_2019_1_Q_0_STUDENTS) self.request_handler.expect_request( crmrequestfactory.get_student_list_by_course_code(FAKE_COURSE_COURSE_CODE), responses_studentlists.UNSUBSCRIBED_ONE_STUDENT) self.request_handler.expect_request( crmrequestfactory.set_project_data(FAKE_COURSE_ID_NUMBER, {u"AktualisLetszam": 0}), responses_general.XPUT_RESPONSE) self.crm_facade.update_headcounts()
def test_there_is_1_student_in_did_not_answer_count_is_set_to_0(self): """ Given: - there is one course in Application Open ("Jelentkezes nyitva") state - there is 1 student in "Did not finalize" ("Nem jelzett vissza") state When: - update_headcounts() is called Then: - headcount is updated to 0 """ self.request_handler.expect_request( crmrequestfactory.get_project_list_for_status(APPLICATION_OPEN_STATUS_NUMBER), responses_courselists.LIST_OF_OPEN_COURSES_2753_ONE_COURSE_OPEN) self.request_handler.expect_request( crmrequestfactory.get_course(FAKE_COURSE_ID_NUMBER), responses_courses.COURSE_2019_1_Q_0_STUDENTS) self.request_handler.expect_request( crmrequestfactory.get_student_list_by_course_code(FAKE_COURSE_COURSE_CODE), responses_studentlists.DID_NOT_ANSWER_ONE_STUDENT) self.request_handler.expect_request( crmrequestfactory.set_project_data(FAKE_COURSE_ID_NUMBER, {u"AktualisLetszam": 0}), responses_general.XPUT_RESPONSE) self.crm_facade.update_headcounts()
def test_correct_list_of_students_is_updated_with_correct_data(self): """ Correct list is updated by update_course_dates_for_all_students_for_that_course with correct data. Given: - 2 students applied to given course (regardless of their states) When: - update_course_dates_for_all_students_for_that_course is called Then: - both students are updated with the correct data (dates, dayoffs and date descriptions) """ course_code = "2019-1-Q" course_id = 1164 first_student_id = 2790 second_student_id = 2796 expected_data_to_update = { "N1Alkalom": "2019-01-28 23:59:59", "N2Alkalom2": "2019-02-04 23:59:59", "N3Alkalom2": "2019-02-11 23:59:59", "N4Alkalom2": "2019-02-18 23:59:59", "N5Alkalom2": "2019-02-25 23:59:59", "N6Alkalom2": "2019-03-04 23:59:59", "N7Alkalom2": "2019-03-18 23:59:59", "N8Alkalom2": "2019-03-25 23:59:59", "N9Alkalom2": "2019-04-01 23:59:59", "N10Alkalom2": "2019-04-08 23:59:59", "N2SzunetOpcionalis2": "2019-03-11 23:59:59", "N2SzunetOpcionalis3": "", "N3SzunetOpcionalis2": "", "Datumleirasok": " - 2019-01-28\n - 2019-02-04\n - 2019-02-11\n - 2019-02-18\n - 2019-02-25\n - 2019-03-04\n - 2019-03-11 - szünet\n - 2019-03-18\n - 2019-03-25\n - 2019-04-01\n - 2019-04-08", } self.request_handler.expect_request( crmrequestfactory.get_course_list_by_course_code(course_code), responses_courselists.COURSE_LIST_FOR_COURSE_CODE) self.request_handler.expect_request( crmrequestfactory.get_course(course_id), responses_courses.COURSE_2019_1_Q) self.request_handler.expect_request( crmrequestfactory.get_student_list_by_course_code(course_code), responses_studentlists.WAITING_LIST_TWO_STUDENTS) self.request_handler.expect_request( crmrequestfactory.set_project_data(first_student_id, expected_data_to_update), responses_general.XPUT_RESPONSE) self.request_handler.expect_request( crmrequestfactory.set_project_data(second_student_id, expected_data_to_update), responses_general.XPUT_RESPONSE) update_course_dates_for_all_students_for_that_course( self.crm_facade, course_code)