Exemplo n.º 1
0
    def setUp(self):
      
        self.p1 = Project(name='Test Project 1')
        self.p2 = Project(name='Test Project 2')
        
        self.p1.save()
        self.p2.save()

        self.p1.project_members.add(User.objects.get(pk=1))
        self.p2.project_members.add(User.objects.get(pk=2))
        self.p2.project_members.add(User.objects.get(pk=3))
        
        self.us1 = UserStory(name='User story A', 
                    planned=45, state=20, project=self.p1)
        self.us2 = UserStory(name='User story B', 
                    planned=30, state=30, project=self.p2)
        
        self.us1.save()
        self.us2.save()

        self.tc1 = TestCase(user_story=self.us1, priority=10)
        self.tc2 = TestCase(user_story=self.us2, priority=10)
        self.tc3 = TestCase(user_story=self.us2, priority=10)

        self.tc1.save()
        self.tc2.save()
        self.tc3.save()
Exemplo n.º 2
0
class TestUS49Base(SeleniumBase):
    def setUp(self):
        self.user = User(username = '******')
        self.passwd = 'hi'
        self.user.set_password(self.passwd)
        self.user.save()
        self.project = Project(name = 'A Project')
        self.project.save()
        self.project.project_members.add(self.user)
        self.project.save()
        self.iteration = Iteration(start_date = '1990-01-01',
                                   end_date = '2020-01-01',
                                   project = self.project)
        self.iteration.save()
        self.story = UserStory(name = 'ABC', project = self.project,
                               description = 'a userstory about abc',
                               iteration = self.iteration, planned = 42, rank = 1,
                               state = 10, blocked = True)
        self.story.save()
        task_states = dict((v, k) for (k, v) in Task.STATES)
        self.task_a = Task(name = "Task A", estimate = 8, remaining = 8,
                           state = task_states['In Progress'],
                           owner = self.user, user_story = self.story)
        self.task_a.save()
        self.task_b = Task(name = "Task B", estimate = 2, remaining = 2,
                           state = task_states['Defined'],
                           owner = self.user, user_story = self.story)
        self.task_b.save()

        super(TestUS49Base, self).setUp()
    def tearDown(self):
        self.project.delete()
        self.user.delete()
        super(TestUS49Base, self).tearDown()
Exemplo n.º 3
0
    def test_partial_case(self):
        it = Iteration(start_date=datetime.datetime.now(), end_date=datetime.datetime.now(), project=self.p1)
        it.save()
        us1 = UserStory(name='User story A', 
                    state=20, project=self.p1, iteration = it)
        us1.save()
        
        t1 = Task(name='Task 1 for US A', user_story = us1, owner= self.user1)
        t2 = Task(estimate=5, name='Task 2 for US A', user_story = us1, owner= self.user2)
        t3 = Task(estimate=10, name='Task 1 for US A', user_story = us1)
        for t in t1, t2, t3:
            t.save()



        tl1 = TaskLog(task=t1, summary="tasklog 1 for Task 1A", time_on_task=1, date=datetime.datetime.now(), owner=self.user1, iteration=it)
        tl2 = TaskLog(task=t2, summary="tasklog 2 for Task 2A", time_on_task=2, date=datetime.datetime.now(), 
owner=self.user1, iteration=it)
        for tl in tl1, tl2:
            tl.save()

        self.assertEqual(it.estimated_without_owner, 10)
        self.assertEqual(it.user_estimated(self.user1.id), 0)
        self.assertEqual(it.user_progress(self.user1.id), 3)
        self.assertEqual(it.user_estimated(self.user2.id), 5)
        self.assertEqual(it.user_progress(self.user2.id), 0)
        self.assertEqual(it.users_total_status, 
            [{'name':self.user1.username,'progress':3, 'estimated':0},
             {'name':self.user2.username,'progress':0, 'estimated':5},
             {'name':'no owner','progress':'', 'estimated':10},
            ]        
        )
Exemplo n.º 4
0
 def test_start_case(self):
     it = Iteration(start_date=datetime.datetime.now(), end_date=datetime.datetime.now(), project=self.p1)
     it.save()
     us1 = UserStory(name='User story A', project=self.p1, iteration = it)
     us2 = UserStory(name='User story B', planned=10, project=self.p1, iteration = it)
     us3 = UserStory(name='User story C', planned=15, project=self.p1, iteration = it)
     us1.save()
     us2.save()
     us3.save()
     self.assertEqual(it.us_accepted_percentage, 0)
Exemplo n.º 5
0
 def test_query_user_story_name(self):
     """ 
     Simple tests just check if there exists a UserStory with a name
     containing the word 'owner'
     """
     query = "name:owner"
     self.assert_(len(UserStory.query(query)) > 0)
