예제 #1
0
 def _testPostCommitRemaining(self):
     """Tests the post commit hook with remaining time command"""
     # Create a ticket of type task, and set it to assigned
     task = self.teh.create_ticket(Type.TASK, props={Key.OWNER: "tester", Key.REMAINING_TIME: "8"})
     # Create a file in the SVN reposoitory using the helper
     rev = self.teh.create_file("test_remaining.txt", "This is a test :-)", "tester", "Remaining #%d:4h" % task.id)
     apostc = AgiloSVNPostCommit(project=self.teh.get_env_path(), rev=rev, env=self.teh.get_env())
     apostc.execute()
     # Should set the task automatically to assigned
     task = self.teh.load_ticket(ticket=task)
     self.assertEqual(task[Key.REMAINING_TIME], "4")
     self.assertEqual(task[Key.STATUS], Status.ACCEPTED)
     # Now test with a wrong owner
     task = self.teh.create_ticket(Type.TASK, props={Key.OWNER: "somebody", Key.REMAINING_TIME: "8"})
     # Create a file in the SVN reposoitory using the helper
     rev = self.teh.create_file(
         "test_remaining_not_owner.txt", "This is a test :-)", "tester", "Remaining #%d:4h" % task.id
     )
     apostc = AgiloSVNPostCommit(project=self.teh.get_env_path(), rev=rev, env=self.teh.get_env())
     self.assertRaises(NotOwnerError, apostc.execute)
     # Now try to set remaining time on a Story
     story = self.teh.create_ticket(Type.USER_STORY)
     rev = self.teh.create_file(
         "test_remaining_story.txt", "This is a test :-)", "tester", "Remaining #%d:4h" % story.id
     )
     apostc = AgiloSVNPostCommit(project=self.teh.get_env_path(), rev=rev, env=self.teh.get_env())
     self.assertRaises(InvalidAttributeError, apostc.execute)
예제 #2
0
 def _testPostCommitClose(self):
     """Tests the post commit hook with close command"""
     # Create a ticket of type task, and set it to assigned
     task = self.teh.create_ticket(Type.TASK, props={Key.REMAINING_TIME: "2"})
     # Create a file in the SVN repository using the helper
     rev = self.teh.create_file("test_not_assigend.txt", "This is a test :-)", "tester", "Closes #%d" % task.id)
     apostc = AgiloSVNPostCommit(project=self.teh.get_env_path(), rev=rev, env=self.teh.get_env())
     # Execute the commands
     self.assertRaises(NotAssignedError, apostc.execute)
     # Now set the task to assigned, change owner and try again
     task = self.teh.create_ticket(Type.TASK, props={Key.REMAINING_TIME: "2"})
     task[Key.STATUS] = Status.ASSIGNED
     task[Key.OWNER] = "somebody"
     task.save_changes("somebody", "Accepted the ticket")
     rev = self.teh.create_file("test_not_owner.txt", "This is a test :-)", "tester", "Closes #%d" % task.id)
     apostc = AgiloSVNPostCommit(project=self.teh.get_env_path(), rev=rev, env=self.teh.get_env())
     self.assertRaises(NotOwnerError, apostc.execute)
     # Now set the right owner, should succeed
     task = self.teh.create_ticket(Type.TASK, props={Key.OWNER: "tester", Key.REMAINING_TIME: "2"})
     task[Key.STATUS] = Status.ASSIGNED
     task.save_changes("tester", "It is mine again")
     # The command execute will save again in less than one second...
     sleep(1)
     rev = self.teh.create_file("test_ok.txt", "This is a test :-)", "tester", "Closes #%d" % task.id)
     apostc = AgiloSVNPostCommit(project=self.teh.get_env_path(), rev=rev, env=self.teh.get_env())
     apostc.execute()
     # Reload the task from Trac
     task = self.teh.load_ticket(task)
     self.assertEqual(task[Key.STATUS], Status.CLOSED)
     self.assertEqual(task[Key.REMAINING_TIME], "0")
