def test_get_or_create_weeks_with_no_weeks(self): """ The previous, current, and next weeks should be created and added to a dict. """ weeks = funct.get_or_create_weeks(0) self.assertEqual(sorted(weeks.keys()), ['current', 'next', 'previous']) self.assertEqual(weeks['current'].monday, funct.get_monday()) self.assertEqual(weeks['previous'].monday, funct.get_monday(None, 0)) self.assertEqual(weeks['next'].monday, funct.get_monday(None, 1))
def test_get_or_create_weeks_with_weeks(self): """ The previous, current, and next weeks should be added to a dict. """ previous_week = test.create_week(monday=funct.get_monday(None, 0)) previous_week.populate() current_week = test.create_week(monday=funct.get_monday()) current_week.populate() next_week = test.create_week(monday=funct.get_monday(None, 1)) next_week.populate() weeks = funct.get_or_create_weeks(0) self.assertEqual(sorted(weeks.keys()), ['current', 'next', 'previous']) self.assertEqual(weeks['current'].monday, current_week.monday) self.assertEqual(weeks['previous'].monday, previous_week.monday) self.assertEqual(weeks['next'].monday, next_week.monday)
def test_get_monday_next(self): """ Returns next Monday. To test, uncomment and change next_mon date. Tested and works. """ week = test.create_week() week.populate() monday = funct.get_monday(week, 1) next_mon = date(2017, 7, 17) self.assertEqual(monday, next_mon)
def test_get_monday_previous(self): """ Returns previous Monday. To test, uncomment and change previous_mon date. Tested and works. """ week = test.create_week() week.populate() monday = funct.get_monday(week, 0) previous_mon = date(2017, 7, 3) self.assertEqual(monday, previous_mon)
def test_get_monday_present(self): """ Returns most recent Monday. To test, uncomment and change current_mon date. Tested and works. """ week = test.create_week() week.populate() monday = funct.get_monday(week=week) current_mon = date(2017, 7, 10) self.assertEqual(monday, current_mon)
def test_check_present_with_present_week(self): """ Sets the boolean value of the correct present week to True and all others to False. The function also returns True. """ mon_present = funct.get_monday(n=None) mon_previous = funct.get_monday(n=0) mon_next = funct.get_monday(n=1) week1 = test.create_week(monday=mon_present) week1.populate() week2 = test.create_week(monday=mon_previous) week2.populate() week3 = test.create_week(monday=mon_next, present=True) week3.populate() out = funct.check_present() for week in [week1, week2, week3]: week.refresh_from_db() self.assertTrue(out) self.assertTrue(week1.present) self.assertFalse(week2.present) self.assertFalse(week3.present)