Exemplo n.º 6
0
 def setUp(self):
     self.passwd = 'hola' # random_name()
     self.user = User(username=random_name())
     self.user.set_password(self.passwd)
     self.user.save()
     self.proj1 = Project(name=random_name())
     self.proj2 = Project(name=random_name())
     for proj in self.proj1, self.proj2:
         proj.save()
         proj.project_members.add(self.user)
         proj.save()
     self.us1 = UserStory(name=random_name(), project=self.proj1)
     self.us1.save()
     self.us2 = UserStory(name=random_name(), project=self.proj2)
     self.us2.save()
     super(TestUS21, self).setUp()
Exemplo n.º 7
0
def backlog(request, project_id):
    user_stories = UserStory.backlogged(project=project_id).order_by('position')

    planned = sum(i.planned for i in user_stories if i.planned)
    todo = sum(i.remaining for i in user_stories)
    estimated = sum(i.estimated for i in user_stories)
    actuals = sum(i.actuals for i in user_stories)
    failures = sum(i.test_failed for i in user_stories)

    context = AgilitoContext(
        request,
        current_project=project_id,
        dictionary={
            'planned' : planned,
            'remaining' : todo,
            'estimated' : estimated,
            'actuals' : actuals,
            'failures' : failures,
        }
    )

    return list_detail.object_list(
        request,
        user_stories,
        template_name = 'agilito/backlog.html',
        extra_context = context
    )
Exemplo n.º 8
0
 def test_query_user_story_id(self):
     """
     Check if the US30 exists
     """
     query = "id:30"
     result = UserStory.query(query)
     self.assertEqual(len(result), 1)
     self.assertEqual(result[0].id, 30)
Exemplo n.º 9
0
    def setUp(self):
        self.user = User(username='******')
        self.passwd = 'hi'
        self.user.set_password(self.passwd)
        self.user.save()
        self.project = Project(name='A Project BB')
        self.project.save()
        self.project.project_members.add(self.user)
        self.project.save()

        self.story1 = UserStory(name='User Story A', rank=3, planned=3, project=self.project)
        self.story1.save()
        self.story2 = UserStory(name='User Story B', rank=2, planned=8, project=self.project)
        self.story2.save()
        self.story3 = UserStory(name='User Story C', rank=1, planned=5, project=self.project)
        self.story3.save()
                           
        super(TestBacklogAddUSDetailed, self).setUp()
Exemplo n.º 10
0
    def setUp(self):
      
        self.p1 = Project(name='Test Project 1')
        self.p2 = Project(name='Test Project 2')
        
        self.p1.save()
        self.p2.save()

        self.p1.project_members.add(User.objects.get(pk=1))
        self.p2.project_members.add(User.objects.get(pk=2))
        self.p2.project_members.add(User.objects.get(pk=3))
        
        self.us1 = UserStory(name='User story A', 
                    planned=45, state=20, project=self.p1)
        self.us2 = UserStory(name='User story B', 
                    planned=30, state=30, project=self.p2)
        
        self.us1.save()
        self.us2.save()
Exemplo n.º 11
0
class TestTaskForm(test.TestCase):
    fixtures = ['database_dump.json']

    def setUp(self):
      
        self.p1 = Project(name='Test Project 1')
        self.p2 = Project(name='Test Project 2')
        
        self.p1.save()
        self.p2.save()

        self.p1.project_members.add(User.objects.get(pk=1))
        self.p2.project_members.add(User.objects.get(pk=2))
        self.p2.project_members.add(User.objects.get(pk=3))
        
        self.us1 = UserStory(name='User story A', 
                    planned=45, state=20, project=self.p1)
        self.us2 = UserStory(name='User story B', 
                    planned=30, state=30, project=self.p2)
        
        self.us1.save()
        self.us2.save()

    def tearDown(self):
    
        for obj in self.us1, self.us2, self.p1, self.p2:
            obj.delete()

    def test_task_form_has_only_relevant_owners_simple(self):
        form = TaskForm(project=self.p1)
        owner_choices = list(form.fields['owner'].choices)
        self.assertEqual(len(owner_choices), 2)
        self.assertEqual(owner_choices[1][1], User.objects.get(pk=1).__str__())

    def test_task_form_has_only_relevant_owners_w_instance_simple(self):
        t1 = Task(name='Task 1 for US A', user_story = self.us1, owner=User.objects.get(pk=2))
        form = TaskForm(project=self.p2, instance=t1)
        owner_choices = list(form.fields['owner'].choices)
        self.assertEqual(len(owner_choices), 3)
        self.assertEqual(owner_choices[1][1], User.objects.get(pk=2).__str__())
        self.assertEqual(owner_choices[2][1], User.objects.get(pk=3).__str__())