예제 #3
0
 def _testPostCommitMultipleDependencies(self):
     """Tests the post commit hook with multiple commands and dependencies"""
     story = self.teh.create_ticket(Type.USER_STORY, props={Key.STORY_POINTS: "13"})
     task1 = self.teh.create_ticket(Type.TASK, props={Key.OWNER: "tester", Key.REMAINING_TIME: "8"})
     task2 = self.teh.create_ticket(Type.TASK, props={Key.OWNER: "tester", Key.REMAINING_TIME: "4"})
     self.assertTrue(story.link_to(task1))
     self.assertTrue(story.link_to(task2))
     # Assign the task1, otherwise will not allow to close it
     task1[Key.STATUS] = Status.ASSIGNED
     task1.save_changes("tester", "Accepted the task...")
     # Assign the task2, otherwise will not allow to close it
     task2[Key.STATUS] = Status.ASSIGNED
     task2.save_changes("tester", "Accepted the task...")
     sleep(1)
     rev = self.teh.create_file(
         "test_multiple_ok.txt",
         "This is a test :-)",
         "tester",
         "This closes #%d and #%d, closes #%d for more details." % (task1.id, task2.id, story.id),
     )
     apostc = AgiloSVNPostCommit(project=self.teh.get_env_path(), rev=rev, env=self.teh.get_env())
     apostc.execute()
     # Reload the tickets from Trac
     task1 = self.teh.load_ticket(ticket=task1)
     task2 = self.teh.load_ticket(ticket=task2)
     story = self.teh.load_ticket(ticket=story)
     # Now check the commands have been executed successfully
     self.assertEqual(task1[Key.STATUS], Status.CLOSED)
     self.assertEqual(task1[Key.REMAINING_TIME], "0")
     self.assertEqual(task2[Key.STATUS], Status.CLOSED)
     self.assertEqual(task2[Key.REMAINING_TIME], "0")
     self.assertEqual(story[Key.STATUS], Status.CLOSED)
예제 #4
0
 def _testPostCommitMultipleCommands(self):
     """Tests the post commit hook with multiple commands combinations"""
     # Create a some tickets
     task1 = self.teh.create_ticket(Type.TASK, props={Key.OWNER: "tester", Key.REMAINING_TIME: "8"})
     task2 = self.teh.create_ticket(Type.TASK, props={Key.OWNER: "tester", Key.REMAINING_TIME: "4"})
     story = self.teh.create_ticket(Type.USER_STORY, props={Key.STORY_POINTS: "13"})
     # Assign the task1, otherwise will not allow to close it
     task1[Key.STATUS] = Status.ASSIGNED
     task1.save_changes("tester", "Accepted the task...")
     sleep(1)
     # Create a file in the SVN repository using the helper
     rev = self.teh.create_file(
         "test_multiple.txt",
         "This is a test :-)",
         "tester",
         "This closes #%d and remaining #%d:2h, see #%d for more details." % (task1.id, task2.id, story.id),
     )
     apostc = AgiloSVNPostCommit(project=self.teh.get_env_path(), rev=rev, env=self.teh.get_env())
     apostc.execute()
     # Reload the tickets from Trac
     task1 = self.teh.load_ticket(ticket=task1)
     task2 = self.teh.load_ticket(ticket=task2)
     story = self.teh.load_ticket(ticket=story)
     # Now check the commands have been executed successfully
     self.assertEqual(task1[Key.STATUS], Status.CLOSED)
     self.assertEqual(task1[Key.REMAINING_TIME], "0")
     self.assertEqual(task2[Key.STATUS], Status.ACCEPTED)
     self.assertEqual(task2[Key.REMAINING_TIME], "2")
예제 #5
0
 def _testPostCommitReference(self):
     """Tests the post commit hook with references command"""
     # Create a ticket of type task, and set it to assigned
     task = self.teh.create_ticket(Type.TASK, props={Key.REMAINING_TIME: "8"})
     # Create a file in the SVN repository using the helper
     rev = self.teh.create_file("test_reference.txt", "This is a test :-)", "tester", "See #%d" % task.id)
     apostc = AgiloSVNPostCommit(project=self.teh.get_env_path(), rev=rev, env=self.teh.get_env())
     apostc.execute()
