def test_this_thursday_skips_holidays(self): thursday_holiday = (datetime(2013, 8, 29), '1d') friday_after_holiday = date(2013, 8, 30) monday = datetime(2013, 8, 26, 12, 33) self.assertEqual( friday_after_holiday, _this_thursday(get_time=lambda: monday, holidays=[thursday_holiday]).date())
def get_current_and_previous_week(): this_thursday = _this_thursday().date() current_week_start = dateutils.increment(this_thursday, days=-6) current_week = append_time_to_week_date(this_thursday, current_week_start) previous_week_start = dateutils.increment(this_thursday, days=-13) previous_week_end = dateutils.increment(this_thursday, days=-7) previous_week = append_time_to_week_date(previous_week_end,previous_week_start) return current_week, previous_week
def get_current_and_previous_week(): this_thursday = _this_thursday().date() current_week_start = dateutils.increment(this_thursday, days=-6) current_week = append_time_to_week_date(this_thursday, current_week_start) previous_week_start = dateutils.increment(this_thursday, days=-13) previous_week_end = dateutils.increment(this_thursday, days=-7) previous_week = append_time_to_week_date(previous_week_end, previous_week_start) return current_week, previous_week
def test_should_give_target_for_previous_terms(self): settings.FIRST_TERM_BEGINS = dateutils.increment(datetime.now(), weeks=-13) settings.SCHOOL_TERM_START = datetime.now() settings.SCHOOL_TERM_END = dateutils.increment(datetime.now(), weeks=12) client = Client() client.login(username="******", password="******") this_thursday = _this_thursday() week_start = dateutils.increment(this_thursday, weeks=-12).strftime("%d,%b,%Y") week_end = dateutils.increment(this_thursday, weeks=-11, days=-1).strftime("%d,%b,%Y") second_week_in_first_term = week_start + " to " + week_end response = client.post("/edtrac/dash-admin-progress/", {"choose_week_to_view": second_week_in_first_term}) self.assertEqual("No Reports made this week", response.context["current_mode"]) self.assertEqual(1.2, response.context["target"])
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_give_target_for_previous_terms(self): settings.FIRST_TERM_BEGINS = dateutils.increment(datetime.now(), weeks=-13) settings.SCHOOL_TERM_START = datetime.now() settings.SCHOOL_TERM_END = dateutils.increment(datetime.now(), weeks=12) client = Client() client.login(username='******', password='******') this_thursday = _this_thursday() week_start = dateutils.increment(this_thursday, weeks=-12).strftime("%d,%b,%Y") week_end = dateutils.increment(this_thursday, weeks=-11, days=-1).strftime("%d,%b,%Y") second_week_in_first_term = week_start + " to " + week_end response = client.post( '/edtrac/dash-admin-progress/', {'choose_week_to_view': second_week_in_first_term}) self.assertEqual('No Reports made this week', response.context['current_mode']) self.assertEqual(1.2, response.context['target'])
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_time_of_this_thursday_is_ten_in_the_morning(self): monday_night = datetime(2013, 8, 26, 23, 0, 0) ten_am = time(10, 0, 0) self.assertEqual(ten_am, _this_thursday(get_time=lambda: monday_night).time())
def test_this_thursday_is_next_week_on_thursday(self): thursday = datetime(2013, 9, 15, 11, 23) next_thursday = date(2013, 9, 19) self.assertEqual(next_thursday, _this_thursday(get_time=lambda: thursday).date())
def test_should_determine_this_thursday(self): monday = datetime(2013, 8, 19, 1, 12) thursday = monday + timedelta(3) self.assertEqual(thursday.date(), _this_thursday(get_time=lambda: monday).date())
def test_this_thursday_skips_holidays(self): thursday_holiday = (datetime(2013, 8, 29), '1d') friday_after_holiday = date(2013, 8, 30) monday = datetime(2013, 8, 26, 12, 33) self.assertEqual(friday_after_holiday, _this_thursday(get_time = lambda : monday, holidays = [thursday_holiday]).date())
def test_time_of_this_thursday_is_ten_in_the_morning(self): monday_night = datetime(2013, 8, 26, 23, 0, 0) ten_am = time(10, 0, 0) self.assertEqual(ten_am, _this_thursday(get_time = lambda : monday_night).time())
def test_this_thursday_is_next_week_on_thursday(self): thursday = datetime(2013, 9, 15, 11, 23) next_thursday = date(2013, 9, 19) self.assertEqual(next_thursday, _this_thursday(get_time = lambda : thursday).date())
def test_should_determine_this_thursday(self): monday = datetime(2013, 8, 19, 1, 12) thursday = monday + timedelta(3) self.assertEqual(thursday.date(), _this_thursday(get_time = lambda : monday).date())