Exemplo n.º 12
0
    def test_complete_case(self):
        it = Iteration(start_date=datetime.datetime.now(), end_date=datetime.datetime.now(), project=self.p1)
        it.save()
        us1 = UserStory(name='User story A', 
                    planned=45, state=20, project=self.p1, iteration = it)
        us2 = UserStory(name='User story B', 
                    planned=30, state=30, project=self.p1, iteration = it)
        us1.save()
        us2.save()
        t1 = Task(estimate=10, name='Task 1 for US A', user_story = us1, owner= self.user1)
        t2 = Task(estimate=5, name='Task 2 for US A', user_story = us1, owner= self.user2)
        t3 = Task(estimate=1, name='Task 1 for US B', user_story = us2, owner= self.user1)
        t4 = Task(estimate=2, name='Task 2 for US B', user_story = us2, owner= self.user2)
        t5 = Task(estimate=5, name='Task 2 for US B', user_story = us2)
        t6 = Task(estimate=4, name='Task 2 for US B', user_story = us2)
        for t in t1, t2, t3, t4, t5, t6:
            t.save()
        tl1 = TaskLog(task=t1, summary="tasklog 1 for Task 1A", time_on_task=1, date=datetime.datetime.now(), owner=self.user1, iteration=it)
        tl2 = TaskLog(task=t2, summary="tasklog 2 for Task 2A", time_on_task=2, date=datetime.datetime.now(), owner=self.user1, iteration=it)
        tl3 = TaskLog(task=t3, summary="tasklog 1 for Task 1B", time_on_task=3, date=datetime.datetime.now(), owner=self.user2, iteration=it)
        tl4 = TaskLog(task=t4, summary="tasklog 2 for Task 2B", time_on_task=5, date=datetime.datetime.now(), owner=self.user2, iteration=it)        
        for tl in tl1, tl2, tl3, tl4:
            tl.save()

        self.assertEqual(it.estimated_without_owner, 9)
        self.assertEqual(it.user_estimated(self.user1.id), 11)
        self.assertEqual(it.user_estimated(self.user2.id), 7)
        self.assertEqual(it.user_progress(self.user1.id), 3)
        self.assertEqual(it.user_progress(self.user2.id), 8)
        self.assertEqual(it.users_total_status, 
            [{'name':self.user1.username,'progress':3, 'estimated':11},
             {'name':self.user2.username,'progress':8, 'estimated':7},
             {'name':'no owner','progress':'', 'estimated':9},
            ]        
        )
Exemplo n.º 13
0
    def test_edit_change_us(self):

        other_story = UserStory(name='DEF', project=self.project,
                                description='a userstory about def',
                                iteration=self.iteration, planned=42, rank=2,
                                state=20, blocked=False)
        other_story.save()

        test_case = TestCase(name='ABC Test', description='Test', priority=10,
                             user_story=self.story)
        test_case.save()

        pk = test_case.id        

        pre = TestCase.objects.count()
        b = self.browser
        b.click("link=Iteration")
        b.wait()
        b.click("link=ABC")
        b.wait()
        b.click("xpath=id('edit_testcase_%d')/a/img" % (test_case.id))
        b.wait()
        b.type("id_name", "hi")
        b.type("id_description", "bye")
        b.select("id_user_story", "US2: DEF")
        self.assertEqual(b.get_selected_label("id_user_story"), "US2: DEF") 
        b.click("css=#content input[type=submit]")
        for i in xrange(15):        
            b.wait()
        self.assertEqual(TestCase.objects.count(), pre)

        # reload test_case
        test_case = TestCase.objects.get(pk=pk)
        self.assertEqual(test_case.name, 'hi')
        self.assertEqual(test_case.description, 'bye')
        self.assertEqual(test_case.user_story.id, other_story.id)

        test_case.delete()
        other_story.delete()
Exemplo n.º 14
0
class TestUS21(SeleniumBase):
    def setUp(self):
        self.passwd = 'hola' # random_name()
        self.user = User(username=random_name())
        self.user.set_password(self.passwd)
        self.user.save()
        self.proj1 = Project(name=random_name())
        self.proj2 = Project(name=random_name())
        for proj in self.proj1, self.proj2:
            proj.save()
            proj.project_members.add(self.user)
            proj.save()
        self.us1 = UserStory(name=random_name(), project=self.proj1)
        self.us1.save()
        self.us2 = UserStory(name=random_name(), project=self.proj2)
        self.us2.save()
        super(TestUS21, self).setUp()

    def tearDown(self):
        for obj in self.user, self.proj1, self.proj2, self.us1, self.us2:
            obj.delete()
        super(TestUS21, self).tearDown()

    def test_user_assigned_to_multiple_projects_switch_to_other_project(self):
        us_locator = "css=#user-story-list td.name a"
        b = self.browser
        b.click("link=Backlog")
        b.wait()
        this_us = b.get_text(us_locator)
        if this_us == self.us1.name:
            target_project, target_story = self.proj2, self.us2
        else:
            assert this_us == self.us2.name
            target_project, target_story = self.proj1, self.us1
        b.select("//li[@id='project-selection']/select",
                 "label=" + target_project.name)
        b.wait()
        self.assertEqual(b.get_text(us_locator), target_story.name)
