Skip to content

Commit

Permalink
0.2.13.3
Browse files Browse the repository at this point in the history
========

* **Fix:** Fixed a bug in ``Review.finalize_review_set()`` for tasks that are
  sent to review and still have some extra time were not clamped to their total
  logged seconds when the review set is all approved.
  • Loading branch information
eoyilmaz committed Feb 16, 2015
1 parent f2d3369 commit dcfc8d9
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 9 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG
Expand Up @@ -2,6 +2,13 @@
Stalker Changes
===============

0.2.13.3
========

* **Fix:** Fixed a bug in ``Review.finalize_review_set()`` for tasks that are
sent to review and still have some extra time were not clamped to their total
logged seconds when the review set is all approved.

0.2.13.2
========

Expand Down
2 changes: 1 addition & 1 deletion stalker/__init__.py
Expand Up @@ -23,7 +23,7 @@
See docs for more information.
"""

__version__ = '0.2.13.2'
__version__ = '0.2.13.3'


import sys
Expand Down
14 changes: 9 additions & 5 deletions stalker/models/review.py
Expand Up @@ -263,23 +263,27 @@ def finalize_review_set(self):
total_seconds += review.schedule_seconds
revise_task = True

timing, unit = self.least_meaningful_time_unit(total_seconds)
self.task._review_number += 1
if revise_task:
# revise the task timing if the task needs more time
if total_seconds > self.task.schedule_seconds:
logger.debug('total_seconds including reviews: %s' %
total_seconds)
timing, unit = \
self.least_meaningful_time_unit(total_seconds)
logger.debug(
'total_seconds including reviews: %s' % total_seconds
)

self.task.schedule_timing = timing
self.task.schedule_unit = unit
self.task.status = hrev
else:
# approve the task
self.task.status = cmpl
# update task parent statuses

# also clamp the schedule timing
self.task.schedule_timing = timing
self.task.schedule_unit = unit

# update task parent statuses
self.task.update_parent_statuses()

from stalker import TaskDependency
Expand Down
39 changes: 39 additions & 0 deletions tests/models/test_review.py
Expand Up @@ -633,6 +633,45 @@ def test_approve_method_updates_task_dependent_timings(self):
0
)

def test_approve_method_updates_task_timings(self):
"""testing if approve method will also update the task timings
"""
self.task3.status = self.status_rts
now = datetime.datetime.now()
td = datetime.timedelta

self.task3.schedule_timing = 2
self.task3.schedule_unit = 'h'

self.task3.create_time_log(
resource=self.task3.resources[0],
start=now,
end=now + td(hours=1)
)

reviews = self.task3.request_review()
self.assertEqual(
self.task3.status, self.status_prev
)

self.assertNotEqual(
self.task3.total_logged_seconds,
self.task3.schedule_seconds
)

review1 = reviews[0]
review1.approve()

self.assertEqual(
self.task3.status, self.status_cmpl
)

self.assertEqual(
self.task3.total_logged_seconds,
self.task3.schedule_seconds
)


def test_approve_method_updates_task_status_correctly_for_a_multi_responsible_task_when_one_approve(self):
"""testing if the Review.approve() method will update the task status
correctly for a task with multiple responsible
Expand Down
6 changes: 3 additions & 3 deletions tests/models/test_task_status_workflow.py
Expand Up @@ -1518,9 +1518,9 @@ def test_request_revision_in_CMPL_leaf_task_schedule_info_update(self):
'schedule_timing': 4,
'schedule_unit': 'h'
}
review3 = self.test_task3.request_revision(**kw)
self.assertEqual(self.test_task3.schedule_unit, 'd')
self.assertEqual(self.test_task3.schedule_timing, 10)
self.test_task3.request_revision(**kw)
self.assertEqual(self.test_task3.schedule_unit, 'h')
self.assertEqual(self.test_task3.schedule_timing, 6)

#CMPL: parent status update
def test_request_revision_in_CMPL_leaf_task_parent_status_updated_to_WIP(self):
Expand Down

0 comments on commit dcfc8d9

Please sign in to comment.