예제 #6
0
 def _testPostCommitReference(self):
     """Tests the post commit hook with references command"""
     # Create a ticket of type task, and set it to assigned
     task = self.teh.create_ticket(Type.TASK,
                                   props={Key.REMAINING_TIME: '8'})
     # Create a file in the SVN repository using the helper
     rev = self.teh.create_file('test_reference.txt', "This is a test :-)",
                                'tester', "See #%d" % task.id)
     apostc = AgiloSVNPostCommit(project=self.teh.get_env_path(),
                                 rev=rev,
                                 env=self.teh.get_env())
     apostc.execute()
예제 #7
0
 def _testPostCommitClose(self):
     """Tests the post commit hook with close command"""
     # Create a ticket of type task, and set it to assigned
     task = self.teh.create_ticket(Type.TASK,
                                   props={Key.REMAINING_TIME: '2'})
     # Create a file in the SVN repository using the helper
     rev = self.teh.create_file('test_not_assigend.txt',
                                "This is a test :-)", 'tester',
                                "Closes #%d" % task.id)
     apostc = AgiloSVNPostCommit(project=self.teh.get_env_path(),
                                 rev=rev,
                                 env=self.teh.get_env())
     # Execute the commands
     self.assertRaises(NotAssignedError, apostc.execute)
     # Now set the task to assigned, change owner and try again
     task = self.teh.create_ticket(Type.TASK,
                                   props={Key.REMAINING_TIME: '2'})
     task[Key.STATUS] = Status.ASSIGNED
     task[Key.OWNER] = 'somebody'
     task.save_changes('somebody', 'Accepted the ticket')
     rev = self.teh.create_file('test_not_owner.txt', "This is a test :-)",
                                'tester', "Closes #%d" % task.id)
     apostc = AgiloSVNPostCommit(project=self.teh.get_env_path(),
                                 rev=rev,
                                 env=self.teh.get_env())
     self.assertRaises(NotOwnerError, apostc.execute)
     # Now set the right owner, should succeed
     task = self.teh.create_ticket(Type.TASK,
                                   props={
                                       Key.OWNER: 'tester',
                                       Key.REMAINING_TIME: '2'
                                   })
     task[Key.STATUS] = Status.ASSIGNED
     task.save_changes('tester', 'It is mine again')
     # The command execute will save again in less than one second...
     sleep(1)
     rev = self.teh.create_file('test_ok.txt', "This is a test :-)",
                                'tester', "Closes #%d" % task.id)
     apostc = AgiloSVNPostCommit(project=self.teh.get_env_path(),
                                 rev=rev,
                                 env=self.teh.get_env())
     apostc.execute()
     # Reload the task from Trac
     task = self.teh.load_ticket(task)
     self.assertEqual(task[Key.STATUS], Status.CLOSED)
     self.assertEqual(task[Key.REMAINING_TIME], '0')
예제 #8
0
 def _testPostCommitRemaining(self):
     """Tests the post commit hook with remaining time command"""
     # Create a ticket of type task, and set it to assigned
     task = self.teh.create_ticket(Type.TASK,
                                   props={
                                       Key.OWNER: 'tester',
                                       Key.REMAINING_TIME: '8'
                                   })
     # Create a file in the SVN reposoitory using the helper
     rev = self.teh.create_file('test_remaining.txt', "This is a test :-)",
                                'tester', "Remaining #%d:4h" % task.id)
     apostc = AgiloSVNPostCommit(project=self.teh.get_env_path(),
                                 rev=rev,
                                 env=self.teh.get_env())
     apostc.execute()
     # Should set the task automatically to assigned
     task = self.teh.load_ticket(ticket=task)
     self.assertEqual(task[Key.REMAINING_TIME], '4')
     self.assertEqual(task[Key.STATUS], Status.ACCEPTED)
     # Now test with a wrong owner
     task = self.teh.create_ticket(Type.TASK,
                                   props={
                                       Key.OWNER: 'somebody',
                                       Key.REMAINING_TIME: '8'
                                   })
     # Create a file in the SVN reposoitory using the helper
     rev = self.teh.create_file('test_remaining_not_owner.txt',
                                "This is a test :-)", 'tester',
                                "Remaining #%d:4h" % task.id)
     apostc = AgiloSVNPostCommit(project=self.teh.get_env_path(),
                                 rev=rev,
                                 env=self.teh.get_env())
     self.assertRaises(NotOwnerError, apostc.execute)
     # Now try to set remaining time on a Story
     story = self.teh.create_ticket(Type.USER_STORY)
     rev = self.teh.create_file('test_remaining_story.txt',
                                "This is a test :-)", 'tester',
                                "Remaining #%d:4h" % story.id)
     apostc = AgiloSVNPostCommit(project=self.teh.get_env_path(),
                                 rev=rev,
                                 env=self.teh.get_env())
     self.assertRaises(InvalidAttributeError, apostc.execute)