Exemplo n.º 15
0
    def setUp(self):
        self.p1 = Project(name='Test Project 1')
        self.p2 = Project(name='Test Project 2')
        
        self.p1.save()
        self.p2.save()
        
        self.us1 = UserStory(name='User story A', 
                    planned=45, state=20, project=self.p1)
        self.us2 = UserStory(name='User story B', 
                    planned=30, state=30, project=self.p2)
        self.us3 = UserStory(name='User story C', 
                    planned=30, state=30, project=self.p2)
        
        self.us1.save()
        self.us2.save()
        self.us3.save()

        self.tc1 = TestCase(user_story=self.us1, priority=10)
        self.tc2 = TestCase(user_story=self.us2, priority=10)

        self.tc1.save()
        self.tc2.save()
Exemplo n.º 16
0
def metaWeblog_newPost(blogid, username, password, struct, publish):
    user = authenticate(username, password)

    projectID, category = blogid.split(':')
    project = getProject(user, projectID)

    story = UserStory()
    story.project = project
    story.name = struct['title']
    story.description = struct['description']
    story.save()

    return str(story.id)
Exemplo n.º 17
0
class TestTestCaseEditForm(test.TestCase):
    fixtures = ['database_dump.json']

    def setUp(self):
        self.p1 = Project(name='Test Project 1')
        self.p2 = Project(name='Test Project 2')
        
        self.p1.save()
        self.p2.save()
        
        self.us1 = UserStory(name='User story A', 
                    planned=45, state=20, project=self.p1)
        self.us2 = UserStory(name='User story B', 
                    planned=30, state=30, project=self.p2)
        self.us3 = UserStory(name='User story C', 
                    planned=30, state=30, project=self.p2)
        
        self.us1.save()
        self.us2.save()
        self.us3.save()

        self.tc1 = TestCase(user_story=self.us1, priority=10)
        self.tc2 = TestCase(user_story=self.us2, priority=10)

        self.tc1.save()
        self.tc2.save()


    def tearDown(self):
        for obj in self.tc1, self.tc2, self.us1, self.us2, self.p1, self.p2:
            obj.delete()

    def test_test_case_edit_form_has_current_project_us_only(self):
        form = TestCaseEditForm(project=self.tc1.user_story.project, instance=self.tc1)
        user_story_choices = list(form.fields['user_story'].choices)
        self.assertEqual(len(user_story_choices), 2)
        self.assertEqual(user_story_choices[1][1], unicode(self.us1))

    def test_test_case_edit_form_has_current_project_us_only_other(self):
        form = TestCaseEditForm(project=self.tc2.user_story.project, instance=self.tc2)
        user_story_choices = list(form.fields['user_story'].choices)
        self.assertEqual(len(user_story_choices), 3)
        self.assert_(unicode(self.us2) in set([user_story_choices[1][1], user_story_choices[2][1]]))
        self.assert_(unicode(self.us3) in set([user_story_choices[1][1], user_story_choices[2][1]]))
Exemplo n.º 18
0
class TestBacklogAddUSDetailed(SeleniumBase):
    def setUp(self):
        self.user = User(username='******')
        self.passwd = 'hi'
        self.user.set_password(self.passwd)
        self.user.save()
        self.project = Project(name='A Project BB')
        self.project.save()
        self.project.project_members.add(self.user)
        self.project.save()

        self.story1 = UserStory(name='User Story A', rank=3, planned=3, project=self.project)
        self.story1.save()
        self.story2 = UserStory(name='User Story B', rank=2, planned=8, project=self.project)
        self.story2.save()
        self.story3 = UserStory(name='User Story C', rank=1, planned=5, project=self.project)
        self.story3.save()
                           
        super(TestBacklogAddUSDetailed, self).setUp()

    def tearDown(self):
        self.project.delete()
        self.user.delete()
        for x in self.story1, self.story2, self.story3:
            x.delete()
        super(TestBacklogAddUSDetailed, self).tearDown()
        
    def test_create_complete_us(self):
        self.login(username='******', password='******')
        b = self.browser
        b.click("link=Backlog")
        b.wait()
        b.click("create-detailed-user-story")
        b.type("id_name", "A sample detailed user story")
        b.type("id_description", "This is a detailed user story")
        b.type("id_planned", "10")
        b.type("id_rank", "50")
        b.type("id_state", "10")
        b.click("id_blocked")
        b.click("us-create")
        self.assertEqual(b.get_text("us-span-4"),
                         "A sample detailed user story")
