Exemplo n.º 1
0
def round_sprint_issue_estimates(sprint_id):
    sprint_issues = jira.get_issues_for_sprint(sprint_id)
    for issue in sprint_issues:
        estimate = jira.get_estimate(issue['key'])
        if estimate and not float(estimate).is_integer():
            jira.update_estimate(issue['key'], int(estimate) + 1)
    get_sprint_stories(sprint_issues)
Exemplo n.º 2
0
 def test_fractional_estimates_rounded_up(self):
     # Abe adds a fractional estimate to an issue and adds it to a sprint,
     # the estimate automatically rounds up
     jira.add_issues_to_sprint(self.sprint_id, [self.issue_keys[4]])
     jira.update_estimate(self.issue_keys[4], 7.2)
     self.wait_for(
         lambda: self.assertEqual(jira.get_estimate(self.issue_keys[4]), 8))
Exemplo n.º 3
0
def set_story_estimate(story):
    current_story_estimate = jira.get_estimate(story['key'])
    new_story_estimate = 0
    for subtask in story['fields']['subtasks']:
        subtask_estimate = jira.get_estimate(subtask['key'])
        if subtask_estimate:
            new_story_estimate += subtask_estimate
    if current_story_estimate != new_story_estimate:
        jira.update_estimate(story['key'], new_story_estimate)
Exemplo n.º 4
0
 def test_update_estimate(self, mock_request):
     self.create_mock_request(mock_request)
     jira.update_estimate('TEST-1', 11)
     endpoint = "/rest/agile/1.0/issue/TEST-1/estimation"
     query = f"boardId={jira.BOARD_ID}"
     mock_request.assert_called_once_with(
         "PUT",
         f"{jira.SERVER}{endpoint}?{query}",
         data=json.dumps({"value": 11}),
         headers=jira.headers)
Exemplo n.º 5
0
    def test_estimate_is_too_big_to_slack(self):
        slack.clear_old_bot_messages(CHANNEL_ID, WEBHOOK_URL)

        # Abe adds a story task with a big estimate to the sprint. He then
        # starts the sprint. There is a notification in Slack detailing as much.
        parent = jira.get_issue(self.issue_keys[0])
        subtasks = parent['fields']['subtasks']
        jira.update_estimate(subtasks[0]['key'], 17)
        jira.update_estimate(subtasks[1]['key'], 5)
        jira.add_issues_to_sprint(self.sprint_id, [self.issue_keys[0]])
        jira.start_sprint(self.sprint_id)
        message = slack.get_latest_bot_message(CHANNEL_ID, WEBHOOK_URL)
        self.assertIn(subtasks[0]['key'], json.dumps(message))
        self.assertNotIn(subtasks[1]['key'], json.dumps(message))
Exemplo n.º 6
0
    def test_burndown_delivered_to_slack(self):
        slack.clear_old_bot_messages(CHANNEL_ID, WEBHOOK_URL)

        # Abe adds some issues to a sprint with estimates. He then starts the
        # sprint. There is a notification in Slack with correct burndown number.
        parent = jira.get_issue(self.issue_keys[0])
        subtasks = parent['fields']['subtasks']
        jira.update_estimate(subtasks[0]['key'], 8)
        jira.transition_issue(subtasks[0]['key'], "Archive", "Won't Do")
        jira.update_estimate(subtasks[1]['key'], 20)
        parent = jira.get_issue(self.issue_keys[1])
        subtasks = parent['fields']['subtasks']
        jira.update_estimate(subtasks[0]['key'], 5)
        jira.update_estimate(subtasks[1]['key'], 2)
        jira.add_issues_to_sprint(self.sprint_id, self.issue_keys[:2])
        jira.start_sprint(self.sprint_id)
        message = slack.get_latest_bot_message(CHANNEL_ID, WEBHOOK_URL)
        self.assertIn('BURNDOWN', json.dumps(message))
        self.assertIn('27', json.dumps(message))
Exemplo n.º 7
0
def set_backlog_parent_issue_estimate(issue_key):
    estimate = jira.get_estimate(issue_key)
    if estimate is not None:
        jira.update_estimate(issue_key, None)
Exemplo n.º 8
0
    def test_subtask_hours_added_to_parent(self):
        # Abe adds hours to some subtasks in the backlog, the parent issue is
        # unaffected
        parent = jira.get_issue(self.issue_keys[0])
        subtasks = parent['fields']['subtasks']
        jira.update_estimate(subtasks[0]['key'], 8)
        jira.update_estimate(subtasks[1]['key'], 3)
        parent = jira.get_issue(self.issue_keys[2])
        subtasks = parent['fields']['subtasks']
        jira.update_estimate(subtasks[0]['key'], 5)
        jira.update_estimate(subtasks[1]['key'], 2)
        self.assertEqual(jira.get_estimate(self.issue_keys[0]), None)
        self.assertEqual(jira.get_estimate(self.issue_keys[1]), None)
        self.assertEqual(jira.get_estimate(self.issue_keys[2]), None)

        # Abe adds a couple of issues to the sprint, the parent issue
        # estimate updates to reflect the sum of the subtasks
        jira.add_issues_to_sprint(self.sprint_id, self.issue_keys[:2])
        self.wait_for(lambda: self.assertEqual(
            jira.get_estimate(self.issue_keys[0]), 11))
        self.wait_for(
            lambda: self.assertEqual(jira.get_estimate(self.issue_keys[1]), 0))
        self.assertEqual(jira.get_estimate(self.issue_keys[2]), None)

        # Abe adds hours to some subtasks in the sprint, the parent issue
        # reflects the change
        parent = jira.get_issue(self.issue_keys[1])
        subtasks = parent['fields']['subtasks']
        jira.update_estimate(subtasks[0]['key'], 5)
        jira.update_estimate(subtasks[1]['key'], 3)
        self.wait_for(
            lambda: self.assertEqual(jira.get_estimate(self.issue_keys[1]), 8))
        self.assertEqual(jira.get_estimate(self.issue_keys[0]), 11)
        self.assertEqual(jira.get_estimate(self.issue_keys[2]), None)

        # Abe creates a subtask with an estimate, the parent issue updates
        estimate_field = jira.get_estimate_field(self.issue_keys[0])
        jira.create_issue("Story Task", "test0c", self.issue_keys[0],
                          **{estimate_field: 2})
        self.wait_for(lambda: self.assertEqual(
            jira.get_estimate(self.issue_keys[0]), 13))
        self.assertEqual(jira.get_estimate(self.issue_keys[1]), 8)
        self.assertEqual(jira.get_estimate(self.issue_keys[2]), None)

        # Abe deletes a subtask, the parent issue updates
        parent = jira.get_issue(self.issue_keys[0])
        subtasks = parent['fields']['subtasks']
        jira.delete_issue(subtasks[2]['key'])
        self.wait_for(lambda: self.assertEqual(
            jira.get_estimate(self.issue_keys[0]), 11))
        self.assertEqual(jira.get_estimate(self.issue_keys[1]), 8)
        self.assertEqual(jira.get_estimate(self.issue_keys[2]), None)

        # Abe removes an issue from the sprint, the parent's issue resets its
        # estimate to None
        jira.remove_issues_from_sprint([self.issue_keys[0]])
        self.wait_for(lambda: self.assertEqual(
            jira.get_estimate(self.issue_keys[0]), None))
        self.assertEqual(jira.get_estimate(self.issue_keys[1]), 8)
        self.assertEqual(jira.get_estimate(self.issue_keys[2]), None)