Ejemplo n.º 1
0
    def test_pop_top_item_from_list_of_stories(self):
        story1 = UserStory('story1')
        story2 = UserStory('story2')
        self.backlog.add_issue(story1)
        self.backlog.add_issue(story2)

        self.assertEqual(self.backlog.pick_top_issue().name, 'story1')
Ejemplo n.º 2
0
    def generate_user_story(self, index):
        name = 'story_' + str(index + 1)
        key = 'key_' + str(index + 1)

        user_story = UserStory(name)

        user_story.key = key
        user_story.set_completion_time(self._team_params["story_cycle_time"])

        return user_story
Ejemplo n.º 3
0
    def setUp(self) -> None:
        team = Mock()
        team.wip_limit = 3
        team.prob_for_taking_stories_when_busy = 0.5

        self.person = Person("Person 1", team)

        # Access list of 1 stories, then toss 1, then access a list again
        self.randrange_orig = random.randrange
        random.randrange = Mock()
        random.randrange.side_effect = [0, 1, 0]

        self.backlog_mock = Mock()

        user_story = UserStory(self._name)
        user_story.key = self._key
        user_story.set_completion_time(self._completion_time)
        self.backlog_mock.pick_top_issue.return_value = user_story
Ejemplo n.º 4
0
 def test_user_story_creation(self):
     user_story = UserStory(self._name)
     self.assertEqual(user_story.name, self._name)
     self.assertEqual(user_story.epic, None)
     self.assertEqual(user_story.key, None)
     self.assertEqual(user_story.status, 'ToDo')
     self.assertEqual(user_story.assignee, '')
     self.assertEqual(user_story.time_left, None)
     self.assertEqual(user_story._completion_time, None)
     self.assertEqual(user_story._done_in_parallel, False)
Ejemplo n.º 5
0
    def test_parallelism(self, transition_table_mock):
        # Only key1, starts with 3 days, becomes 2 days
        self.person.pick_story_for_today_and_work(self._day, self.backlog_mock,
                                                  transition_table_mock)

        # Story story2 is added
        # story1 time_left increases from 2 to 3, then it is worked on, so time_left becomes 2
        # story2 increases from 3 to 4 and stays like that
        user_story = UserStory('story2')
        user_story.key = 'key2'
        user_story.set_completion_time(self._completion_time)
        self.backlog_mock.pick_top_issue.return_value = user_story

        self.person.pick_story_for_today_and_work(self._day, self.backlog_mock,
                                                  transition_table_mock)

        self.assertEqual(self.person.stories_in_progress[0].time_left,
                         self._completion_time - 1)
        self.assertEqual(self.person.stories_in_progress[1].time_left,
                         self._completion_time + 1)
Ejemplo n.º 6
0
    def generate_hierarchy(self, epics_num, user_stories_per_epic,
                           prob_for_ShS_delay, avg_ShS_delay):
        for e in range(epics_num):
            curr_epic = Epic(self.create_epic_name(e + 1))
            self.epic_backlog.add_issue(curr_epic)

            for s in range(user_stories_per_epic):
                curr_story = UserStory(
                    self.create_user_story_name(s + 1, curr_epic), curr_epic)

                # Tsafi 12 Feb 2020: random decision if should add delay:
                should_add_wait = False
                if prob_for_ShS_delay > 0 and avg_ShS_delay > 0:
                    if random.randrange(100) <= (prob_for_ShS_delay * 100):
                        should_add_wait = True

                # Tsafi 12 Feb 2020: if needed - add the delay
                if should_add_wait:
                    curr_story.wait += avg_ShS_delay

                curr_epic.add_story(curr_story)

        self.prioritize_user_stories()
Ejemplo n.º 7
0
class TestUserStory(unittest.TestCase):
    _name = 'story1'
    _key = 'SP-1'
    _completion_time = 3

    def setUp(self) -> None:
        self.us = UserStory(self._name)
        self.us.set_completion_time(self._completion_time)
        self.us.key = self._key

        self.transition_table_mock = Mock()

    def work_till_done(self):
        for x in range(self._completion_time):
            self.us.work_one_day()

    def test_user_story_creation(self):
        user_story = UserStory(self._name)
        self.assertEqual(user_story.name, self._name)
        self.assertEqual(user_story.epic, None)
        self.assertEqual(user_story.key, None)
        self.assertEqual(user_story.status, 'ToDo')
        self.assertEqual(user_story.assignee, '')
        self.assertEqual(user_story.time_left, None)
        self.assertEqual(user_story._completion_time, None)
        self.assertEqual(user_story._done_in_parallel, False)

    def test_user_story_creation_whith_epic(self):
        epic = Mock()
        user_story = UserStory(self._name, epic)

        self.assertEqual(user_story.epic, epic)

    def test_does_not_become_done_on_creation(self):
        self.assertFalse(self.us.just_became_done())

    def test_work_one_day(self):
        self.us.work_one_day()
        self.assertEqual(self.us.time_left, self._completion_time - 1)
        self.assertFalse(self.us.just_became_done())

    def test_work_till_done(self):
        self.work_till_done()

        self.assertTrue(self.us.just_became_done())

    def test_work_till_done_ask_twice(self):
        self.work_till_done()

        self.assertTrue(self.us.just_became_done())

        # Simulate transition update
        self.us.status = 'Done'

        # For the second time, just became done is not relevant anymore
        self.assertFalse(self.us.just_became_done())

    def test_work_too_much(self):
        for x in range(self._completion_time + 2):
            self.us.work_one_day()

        self.assertTrue(self.us.just_became_done())

    def test_parallelism_first_time(self):
        self.us.update_worked_on_in_parallel()
        self.assertEqual(self.us.time_left, self._completion_time + 1)

    def test_parallelism_second_time(self):
        self.us.update_worked_on_in_parallel()
        self.us.update_worked_on_in_parallel()
        self.us.update_worked_on_in_parallel()
        self.assertEqual(self.us.time_left, self._completion_time + 1)

    def test_transition_update(self):
        self.us.update_status(1, 'ToDo', self.transition_table_mock)

        self.transition_table_mock.add_transition.assert_called_once_with(
            1, self._key, 'ToDo')
        self.assertEqual(self.us.status, 'ToDo')

    def test_transition_update_when_done(self):
        self.work_till_done()
        self.us.check_if_done_and_update(1, self.transition_table_mock)

        self.transition_table_mock.add_transition.assert_called_once_with(
            1, self._key, 'Done')
        self.assertEqual(self.us.status, 'Done')

    def test_completion_time_change(self):
        self.us.set_completion_time(self._completion_time + 2)

        self.assertEqual(self.us.time_left, self._completion_time + 2)
        self.assertEqual(self.us._completion_time, self._completion_time + 2)
Ejemplo n.º 8
0
    def test_user_story_creation_whith_epic(self):
        epic = Mock()
        user_story = UserStory(self._name, epic)

        self.assertEqual(user_story.epic, epic)
Ejemplo n.º 9
0
    def setUp(self) -> None:
        self.us = UserStory(self._name)
        self.us.set_completion_time(self._completion_time)
        self.us.key = self._key

        self.transition_table_mock = Mock()
Ejemplo n.º 10
0
 def test_pop_from_list_of_stories(self):
     story = UserStory('story1')
     self.backlog.add_issue(story)
     self.assertEqual(self.backlog.pick_top_issue().name, 'story1')
     self.assertEqual(len(self.backlog.list_of_issues), 0)