예제 #9
0
 def _testPostCommitMultipleDependencies(self):
     """Tests the post commit hook with multiple commands and dependencies"""
     story = self.teh.create_ticket(Type.USER_STORY,
                                    props={Key.STORY_POINTS: '13'})
     task1 = self.teh.create_ticket(Type.TASK,
                                    props={
                                        Key.OWNER: 'tester',
                                        Key.REMAINING_TIME: '8'
                                    })
     task2 = self.teh.create_ticket(Type.TASK,
                                    props={
                                        Key.OWNER: 'tester',
                                        Key.REMAINING_TIME: '4'
                                    })
     self.assertTrue(story.link_to(task1))
     self.assertTrue(story.link_to(task2))
     # Assign the task1, otherwise will not allow to close it
     task1[Key.STATUS] = Status.ASSIGNED
     task1.save_changes('tester', 'Accepted the task...')
     # Assign the task2, otherwise will not allow to close it
     task2[Key.STATUS] = Status.ASSIGNED
     task2.save_changes('tester', 'Accepted the task...')
     sleep(1)
     rev = self.teh.create_file('test_multiple_ok.txt', "This is a test :-)", 'tester',
                                "This closes #%d and #%d, closes #%d for more details." % \
                                (task1.id, task2.id, story.id))
     apostc = AgiloSVNPostCommit(project=self.teh.get_env_path(),
                                 rev=rev,
                                 env=self.teh.get_env())
     apostc.execute()
     # Reload the tickets from Trac
     task1 = self.teh.load_ticket(ticket=task1)
     task2 = self.teh.load_ticket(ticket=task2)
     story = self.teh.load_ticket(ticket=story)
     # Now check the commands have been executed successfully
     self.assertEqual(task1[Key.STATUS], Status.CLOSED)
     self.assertEqual(task1[Key.REMAINING_TIME], '0')
     self.assertEqual(task2[Key.STATUS], Status.CLOSED)
     self.assertEqual(task2[Key.REMAINING_TIME], '0')
     self.assertEqual(story[Key.STATUS], Status.CLOSED)
예제 #10
0
 def _testPostCommitMultipleCommands(self):
     """Tests the post commit hook with multiple commands combinations"""
     # Create a some tickets
     task1 = self.teh.create_ticket(Type.TASK,
                                    props={
                                        Key.OWNER: 'tester',
                                        Key.REMAINING_TIME: '8'
                                    })
     task2 = self.teh.create_ticket(Type.TASK,
                                    props={
                                        Key.OWNER: 'tester',
                                        Key.REMAINING_TIME: '4'
                                    })
     story = self.teh.create_ticket(Type.USER_STORY,
                                    props={Key.STORY_POINTS: '13'})
     # Assign the task1, otherwise will not allow to close it
     task1[Key.STATUS] = Status.ASSIGNED
     task1.save_changes('tester', 'Accepted the task...')
     sleep(1)
     # Create a file in the SVN repository using the helper
     rev = self.teh.create_file('test_multiple.txt', "This is a test :-)", 'tester',
                                "This closes #%d and remaining #%d:2h, see #%d for more details." % \
                                (task1.id, task2.id, story.id))
     apostc = AgiloSVNPostCommit(project=self.teh.get_env_path(),
                                 rev=rev,
                                 env=self.teh.get_env())
     apostc.execute()
     # Reload the tickets from Trac
     task1 = self.teh.load_ticket(ticket=task1)
     task2 = self.teh.load_ticket(ticket=task2)
     story = self.teh.load_ticket(ticket=story)
     # Now check the commands have been executed successfully
     self.assertEqual(task1[Key.STATUS], Status.CLOSED)
     self.assertEqual(task1[Key.REMAINING_TIME], '0')
     self.assertEqual(task2[Key.STATUS], Status.ACCEPTED)
     self.assertEqual(task2[Key.REMAINING_TIME], '2')