Exemplo n.º 19
0
class TestBacklogQuickAdd(SeleniumBase):
    def setUp(self):
        self.user = User(username='******')
        self.passwd = 'hi'
        self.user.set_password(self.passwd)
        self.user.save()
        self.project = Project(name='A Project')
        self.project.save()
        self.project.project_members.add(self.user)
        self.project.save()

        self.story1 = UserStory(name='User Story A', rank=3, planned=3, project=self.project)
        self.story1.save()
        self.story2 = UserStory(name='User Story B', rank=2, planned=8, project=self.project)
        self.story2.save()
        self.story3 = UserStory(name='User Story C', rank=1, planned=5, project=self.project)
        self.story3.save()
                           
        super(TestBacklogQuickAdd, self).setUp()

    def tearDown(self):
        self.project.delete()
        self.user.delete()
        for x in self.story1, self.story2, self.story3:
            x.delete()
        super(TestBacklogQuickAdd, self).tearDown()
        
    def test_tc4(self):
        self.login(username='******', password='******')
        #sel.open("/accounts/login/")
        #sel.type("id_username", "User B")
        #sel.type("id_password", "hi")
        #sel.click("//input[@value='login']")
        b = self.browser
        b.click("link=Backlog")
        b.wait()
        b.click("create-user-story")
        b.type("id_name", "A sample user story")
        b.click("us-create")
        self.assertEqual(b.get_text("us-span-4"),
                         "A sample user story")
Exemplo n.º 20
0
def storysize(s):
    if not UNRESTRICTED_SIZE and s == UserStory.SIZES.INFINITY:
        return mark_safe('∞')

    return UserStory.size_label_for(s)
Exemplo n.º 21
0
class TestTestResultForm(test.TestCase):
    fixtures = ['database_dump.json']

    def setUp(self):
      
        self.p1 = Project(name='Test Project 1')
        self.p2 = Project(name='Test Project 2')
        
        self.p1.save()
        self.p2.save()

        self.p1.project_members.add(User.objects.get(pk=1))
        self.p2.project_members.add(User.objects.get(pk=2))
        self.p2.project_members.add(User.objects.get(pk=3))
        
        self.us1 = UserStory(name='User story A', 
                    planned=45, state=20, project=self.p1)
        self.us2 = UserStory(name='User story B', 
                    planned=30, state=30, project=self.p2)
        
        self.us1.save()
        self.us2.save()

        self.tc1 = TestCase(user_story=self.us1, priority=10)
        self.tc2 = TestCase(user_story=self.us2, priority=10)
        self.tc3 = TestCase(user_story=self.us2, priority=10)

        self.tc1.save()
        self.tc2.save()
        self.tc3.save()

    def tearDown(self):
        for obj in self.tc1, self.tc2, self.tc3, self.us1, self.us2, self.p1, self.p2:
            obj.delete()

    def test_test_result_form_only_test_cases_of_current_project_simple(self):
        form = TestResultForm(project=self.p1)
        test_case_choices = list(form.fields['test_case'].choices)
        self.assertEqual(len(test_case_choices), 2)
        self.assertEqual(test_case_choices[1][1], unicode(self.tc1))
        tester_choices = list(form.fields['tester'].choices)
        self.assertEqual(len(tester_choices), 2)
        self.assertEqual(tester_choices[1][1], User.objects.get(pk=1).__str__())        


    def test_test_result_form_build_with_instance_has_only_test_cases_of_current_project(self):
        test_result = TestResult(result=10, test_case=self.tc1, tester=User.objects.all()[0])
        form = TestResultForm(project=self.p1,instance=test_result)
        test_case_choices = list(form.fields['test_case'].choices)
        self.assertEqual(len(test_case_choices), 2)
        self.assertEqual(test_case_choices[1][1], unicode(self.tc1))
        tester_choices = list(form.fields['tester'].choices)
        self.assertEqual(len(tester_choices), 2)
        self.assertEqual(tester_choices[1][1], User.objects.get(pk=1).__str__())        


    def test_test_result_form_only_test_cases_of_current_project_other(self):
        form = TestResultForm(project=self.p2)
        test_case_choices = list(form.fields['test_case'].choices)
        self.assertEqual(len(test_case_choices), 3)
        self.assert_(unicode(self.tc2) in set([test_case_choices[1][1], test_case_choices[2][1]]))
        tester_choices = list(form.fields['tester'].choices)
        self.assertEqual(len(tester_choices), 3)
        self.assertEqual(tester_choices[1][1], User.objects.get(pk=2).__str__())        
