def test_should_send_message_if_invalid_response_received(self): schedule_script_now(grp=self.head_teacher_group.name,slug=self.teachers_weekly_script.slug) check_progress(self.teachers_weekly_script) fake_incoming("dummy response",self.emis_reporter1) check_progress(self.teachers_weekly_script) expected = 'The answer you have provided is not in the correct format. Use figures like 3 to answer the question' self.assertTrue(expected in Message.objects.filter(direction='O',connection=self.emis_reporter1.connection_set.all()[0]).values_list('text',flat=True))
def test_should_reject_numeric_data_thats_implausibly_large(self): schedule_script_now(self.head_teacher_group.name, slug=self.teachers_weekly_script.slug) check_progress(self.teachers_weekly_script) fake_incoming("20 boys", self.emis_reporter1) fake_incoming("5001 boys", self.emis_reporter2) result = get_numeric_data([self.p3_boys_absent_poll], [self.kampala_district], self.term_range) self.assertEqual(20, result)
def test_should_return_location_numeric_data_given_a_poll_and_time_range(self): schedule_script_now(self.head_teacher_group.name, slug=self.teachers_weekly_script.slug) check_progress(self.teachers_weekly_script) fake_incoming("20 boys", self.emis_reporter1) fake_incoming("10 boys", self.emis_reporter2) result = get_numeric_data_for_location([self.p3_boys_absent_poll], [self.kampala_district], self.term_range) self.assertEqual(30, result[self.kampala_district.id])
def test_messages_are_handled_in_education_app(self): schedule_script_now(grp=self.head_teacher_group.name,slug=self.teachers_weekly_script.slug) check_progress(self.teachers_weekly_script) with patch('script.app.App.handle') as mock_method: fake_incoming("dummy response" ,self.emis_reporter1) assert not mock_method.called
def test_should_return_10_given_reporter_responds_10_to_boys_enrollment_poll(self): schedule_script_now(grp=self.head_teacher_group.name, slug = self.head_teachers_termly_script.slug) check_progress(self.head_teachers_termly_script) fake_incoming("10", self.emis_reporter1) enrolled_boys = get_enrolled_pupils(self.emis_reporter1.connection_set.all()[0], self.p6_boys_enroll_poll.name, settings.SCHOOL_TERM_START, settings.SCHOOL_TERM_END) self.assertEqual(10, enrolled_boys)
def test_gendered_text_responses(self): params = { "description": "A response value for a Poll with expected text responses", "datatype": "text", "enum_group": None, "required": False, "type": None, "slug": "poll_text_value", "name": "Text" } Attribute.objects.get_or_create(**params) schedule_script_now(self.smc_group.name, slug=self.head_teacher_weekly_script.slug) check_progress(self.head_teacher_weekly_script) fake_incoming("yes", self.emis_reporter3) male_yes_result = gendered_text_responses(self.term_range, [self.kampala_district], ['Yes', 'YES', 'yes'], 'M') male_no_result = gendered_text_responses(self.term_range, [self.kampala_district], ['No', 'NO', 'no'], 'M') female_yes_result = gendered_text_responses(self.term_range, [self.kampala_district], ['Yes', 'YES', 'yes'], 'F') female_no_result = gendered_text_responses(self.term_range, [self.kampala_district], ['No', 'NO', 'no'], 'F') self.assertEqual(1, male_yes_result) self.assertEqual(0, male_no_result) self.assertEqual(0, female_yes_result) self.assertEqual(0, female_no_result)
def test_should_check_increment_in_outgoing_msg_count_on_all_responses_received(self): schedule_script_now(grp=self.head_teacher_group.name,slug = self.teachers_weekly_script.slug) check_progress(self.teachers_weekly_script) fake_incoming("4",self.emis_reporter1)#response to p3 boys poll check_progress(self.teachers_weekly_script) self.assertEqual(2,Message.objects.filter(direction='O',connection=self.emis_reporter1.connection_set.all()[0]).count()) fake_incoming("3",self.emis_reporter1)#response to p3 girls poll check_progress(self.teachers_weekly_script) # self.assertEqual(3,Message.objects.filter(direction='O',connection=self.emis_reporter1.connection_set.all()[0]).count()) self.assertEqual(2,Message.objects.filter(direction='O',connection=self.emis_reporter1.connection_set.all()[0]).count())#pausing feedbacks
def test_should_send_feedbacks_to_smc(self): schedule_script_now(grp= self.smc_group.name, slug=self.smc_weekly_script.slug) check_progress(self.smc_weekly_script) fake_incoming("yes", self.emis_reporter3) check_progress(self.smc_weekly_script) # self.assertEqual(2,Message.objects.filter(direction='O',connection=self.emis_reporter3.connection_set.all()[0]).count()) self.assertEqual(1,Message.objects.filter(direction='O',connection=self.emis_reporter3.connection_set.all()[0]).count())#paisong feedback expected='Thank you for your report. Please continue to visit your school and report on what is happening.' # self.assertTrue(expected in Message.objects.filter(direction='O',connection=self.emis_reporter3.connection_set.all()[0]).values_list('text',flat=True)) self.assertFalse(expected in Message.objects.filter(direction='O',connection=self.emis_reporter3.connection_set.all()[0]).values_list('text',flat=True))#pausing feedback
def test_should_resend_poll_question_on_invalid_responses(self): schedule_script_now(grp=self.head_teacher_group.name,slug=self.teachers_weekly_script.slug) check_progress(self.teachers_weekly_script) fake_incoming("invalid response",self.emis_reporter1) check_progress(self.teachers_weekly_script) self.assertEqual(3,Message.objects.filter(direction='O',connection=self.emis_reporter1.connection_set.all()[0]).count()) outgoing_messages = list(Message.objects.filter(direction='O', connection=self.emis_reporter1.connection_set.all()[0]).values_list( 'text', flat=True)) self.assertEqual(2,outgoing_messages.count(self.p3_boys_absent_poll.question))
def test_should_not_send_absenteeism_calculation_if_partial_responses_sent(self): schedule_script_now(grp=self.head_teacher_group.name,slug=self.teachers_weekly_script.slug) check_progress(self.teachers_weekly_script) fake_incoming("3",self.emis_reporter1) check_progress(self.teachers_weekly_script) time.sleep(3) check_progress(self.teachers_weekly_script) expected = 'Thankyou p3 Teacher, Attendance for boys have been improved by 0percent" \ "Attendance for girls have been improved by 0percent' self.assertFalse(expected in Message.objects.filter(direction='O',connection=self.emis_reporter1.connection_set.all()[0]).values_list('text',flat=True))
def test_aggregated_report_has_school_id(self): schedule_script_now(self.head_teacher_group.name, slug=self.head_teachers_termly_script.slug) check_progress(self.head_teachers_termly_script) fake_incoming("10 boys", self.emis_reporter1) config_list = get_polls_for_keyword('all') collective_result, chart_results_model, school_percent,tooltip = \ get_aggregated_report_for_district([self.kampala_district], [self.term_range], config_list) self.assertEqual(self.kampala_school_lubaga.id, collective_result['UMHS Lubaga']['id'])
def test_should_return_10_boys_and_0_girls_given_reporter_responds_10boys_but_no_girls_to_enrollment_poll(self): schedule_script_now(grp = self.head_teacher_group.name, slug = self.head_teachers_termly_script.slug) check_progress(self.head_teachers_termly_script) fake_incoming("10", self.emis_reporter1) check_progress(self.head_teachers_termly_script) time.sleep(2) check_progress(self.head_teachers_termly_script) boys, girls = get_enrolled_boys_and_girls(self.emis_reporter1.connection_set.all()[0], self.p3_boys_enroll_poll.name, self.p3_girls_enroll_poll.name) self.assertEqual(10, boys) self.assertEqual(0, girls)
def test_should_send_alert_messages_on_partial_responses(self): schedule_script_now(grp=self.head_teacher_group.name,slug=self.teachers_weekly_script.slug) check_progress(self.teachers_weekly_script) fake_incoming("3",self.emis_reporter1) check_progress(self.teachers_weekly_script) time.sleep(3) check_progress(self.teachers_weekly_script) # self.assertEqual(3,Message.objects.filter(direction='O',connection=self.emis_reporter1.connection_set.all()[0]).count()) self.assertEqual(2,Message.objects.filter(direction='O',connection=self.emis_reporter1.connection_set.all()[0]).count())#pausing feedback expected = 'Thank you for participating. Remember to answer all your questions next Thursday.' # self.assertTrue(expected in Message.objects.filter(direction='O',connection=self.emis_reporter1.connection_set.all()[0]).values_list('text',flat=True)) self.assertFalse(expected in Message.objects.filter(direction='O',connection=self.emis_reporter1.connection_set.all()[0]).values_list('text',flat=True))#pausing feedback
def test_should_return_4_given_reporter_responds_4_to_girls_enrollment_poll(self): self.head_teachers_termly_script.steps.all().delete() self.head_teachers_termly_script.steps.add( ScriptStep.objects.create(script=self.head_teachers_termly_script, poll=self.p6_girls_enroll_poll, order=0, rule=ScriptStep.WAIT_MOVEON, start_offset=0, giveup_offset=7200)) schedule_script_now(grp = self.head_teacher_group.name, slug = self.head_teachers_termly_script.slug) check_progress(self.head_teachers_termly_script) fake_incoming("4", self.emis_reporter1) check_progress(self.head_teachers_termly_script) enrolled_girls = get_enrolled_pupils(self.emis_reporter1.connection_set.all()[0], self.p6_girls_enroll_poll.name, settings.SCHOOL_TERM_START, settings.SCHOOL_TERM_END) self.assertEqual(4, enrolled_girls)
def test_should_return_10_boys_and_0_girls_given_reporter_responds_10boys_but_no_girls_to_enrollment_poll( self): schedule_script_now(grp=self.head_teacher_group.name, slug=self.head_teachers_termly_script.slug) check_progress(self.head_teachers_termly_script) fake_incoming("10", self.emis_reporter1) check_progress(self.head_teachers_termly_script) time.sleep(2) check_progress(self.head_teachers_termly_script) boys, girls = get_enrolled_boys_and_girls( self.emis_reporter1.connection_set.all()[0], self.p3_boys_enroll_poll.name, self.p3_girls_enroll_poll.name) self.assertEqual(10, boys) self.assertEqual(0, girls)
def test_should_send_alert_messages_on_invalid_and_partial_responses(self): # 5 outgoing messages (1st) step 0 poll, (2nd) error msg alert (3rd) resend error poll (4th) step 1 msg (5th) Script completion alert schedule_script_now(grp=self.head_teacher_group.name, slug=self.teachers_weekly_script.slug) check_progress(self.teachers_weekly_script) fake_incoming("Invalid", self.emis_reporter1) check_progress(self.teachers_weekly_script) expected = 'The answer you have provided is not in the correct format. Use figures like 3 to answer the question' self.assertTrue(expected in Message.objects.filter(direction='O',connection=self.emis_reporter1.connection_set.all()[0]).values_list('text',flat=True)) time.sleep(3) check_progress(self.teachers_weekly_script) fake_incoming("3",self.emis_reporter1) check_progress(self.teachers_weekly_script) # self.assertEqual(5, Message.objects.filter(direction='O',connection=self.emis_reporter1.connection_set.all()[0]).count()) self.assertEqual(4, Message.objects.filter(direction='O',connection=self.emis_reporter1.connection_set.all()[0]).count())#pausing feedback expected = 'Thank you for participating. Remember to answer all your questions next Thursday.' # self.assertTrue(expected in Message.objects.filter(direction='O',connection=self.emis_reporter1.connection_set.all()[0]).values_list('text',flat=True)) self.assertFalse(expected in Message.objects.filter(direction='O',connection=self.emis_reporter1.connection_set.all()[0]).values_list('text',flat=True))#pausing feedback
def test_get_count_for_yes_no_response_by_school(self): params = { "description": "A response value for a Poll with expected text responses", "datatype": "text", "enum_group": None, "required": False, "type": None, "slug": "poll_text_value", "name": "Text" } Attribute.objects.get_or_create(**params) schedule_script_now(self.smc_group.name, slug=self.head_teacher_weekly_script.slug) check_progress(self.head_teacher_weekly_script) fake_incoming("yes", self.emis_reporter3) yes, no = get_count_for_yes_no_response_by_school([self.head_teacher_monitoring_poll], [self.kampala_district], self.term_range) self.assertEqual({self.kampala_school.id : 1}, yes) self.assertEqual({}, no)
def test_should_send_feedbacks_to_smc(self): schedule_script_now(grp=self.smc_group.name, slug=self.smc_weekly_script.slug) check_progress(self.smc_weekly_script) fake_incoming("yes", self.emis_reporter3) check_progress(self.smc_weekly_script) # self.assertEqual(2,Message.objects.filter(direction='O',connection=self.emis_reporter3.connection_set.all()[0]).count()) self.assertEqual( 1, Message.objects.filter( direction='O', connection=self.emis_reporter3.connection_set.all() [0]).count()) #paisong feedback expected = 'Thank you for your report. Please continue to visit your school and report on what is happening.' # self.assertTrue(expected in Message.objects.filter(direction='O',connection=self.emis_reporter3.connection_set.all()[0]).values_list('text',flat=True)) self.assertFalse(expected in Message.objects.filter( direction='O', connection=self.emis_reporter3.connection_set.all() [0]).values_list('text', flat=True)) #pausing feedback
def test_should_send_alert_messages_on_partial_responses(self): schedule_script_now(grp=self.head_teacher_group.name, slug=self.teachers_weekly_script.slug) check_progress(self.teachers_weekly_script) fake_incoming("3", self.emis_reporter1) check_progress(self.teachers_weekly_script) time.sleep(3) check_progress(self.teachers_weekly_script) # self.assertEqual(3,Message.objects.filter(direction='O',connection=self.emis_reporter1.connection_set.all()[0]).count()) self.assertEqual( 2, Message.objects.filter( direction='O', connection=self.emis_reporter1.connection_set.all() [0]).count()) #pausing feedback expected = 'Thank you for participating. Remember to answer all your questions next Thursday.' # self.assertTrue(expected in Message.objects.filter(direction='O',connection=self.emis_reporter1.connection_set.all()[0]).values_list('text',flat=True)) self.assertFalse(expected in Message.objects.filter( direction='O', connection=self.emis_reporter1.connection_set.all() [0]).values_list('text', flat=True)) #pausing feedback
def test_should_check_message_string_for_teachers(self): schedule_script_now(grp= self.head_teacher_group.name, slug=self.head_teachers_weekly_script.slug) check_progress(self.head_teachers_weekly_script) fake_incoming("10", self.emis_reporter1) check_progress(self.head_teachers_weekly_script) fake_incoming("10", self.emis_reporter1) check_progress(self.head_teachers_weekly_script) fake_incoming("9", self.emis_reporter1) check_progress(self.head_teachers_weekly_script) fake_incoming("4", self.emis_reporter1) check_progress(self.head_teachers_weekly_script) expected ='Thankyou, Attendance for male teacher have been improved by 40percent Attendance for female teachers have been improved by 40percent' # self.assertTrue(expected in Message.objects.filter(direction='O',connection=self.emis_reporter1.connection_set.all()[0]).values_list('text',flat=True)) self.assertFalse(expected in Message.objects.filter(direction='O',connection=self.emis_reporter1.connection_set.all()[0]).values_list('text',flat=True))#pausing feedbacks
def test_should_check_increment_in_outgoing_msg_count_on_all_responses_received( self): schedule_script_now(grp=self.head_teacher_group.name, slug=self.teachers_weekly_script.slug) check_progress(self.teachers_weekly_script) fake_incoming("4", self.emis_reporter1) #response to p3 boys poll check_progress(self.teachers_weekly_script) self.assertEqual( 2, Message.objects.filter( direction='O', connection=self.emis_reporter1.connection_set.all() [0]).count()) fake_incoming("3", self.emis_reporter1) #response to p3 girls poll check_progress(self.teachers_weekly_script) # self.assertEqual(3,Message.objects.filter(direction='O',connection=self.emis_reporter1.connection_set.all()[0]).count()) self.assertEqual( 2, Message.objects.filter( direction='O', connection=self.emis_reporter1.connection_set.all() [0]).count()) #pausing feedbacks
def test_should_report_attendance_difference_for_teachers(self): schedule_script_now(grp= self.head_teacher_group.name, slug=self.head_teachers_weekly_script.slug) check_progress(self.head_teachers_weekly_script) fake_incoming("10", self.emis_reporter1) check_progress(self.head_teachers_weekly_script) fake_incoming("10", self.emis_reporter1) check_progress(self.head_teachers_weekly_script) fake_incoming("9", self.emis_reporter1) check_progress(self.head_teachers_weekly_script) fake_incoming("4", self.emis_reporter1) progress = ScriptProgress.objects.create(script=self.head_teachers_weekly_script, connection=self.emis_reporter1.connection_set.all()[0], step=self.male_teacher_step) teachers_attendance_difference = calculate_attendance_difference(self.emis_reporter1.connection_set.all()[0], progress) self.assertTrue(teachers_attendance_difference is not None) self.assertEqual(40,teachers_attendance_difference[self.male_teachers_attendance_poll.name][0]) self.assertEqual("improved",teachers_attendance_difference[self.male_teachers_attendance_poll.name][1])
def test_should_check_message_string_for_teachers(self): schedule_script_now(grp=self.head_teacher_group.name, slug=self.head_teachers_weekly_script.slug) check_progress(self.head_teachers_weekly_script) fake_incoming("10", self.emis_reporter1) check_progress(self.head_teachers_weekly_script) fake_incoming("10", self.emis_reporter1) check_progress(self.head_teachers_weekly_script) fake_incoming("9", self.emis_reporter1) check_progress(self.head_teachers_weekly_script) fake_incoming("4", self.emis_reporter1) check_progress(self.head_teachers_weekly_script) expected = 'Thankyou, Attendance for male teacher have been improved by 40percent Attendance for female teachers have been improved by 40percent' # self.assertTrue(expected in Message.objects.filter(direction='O',connection=self.emis_reporter1.connection_set.all()[0]).values_list('text',flat=True)) self.assertFalse(expected in Message.objects.filter( direction='O', connection=self.emis_reporter1.connection_set.all() [0]).values_list('text', flat=True)) #pausing feedbacks
def test_should_give_attendance_difference_as_0_if_error_message_received(self): schedule_script_now(grp=self.head_teacher_group.name,slug=self.head_teachers_termly_script.slug) check_progress(self.head_teachers_termly_script) fake_incoming("10",self.emis_reporter1) check_progress(self.head_teachers_termly_script) fake_incoming("10",self.emis_reporter1) schedule_script_now(grp=self.head_teacher_group.name,slug = self.teachers_weekly_script.slug) check_progress(self.teachers_weekly_script) fake_incoming("I am not in school today",self.emis_reporter1)#response to p3 boys poll progress = ScriptProgress.objects.create(script=self.teachers_weekly_script, connection=self.emis_reporter1.connection_set.all()[0],step=self.p3_boys_attendance_step) attendance_difference = calculate_attendance_difference(self.emis_reporter1.connection_set.all()[0],progress) self.assertEqual(0,attendance_difference[self.p3_boys_absent_poll.name][0]) self.assertEqual("improved",attendance_difference[self.p3_boys_absent_poll.name][1])
def test_should_calculate_difference_in_attendance_for_this_and_past_week(self): schedule_script_now(grp=self.head_teacher_group.name,slug=self.head_teachers_termly_script.slug) check_progress(self.head_teachers_termly_script) fake_incoming("10",self.emis_reporter1) check_progress(self.head_teachers_termly_script) fake_incoming("10",self.emis_reporter1) schedule_script_now(grp=self.head_teacher_group.name,slug = self.teachers_weekly_script.slug) check_progress(self.teachers_weekly_script) fake_incoming("4",self.emis_reporter1) progress = ScriptProgress.objects.create(script=self.teachers_weekly_script, connection=self.emis_reporter1.connection_set.all()[0], step=self.p6_boys_attendance_step) attendance_difference = calculate_attendance_difference(self.emis_reporter1.connection_set.all()[0], progress) self.assertEqual(40,attendance_difference[self.p6_boys_absent_poll.name][0]) self.assertEqual("improved",attendance_difference[self.p6_boys_absent_poll.name][1])
def test_get_aggregated_report_data_single_indicator(self): schedule_script_now(self.head_teacher_group.name, slug=self.head_teachers_termly_script.slug) check_progress(self.head_teachers_termly_script) fake_incoming("10 boys", self.emis_reporter1) check_progress(self.head_teachers_termly_script) fake_incoming("5 girls", self.emis_reporter1) schedule_script_now(self.head_teacher_group.name, slug=self.teachers_weekly_script.slug) check_progress(self.teachers_weekly_script) fake_incoming("8 boys", self.emis_reporter1) check_progress(self.teachers_weekly_script) fake_incoming("1 girls", self.emis_reporter1) config_list = get_polls_for_keyword('P3Boys') collective_result, chart_results_model, school_percent,tooltip = \ get_aggregated_report_data_single_indicator([self.kampala_district], [self.term_range], config_list) self.assertEqual(20.0, collective_result['P3 Boys'][0].values()[0]) config_list = get_polls_for_keyword('P3Girls') collective_result, chart_results_model, school_percent,tooltip = get_aggregated_report_data_single_indicator([self.kampala_district], [self.term_range], config_list) self.assertEqual(80.0, collective_result['P3 Girls'][0].values()[0])
def test_should_report_attendance_difference_for_teachers(self): schedule_script_now(grp=self.head_teacher_group.name, slug=self.head_teachers_weekly_script.slug) check_progress(self.head_teachers_weekly_script) fake_incoming("10", self.emis_reporter1) check_progress(self.head_teachers_weekly_script) fake_incoming("10", self.emis_reporter1) check_progress(self.head_teachers_weekly_script) fake_incoming("9", self.emis_reporter1) check_progress(self.head_teachers_weekly_script) fake_incoming("4", self.emis_reporter1) progress = ScriptProgress.objects.create( script=self.head_teachers_weekly_script, connection=self.emis_reporter1.connection_set.all()[0], step=self.male_teacher_step) teachers_attendance_difference = calculate_attendance_difference( self.emis_reporter1.connection_set.all()[0], progress) self.assertTrue(teachers_attendance_difference is not None) self.assertEqual( 40, teachers_attendance_difference[ self.male_teachers_attendance_poll.name][0]) self.assertEqual( "improved", teachers_attendance_difference[ self.male_teachers_attendance_poll.name][1])
def test_should_calculate_difference_in_attendance_for_this_and_past_week( self): schedule_script_now(grp=self.head_teacher_group.name, slug=self.head_teachers_termly_script.slug) check_progress(self.head_teachers_termly_script) fake_incoming("10", self.emis_reporter1) check_progress(self.head_teachers_termly_script) fake_incoming("10", self.emis_reporter1) schedule_script_now(grp=self.head_teacher_group.name, slug=self.teachers_weekly_script.slug) check_progress(self.teachers_weekly_script) fake_incoming("4", self.emis_reporter1) #response to p3 boys poll progress = ScriptProgress.objects.create( script=self.teachers_weekly_script, connection=self.emis_reporter1.connection_set.all()[0], step=self.p3_boys_attendance_step) attendance_difference = calculate_attendance_difference( self.emis_reporter1.connection_set.all()[0], progress) self.assertEqual( 40, attendance_difference[self.p3_boys_absent_poll.name][0]) self.assertEqual( "improved", attendance_difference[self.p3_boys_absent_poll.name][1])
def test_should_return_get_numeric_data_by_school(self): schedule_script_now(self.head_teacher_group.name, slug=self.teachers_weekly_script.slug) check_progress(self.teachers_weekly_script) fake_incoming("20 boys", self.emis_reporter1) school_results = get_numeric_data_by_school([self.p3_boys_absent_poll], [self.kampala_school], self.term_range) self.assertEqual(20, sum(school_results))
def test_previous_week_attendance_against_current_week_attendance(self): schedule_script_now(grp = self.head_teacher_group.name, slug = self.head_teachers_termly_script.slug) check_progress(self.head_teachers_termly_script) fake_incoming("10boys", self.emis_reporter1) check_progress(self.head_teachers_termly_script) fake_incoming("10", self.emis_reporter1) check_progress(self.head_teachers_termly_script) # previous week absenteeism script schedule schedule_script_now(grp=self.head_teacher_group.name,slug=self.teachers_weekly_script.slug) check_progress(self.teachers_weekly_script) fake_incoming("5", self.emis_reporter1) check_progress(self.teachers_weekly_script) fake_incoming("5girls", self.emis_reporter1) check_progress(self.teachers_weekly_script) expected ='Thankyou p3 Teacher, Attendance for boys have been improved by 50percent Attendance for girls have been improved by 50percent' # self.assertTrue(expected in Message.objects.filter(direction='O',connection=self.emis_reporter1.connection_set.all()[0]).values_list('text',flat=True)) self.assertFalse(expected in Message.objects.filter(direction='O',connection=self.emis_reporter1.connection_set.all()[0]).values_list('text',flat=True))#pausing feedback responses = Response.objects.filter(contact__connection=self.emis_reporter1.connection_set.all()[0], has_errors=False) poll_list = ['edtrac_boysp3_attendance','edtrac_girlsp3_attendance'] this_thursday = _this_thursday().date() previous_week = dateutils.increment(this_thursday,days=-12) for resp in responses: if resp.poll.name in poll_list: resp.date = previous_week resp.save() # current week absenteeism script schedule schedule_script_now(grp=self.head_teacher_group.name,slug=self.teachers_weekly_script.slug) check_progress(self.teachers_weekly_script) fake_incoming("6boys", self.emis_reporter1) check_progress(self.teachers_weekly_script) fake_incoming("4", self.emis_reporter1) check_progress(self.teachers_weekly_script) expected ='Thankyou p3 Teacher, Attendance for boys have been improved by 10percent Attendance for girls have been dropped by 10percent' # self.assertTrue(expected in Message.objects.filter(direction='O',connection=self.emis_reporter1.connection_set.all()[0]).values_list('text',flat=True)) self.assertFalse(expected in Message.objects.filter(direction='O',connection=self.emis_reporter1.connection_set.all()[0]).values_list('text',flat=True))#pausing feedback
def test_should_send_2_invalid_alerts_by_script_completion(self): schedule_script_now(grp = self.head_teacher_group.name, slug = self.head_teachers_termly_script.slug) check_progress(self.head_teachers_termly_script) fake_incoming("10", self.emis_reporter1) check_progress(self.head_teachers_termly_script) fake_incoming("10", self.emis_reporter1) check_progress(self.head_teachers_termly_script) schedule_script_now(grp=self.head_teacher_group.name,slug=self.teachers_weekly_script.slug) check_progress(self.teachers_weekly_script) fake_incoming("Invalid", self.emis_reporter1) check_progress(self.teachers_weekly_script) fake_incoming("4", self.emis_reporter1) check_progress(self.teachers_weekly_script) fake_incoming("Invalid", self.emis_reporter1) check_progress(self.teachers_weekly_script) fake_incoming("4", self.emis_reporter1) check_progress(self.teachers_weekly_script) alert = 'The answer you have provided is not in the correct format. Use figures like 3 to answer the question' messages = Message.objects.filter(direction='O', text =alert, connection=self.emis_reporter1.connection_set.all()[0]) self.assertEqual(2, messages.count()) expected ='Thankyou p3 Teacher, Attendance for boys have been improved by 40percent Attendance for girls have been improved by 40percent' # self.assertTrue(expected in Message.objects.filter(direction='O',connection=self.emis_reporter1.connection_set.all()[0]).values_list('text',flat=True)) self.assertFalse(expected in Message.objects.filter(direction='O',connection=self.emis_reporter1.connection_set.all()[0]).values_list('text',flat=True))#pausing feedback
def test_should_return_get_numeric_data_all_schools_for_locations(self): schedule_script_now(self.head_teacher_group.name, slug=self.teachers_weekly_script.slug) check_progress(self.teachers_weekly_script) fake_incoming("20 boys", self.emis_reporter1) school_results = get_numeric_data_all_schools_for_locations([self.p3_boys_absent_poll], [self.kampala_district], self.term_range) self.assertEqual({self.kampala_school.id: 20}, school_results)