def testWorkingDays(self): """Test the working days calculation""" # Normal Working days self.assert_equals(5, dt.count_working_days(self.start_sunday, self.end_sunday)) # Now without any day off self.assert_equals((self.end_sunday - self.start_sunday).days + 1, dt.count_working_days(self.start_sunday, self.end_sunday, week_days_off=[])) # Now check that the start and end dates are in days = dt.get_working_days(self.start_sunday, self.end_sunday, week_days_off=[]) self.assert_true(self.start_sunday in days, "Start Sunday: %s is not in!" % self.start_sunday) self.assert_true(self.end_sunday in days, "End Sunday: %s is not in!" % self.end_sunday)
def testSprintUpdateDuration(self): """ Tests the Sprint update of the duration in case start, or end, or duration are changed """ sprint = self.manager.create(name="Test Sprint", start=self.start, end=self.end) self.assert_equals(sprint.duration, count_working_days(sprint.start.date(), sprint.end.date())) # Now change the start date +1 sprint.start = sprint.start + timedelta(days=1) self.assert_equals(sprint.duration, count_working_days(sprint.start.date(), sprint.end.date())) # Now move the end -1 sprint.end = sprint.end - timedelta(days=1) self.assert_equals(sprint.duration, count_working_days(sprint.start.date(), sprint.end.date()))
def testSprintCreationWithDates(self): """Tests the Sprint creation with the start and end date""" sprint = self.manager.create(name="Test Sprint", start=self.start, end=self.end) self.assert_equals(sprint.duration, count_working_days(self.start.date(), self.end.date())) # Now save the sprint and reload it from the DB # AT: With the manager the sprint is already saved # self.manager.save(sprint) sprint = self.manager.get(name="Test Sprint") self.assert_equals(sprint.duration, count_working_days(self.start.date(), self.end.date())) self.assert_equals(self.end, sprint.end) self.assert_equals(self.start, sprint.start) # Now add a description and test the reload sprint.description = 'This is a test Sprint' self.manager.save(sprint) # clear the cache so we are sure it will be reloaded from the DB self.manager.get_cache().invalidate() sprint = self.manager.get(name="Test Sprint") self.assert_equals(sprint.description, 'This is a test Sprint')
def testSprintUpdateDuration(self): """ Tests the Sprint update of the duration in case start, or end, or duration are changed """ sprint = self.manager.create(name="Test Sprint", start=self.start, end=self.end) self.assert_equals( sprint.duration, count_working_days(sprint.start.date(), sprint.end.date())) # Now change the start date +1 sprint.start = sprint.start + timedelta(days=1) self.assert_equals( sprint.duration, count_working_days(sprint.start.date(), sprint.end.date())) # Now move the end -1 sprint.end = sprint.end - timedelta(days=1) self.assert_equals( sprint.duration, count_working_days(sprint.start.date(), sprint.end.date()))
def testSprintCreationWithDates(self): """Tests the Sprint creation with the start and end date""" sprint = self.manager.create(name="Test Sprint", start=self.start, end=self.end) self.assert_equals( sprint.duration, count_working_days(self.start.date(), self.end.date())) # Now save the sprint and reload it from the DB # AT: With the manager the sprint is already saved # self.manager.save(sprint) sprint = self.manager.get(name="Test Sprint") self.assert_equals( sprint.duration, count_working_days(self.start.date(), self.end.date())) self.assert_equals(self.end, sprint.end) self.assert_equals(self.start, sprint.start) # Now add a description and test the reload sprint.description = 'This is a test Sprint' self.manager.save(sprint) # clear the cache so we are sure it will be reloaded from the DB self.manager.get_cache().invalidate() sprint = self.manager.get(name="Test Sprint") self.assert_equals(sprint.description, 'This is a test Sprint')
def _get_duration(self): """Gets the duration of the Sprint""" duration = count_working_days(self.start, self.end) debug(self, "Returning duration %d start: %s, end: %s" % (duration, self.start, self.end)) return duration
def _get_duration(self): """Gets the duration of the Sprint""" duration = count_working_days(self.start, self.end) debug(self, "Returning duration %d start: %s, end: %s" % \ (duration, self.start, self.end)) return duration