Exemplo n.º 22
0
class TestUS254(TestUS49Base):

    def setUp(self):
        super(TestUS254, self).setUp()

        self.user_story_states = dict((v,k) for (k,v) in UserStory.STATES)

        self.story_2 = UserStory(name='TestUS254 A', project=self.project,
                               description='a userstory to test us254',
                               iteration=self.iteration, planned=42, rank=1,
                               state=10, blocked=False)
        self.story_2.save()

        self.story_3 = UserStory(name='TestUS254 B', project=self.project,
                               description='another userstory to test us254',
                               iteration=self.iteration, planned=42, rank=1,
                               state=10, blocked=False)
        self.story_3.save()

        self.story_4 = UserStory(name='TestUS254 C', project=self.project,
                               description='yet another userstory to test us254',
                               iteration=self.iteration, planned=42, rank=1,
                               state=10, blocked=False)
        self.story_4.save()

        self.story_5 = UserStory(name='TestUS254 D', project=self.project,
                               description='again, yet another userstory to test us254',
                               iteration=self.iteration, planned=42, rank=1,
                               state=10, blocked=False)
        self.story_5.save()

        
        self.task_states = dict((v,k) for (k,v) in Task.STATES)

        # actuals > 0, not completed -> change state to In progress

        self.task_c = Task(name="Task C", estimate=8, remaining=6,
                           state=self.task_states['Defined'],
                           owner=self.user, user_story=self.story_2)
        self.task_c.save()

        self.tasklog_c = TaskLog(task=self.task_c, time_on_task=2, summary='test',
                                 date=datetime.today(), owner=self.user,
                                 old_remaining=0)

        self.tasklog_c.save()

        # actuals > 0, completed, remaining > 0, all task in us completed -> 
        # should change US to complete and change task to complete, remaining 0

        self.task_d = Task(name="Task D", estimate=2, remaining=2,
                           state=self.task_states['Complete'],
                           owner=self.user, user_story=self.story_3)
        self.task_d.save()

        self.task_f = Task(name="Task F", estimate=2, remaining=0,
                           state=self.task_states['Complete'],
                           owner=self.user, user_story=self.story_3)
        self.task_f.save()

        self.tasklog_f = TaskLog(task=self.task_f, time_on_task=2, summary='test',
                                 date=datetime.today(), owner=self.user,
                                 old_remaining=0)

        self.tasklog_f.save()

        self.tasklog_d = TaskLog(task=self.task_d, time_on_task=2, summary='test',
                                 date=datetime.today(), owner=self.user,
                                 old_remaining=0)

        self.tasklog_d.save()


        # actuals > 0, defined, remaining = 0, not all task in us completed 
        # should change to complete.                           
        self.task_e = Task(name="Task E", estimate=2, remaining=0,
                           state=self.task_states['Defined'],
                           owner=self.user, user_story=self.story_2)
        self.task_e.save()

        self.tasklog_e = TaskLog(task=self.task_e, time_on_task=2, summary='test',
                                 date=datetime.today(), owner=self.user,
                                 old_remaining=0)

        self.tasklog_e.save()

        # actuals > 0, in progress, remaining = 0, not all task in us completed 
        # should change to complete.   
        self.task_g = Task(name="Task G", estimate=2, remaining=0,
                           state=self.task_states['In Progress'],
                           owner=self.user, user_story=self.story_2)
        self.task_g.save()

        self.tasklog_g = TaskLog(task=self.task_g, time_on_task=2, summary='test',
                                 date=datetime.today(), owner=self.user,
                                 old_remaining=0)

        self.tasklog_g.save()



    def tearDown(self):
        super(TestUS254, self).tearDown()
        for obj in self.tasklog_f, self.tasklog_e, self.tasklog_d, self.tasklog_c,\
            self.task_g, self.task_f, self.task_e, self.task_d, self.task_c,\
            self.story_5, self.story_4, self.story_3, self.story_2:
            obj.delete() 

    def test_adding_a_task_in_progress_changes_us_to_in_progress(self):
        b = self.browser
        b.click("link=Iteration")
        b.wait()

        b.click("link=TestUS254 D")
        b.wait()        

        b.click("link=add a task")
        b.wait()

        b.type("id_name", "A sample detailed task")
        b.type("id_description", "This is a detailed task")
        b.type("id_estimate", "10")
        b.type("id_remaining", "10")
        b.type("id_state", "20")
        b.click("xpath=id('content')/form/input")
        b.wait()

        obj = UserStory.objects.get(id=self.story_5.id)
        self.assertEqual(obj.state, 20)

    def test_adding_a_task_in_progress_and_one_task_complete_changes_us_to_in_progress(self):
        b = self.browser
        b.click("link=Iteration")
        b.wait()

        b.click("link=TestUS254 D")
        b.wait()        
        last_location = b.get_location()

        b.click("link=add a task")
        b.wait()

        b.type("id_name", "A sample detailed task")
        b.type("id_description", "This is a detailed task")
        b.type("id_estimate", "10")
        b.type("id_remaining", "10")
        b.type("id_state", "20")
        b.click("xpath=id('content')/form/input")
        b.wait()

        obj = UserStory.objects.get(id=self.story_5.id)
        self.assertEqual(obj.state, 20)
        self.assertEqual(last_location, b.get_location())

        b.click("link=add a task")
        b.wait()

        b.type("id_name", "A sample detailed task")
        b.type("id_description", "This is a detailed task")
        b.type("id_estimate", "10")
        b.type("id_remaining", "0")
        b.type("id_state", "30")
        b.click("xpath=id('content')/form/input")
        b.wait()

        obj = UserStory.objects.get(id=self.story_5.id)
        self.assertEqual(obj.state, 20)

 
    def test_adding_a_task_define_does_not_change_state_of_us(self):
        b = self.browser
        b.click("link=Iteration")
        b.wait()

        b.click("link=TestUS254 D")
        b.wait()        

        b.click("link=add a task")
        b.wait()

        b.type("id_name", "A sample detailed task")
        b.type("id_description", "This is a detailed task")
        b.type("id_estimate", "10")
        b.type("id_remaining", "10")
        b.type("id_state", "10")
        b.click("xpath=id('content')/form/input")
        b.wait()

        obj = UserStory.objects.get(id=self.story_5.id)
        self.assertEqual(obj.state, 10)

    def test_editing_task_with_actuals_sets_from_defined_to_complete(self):
        # Task has actuals > 0 is on state defined should change state to 'In Progress'
        # Should change story to 'In Progress'

        b = self.browser
        b.click("link=Iteration")
        b.wait()

        b.click("link=TestUS254 A")
        b.wait()        

        b.click("xpath=id('task_edit_%d')/img" % self.task_c.id)
        b.wait()

        b.click("xpath=id('content')/form/input")
        b.wait()

        # Reload obj task, self.task_c is on a stale state:
        obj = Task.objects.get(id=self.task_c.id)
        # Check that only that the state changed
        self.assertEqual(obj.name, "Task C")
        self.assertEqual(obj.description, '')
        self.assertEqual(obj.estimate, 8)
        self.assertEqual(obj.remaining, 6)
        self.assertEqual(obj.owner, self.user)
        self.assertEqual(obj.user_story, self.story_2)
        self.assertEqual(obj.state, self.task_states['In Progress'])  
        self.assertEqual(obj.user_story.state, self.user_story_states['In Progress'])

    def test_editing_task_with_actuals_and_in_complete_state_sets_remaining_to_zero(self):
        # Task has actuals > 0, is completed, and has remaining > 0. 
        # All task in us completed. (There are two) 
        # should change US to complete and change task to complete, remaining 0
        
        b = self.browser
        b.click("link=Iteration")
        b.wait()

        b.click("link=TestUS254 B")
        b.wait()        

        b.click("xpath=id('task_edit_%d')/img" % self.task_d.id)
        b.wait()

        b.click("xpath=id('content')/form/input")
        b.wait()

        # Reload obj task, self.task_c is on a stale state:
        obj = Task.objects.get(id=self.task_d.id)
        # Check that nothing else changed except that which should
        self.assertEqual(obj.name, "Task D")
        self.assertEqual(obj.description, '')
        self.assertEqual(obj.estimate, 2)
        self.assertEqual(obj.remaining, 0)
        self.assertEqual(obj.owner, self.user)
        self.assertEqual(obj.user_story, self.story_3)
        self.assertEqual(obj.state, self.task_states['Complete'])  
        self.assertEqual(obj.user_story.state, self.user_story_states['Completed'])

    def test_editing_task_with_actuals_remaining_on_zero_in_defined_state_sets_state_to_complete(self):
        # Task has actuals > 0, is defined, and has remaining = 0. 
        # Not all task in us completed.
        # Should change US to In Progress and change task to complete, remaining 0

        
        b = self.browser
        b.click("link=Iteration")
        b.wait()

        b.click("link=TestUS254 A")
        b.wait()        

        b.click("xpath=id('task_edit_%d')/img" % self.task_e.id)
        b.wait()

        b.click("xpath=id('content')/form/input")
        b.wait()

        # Reload obj task, self.task_c is on a stale state:
        obj = Task.objects.get(id=self.task_e.id)
        # Check that nothing else changed except that which should
        self.assertEqual(obj.name, "Task E")
        self.assertEqual(obj.description, '')
        self.assertEqual(obj.estimate, 2)
        self.assertEqual(obj.remaining, 0)
        self.assertEqual(obj.owner, self.user)
        self.assertEqual(obj.user_story, self.story_2)
        self.assertEqual(obj.state, self.task_states['Complete'])  
        self.assertEqual(obj.user_story.state, self.user_story_states['In Progress'])

    def test_editing_task_with_actuals_remaining_on_zero_in_in_progress_state_sets_state_to_complete(self):
        # Task has actuals > 0, is in progress, and has remaining = 0. 
        # Not all task in us completed.
        # Should change US to In Progress and change task to complete, remaining 0
        
        b = self.browser
        b.click("link=Iteration")
        b.wait()

        b.click("link=TestUS254 A")
        b.wait()        

        b.click("xpath=id('task_edit_%d')/img" % self.task_g.id)
        b.wait()

        b.click("xpath=id('content')/form/input")
        b.wait()

        # Reload obj task, self.task_c is on a stale state:
        obj = Task.objects.get(id=self.task_g.id)
        # Check that nothing else changed except that which should
        self.assertEqual(obj.name, "Task G")
        self.assertEqual(obj.description, '')
        self.assertEqual(obj.estimate, 2)
        self.assertEqual(obj.remaining, 0)
        self.assertEqual(obj.owner, self.user)
        self.assertEqual(obj.user_story, self.story_2)
        self.assertEqual(obj.state, self.task_states['Complete'])  
        self.assertEqual(obj.user_story.state, self.user_story_states['In Progress'])
