def test_extended_end_dates_all_set(self): cycles = [ Cycle.create( team_id="Team_001", ordinal=1, start_date=date(2019, 1, 1), end_date=date(2019, 1, 15) ), Cycle.create( team_id="Team_001", ordinal=2, start_date=date(2019, 2, 1), end_date=date(2019, 2, 15) ), Cycle.create( team_id="Team_001", ordinal=3, start_date=date(2019, 3, 1), end_date=date(2019, 3, 15) ), ] reordered = Cycle.reorder_and_extend(cycles) self.assertEqual( reordered[0].extended_end_date, date(2019, 1, 31), # day before 2/1 ) self.assertEqual( reordered[1].extended_end_date, date(2019, 2, 28), # day before 3/1 ) self.assertEqual( reordered[2].extended_end_date, date(2019, 6, 30) # last day of program )
def test_extended_end_dates_some_unset(self): cycles = [ Cycle.create( team_id="Team_001", ordinal=1, start_date=date(2019, 1, 1), end_date=date(2019, 1, 15) ), Cycle.create( team_id="Team_001", ordinal=2, start_date=None, end_date=None, ), Cycle.create( team_id="Team_001", ordinal=3, start_date=None, end_date=None, ), ] # Should match output of Cycle.cycleless_end_date(). last_day_of_program = date(2019, 6, 30) reordered = Cycle.reorder_and_extend(cycles) self.assertEqual(reordered[0].extended_end_date, last_day_of_program) self.assertEqual(reordered[1].extended_end_date, None) self.assertEqual(reordered[2].extended_end_date, None)
def test_reorders(self): """ Cycles without dates are placed at the end ordered by ordinal. """ cycles = [ Cycle.create( team_id="Team_001", ordinal=1, start_date=None, end_date=None ), Cycle.create( team_id="Team_001", ordinal=2, start_date=None, end_date=None ), Cycle.create( team_id="Team_001", ordinal=3, start_date=date(2018, 1, 1), end_date=date(2019, 1, 1) ), ] reordered = Cycle.reorder_and_extend(cycles) self.assertEqual(reordered, [cycles[2], cycles[0], cycles[1]])