Exemplo n.º 1
0
    def test_male_and_female_head_teachers_attendance_on_holiday(self):
        d1, d2 = get_week_date(depth=2)
        settings.SCHOOL_HOLIDAYS = [(d1[0], d1[1]), (d2[0], d2[1])]
        self.create_emisreporters_of_smc_group()
        self.m_head_teachers_attendance_poll = create_poll_with_reporters(
            "edtrac_head_teachers_attendance",
            "Has the head teacher been at school for at least 3 days? Answer YES or NO",
            Poll.TYPE_TEXT, self.user,
            [self.emisreporter4, self.emisreporter5, self.emisreporter6])

        self.m_head_teachers_attendance_poll.add_yesno_categories()
        self.m_head_teachers_attendance_poll.save()
        self.m_head_teachers_attendance_poll.start()
        self.fake_incoming_with_date('yes', self.connection4,
                                     self.poll_response_current_week_date)
        self.fake_incoming_with_date('yes', self.connection5,
                                     self.poll_response_current_week_date)
        self.fake_incoming_with_date('no', self.connection6,
                                     self.poll_response_current_week_date)

        self.fake_incoming_with_date('no', self.connection4,
                                     self.poll_response_past_week_date)
        self.fake_incoming_with_date('no', self.connection5,
                                     self.poll_response_past_week_date)
        self.fake_incoming_with_date('yes', self.connection6,
                                     self.poll_response_past_week_date)
        result_m_head_teachers = head_teachers_male(
            self.root_node.get_children())
        result_f_head_teachers = head_teachers_female(
            self.root_node.get_children())

        self.assertEqual("--", result_m_head_teachers['m_head_t_week_before'])
        self.assertEqual("--", result_f_head_teachers['f_head_t_week_before'])
Exemplo n.º 2
0
def get_date_range(from_date, to_date, depth=4):
    if from_date is None and to_date is None:
        return get_week_date(depth)
    week_range = []
    first_week = (to_date - timedelta(days=7), to_date)
    week_range.append(first_week)
    to_date = to_date - timedelta(days=7)
    while to_date > from_date:
        week_range.append(
            (to_date - timedelta(days=8), to_date - timedelta(days=1)))
        to_date = to_date - timedelta(days=7)
    return week_range
Exemplo n.º 3
0
    def setUp(self):
        super(TestAbsenteeismViewHelper, self).setUp()
        self.kampala_school1 = create_school("St. Joseph's", self.kampala_district)
        self.smc_group = create_group("SMC")
        self.emis_reporter5 = create_emis_reporters('Derek', self.kampala_district, self.kampala_school, 1234557,
                                                    self.smc_group)
        self.emis_reporter6 = create_emis_reporters('Peter', self.kampala_district, self.kampala_school1, 1234558,
                                                    self.smc_group)
        self.head_teachers_group = create_group("Head Teachers")
        self.emis_reporter7 = create_emis_reporters('John', self.kampala_district, self.kampala_school, 1234559,
                                                    self.head_teachers_group)
        self.emis_reporter7.gender = 'M'
        self.emis_reporter7.save()
        self.emis_reporter8 = create_emis_reporters('James', self.kampala_district, self.kampala_school1, 1234550,
                                                    self.head_teachers_group)
        self.emis_reporter8.gender = 'm'
        self.emis_reporter8.save()
        self.head_teachers_script = Script.objects.create(name='Education monitoring smc weekly script',
                                                     slug='edtrac_smc_weekly')
        self.head_teachers_poll, self.head_teachers_poll_created = Poll.objects.get_or_create(
            name='edtrac_head_teachers_attendance',
            user=self.admin_user,
            type=Poll.TYPE_TEXT,
            question='Has the head teacher been at school for at least 3 days? Answer YES or NO',
            default_response='')
        self.head_teachers_poll.add_yesno_categories()
        self.head_teachers_poll.save()
        self.head_teachers_script.steps.add(
            ScriptStep.objects.create(script=self.head_teachers_script, poll=self.head_teachers_poll, order=0,
                                      rule=ScriptStep.WAIT_MOVEON, start_offset=0, giveup_offset=86400 ))

        self.teachers_weekly_script = Script.objects.create(name='Revised P3 Teachers Weekly Script',slug='edtrac_p3_teachers_weekly')
        self.p3_boys_absent_poll.contacts.add(self.emis_reporter7)
        self.p3_boys_absent_poll.contacts.add(self.emis_reporter8)
        self.p3_boys_absent_poll.save()
        self.teachers_weekly_script.steps.add(
            ScriptStep.objects.create(script=self.teachers_weekly_script, poll=self.p3_boys_absent_poll, order=0,
                                      rule=ScriptStep.WAIT_MOVEON, start_offset=0, giveup_offset=7200 ))

        settings.SCHOOL_TERM_START = dateutils.increment(datetime.datetime.now(),weeks=-8)
        settings.SCHOOL_TERM_END = dateutils.increment(datetime.datetime.now(),weeks=1)
        self.date_week = get_week_date(4)
Exemplo n.º 4
0
    def test_male_and_female_head_teachers_attendance_on_holiday(self):
        d1,d2 = get_week_date(depth = 2)
        settings.SCHOOL_HOLIDAYS = [(d1[0],d1[1]) , (d2[0],d2[1])]
        self.create_emisreporters_of_smc_group()
        self.m_head_teachers_attendance_poll=create_poll_with_reporters("edtrac_head_teachers_attendance",
                                                         "Has the head teacher been at school for at least 3 days? Answer YES or NO",
                                                         Poll.TYPE_TEXT,self.user,
                                                         [self.emisreporter4,self.emisreporter5,self.emisreporter6])

        self.m_head_teachers_attendance_poll.add_yesno_categories()
        self.m_head_teachers_attendance_poll.save()
        self.m_head_teachers_attendance_poll.start()
        self.fake_incoming_with_date('yes', self.connection4, self.poll_response_current_week_date)
        self.fake_incoming_with_date('yes', self.connection5, self.poll_response_current_week_date)
        self.fake_incoming_with_date('no', self.connection6, self.poll_response_current_week_date)

        self.fake_incoming_with_date('no', self.connection4, self.poll_response_past_week_date)
        self.fake_incoming_with_date('no', self.connection5, self.poll_response_past_week_date)
        self.fake_incoming_with_date('yes', self.connection6, self.poll_response_past_week_date)
        result_m_head_teachers=head_teachers_male(self.root_node.get_children())
        result_f_head_teachers=head_teachers_female(self.root_node.get_children())

        self.assertEqual("--",result_m_head_teachers['m_head_t_week_before'])
        self.assertEqual("--",result_f_head_teachers['f_head_t_week_before'])