Exemplo n.º 23
0
    def setUp(self):
        super(TestUS254, self).setUp()

        self.user_story_states = dict((v,k) for (k,v) in UserStory.STATES)

        self.story_2 = UserStory(name='TestUS254 A', project=self.project,
                               description='a userstory to test us254',
                               iteration=self.iteration, planned=42, rank=1,
                               state=10, blocked=False)
        self.story_2.save()

        self.story_3 = UserStory(name='TestUS254 B', project=self.project,
                               description='another userstory to test us254',
                               iteration=self.iteration, planned=42, rank=1,
                               state=10, blocked=False)
        self.story_3.save()

        self.story_4 = UserStory(name='TestUS254 C', project=self.project,
                               description='yet another userstory to test us254',
                               iteration=self.iteration, planned=42, rank=1,
                               state=10, blocked=False)
        self.story_4.save()

        self.story_5 = UserStory(name='TestUS254 D', project=self.project,
                               description='again, yet another userstory to test us254',
                               iteration=self.iteration, planned=42, rank=1,
                               state=10, blocked=False)
        self.story_5.save()

        
        self.task_states = dict((v,k) for (k,v) in Task.STATES)

        # actuals > 0, not completed -> change state to In progress

        self.task_c = Task(name="Task C", estimate=8, remaining=6,
                           state=self.task_states['Defined'],
                           owner=self.user, user_story=self.story_2)
        self.task_c.save()

        self.tasklog_c = TaskLog(task=self.task_c, time_on_task=2, summary='test',
                                 date=datetime.today(), owner=self.user,
                                 old_remaining=0)

        self.tasklog_c.save()

        # actuals > 0, completed, remaining > 0, all task in us completed -> 
        # should change US to complete and change task to complete, remaining 0

        self.task_d = Task(name="Task D", estimate=2, remaining=2,
                           state=self.task_states['Complete'],
                           owner=self.user, user_story=self.story_3)
        self.task_d.save()

        self.task_f = Task(name="Task F", estimate=2, remaining=0,
                           state=self.task_states['Complete'],
                           owner=self.user, user_story=self.story_3)
        self.task_f.save()

        self.tasklog_f = TaskLog(task=self.task_f, time_on_task=2, summary='test',
                                 date=datetime.today(), owner=self.user,
                                 old_remaining=0)

        self.tasklog_f.save()

        self.tasklog_d = TaskLog(task=self.task_d, time_on_task=2, summary='test',
                                 date=datetime.today(), owner=self.user,
                                 old_remaining=0)

        self.tasklog_d.save()


        # actuals > 0, defined, remaining = 0, not all task in us completed 
        # should change to complete.                           
        self.task_e = Task(name="Task E", estimate=2, remaining=0,
                           state=self.task_states['Defined'],
                           owner=self.user, user_story=self.story_2)
        self.task_e.save()

        self.tasklog_e = TaskLog(task=self.task_e, time_on_task=2, summary='test',
                                 date=datetime.today(), owner=self.user,
                                 old_remaining=0)

        self.tasklog_e.save()

        # actuals > 0, in progress, remaining = 0, not all task in us completed 
        # should change to complete.   
        self.task_g = Task(name="Task G", estimate=2, remaining=0,
                           state=self.task_states['In Progress'],
                           owner=self.user, user_story=self.story_2)
        self.task_g.save()

        self.tasklog_g = TaskLog(task=self.task_g, time_on_task=2, summary='test',
                                 date=datetime.today(), owner=self.user,
                                 old_remaining=0)

        self.tasklog_g.save()