示例#1
0
 def test_check_msg_call(self, test_checkMsg):
     """
     Test that checkMessage has been called
     """
     test_checkMsg.return_value = True
     jk.checkCommitMessage(ui=self.ui, repo=self.repo)
     self.assertTrue(jk.checkMessage.called)
 def test_check_msg_call(self, test_checkMsg):
     """
     Test that checkMessage has been called
     """
     test_checkMsg.return_value = True
     jk.checkCommitMessage(ui=self.ui, repo=self.repo)
     self.assertTrue(jk.checkMessage.called)
示例#3
0
 def test_fail_user_message(self, test_checkMsg):
     """
     When script fails and blocks commit, the user
     must see output info message.
     """
     with patch.object(MockUI, 'warn') as self.ui.warn:
         #jk.checkMessage = MagicMock(return_value=False)
         test_checkMsg.return_value = False
         jk.checkCommitMessage(ui=self.ui, repo=self.repo)
         self.assertTrue(self.ui.warn.called)
 def test_fail_user_message(self, test_checkMsg):
     """
     When script fails and blocks commit, the user
     must see output info message.
     """
     with patch.object(MockUI, 'warn') as self.ui.warn:
         #jk.checkMessage = MagicMock(return_value=False)
         test_checkMsg.return_value = False
         jk.checkCommitMessage(ui=self.ui, repo=self.repo)
         self.assertTrue(self.ui.warn.called)
示例#5
0
 def test_fail_user_message(self, test_checkMsg):
     """
     When script fails and blocks commit, the user
     must see output info message.
     """
     with patch.object(MockUI, 'warn') as self.ui.warn:
         with patch('jirakeycheck.getJIRAProjectFromDirectoryName',
                    return_value='PRJ') as patch_method:
             #jk.checkMessage = MagicMock(return_value=False)
             test_checkMsg.return_value = False
             jk.checkCommitMessage(ui=self.ui, repo=self.repo)
             self.assertTrue(self.ui.warn.called)
示例#6
0
 def test_check_msg_fail(self, test_checkMsg):
     """
      Test when checkMessage is not passed (returned False)
      the whole script fails and block commit
     """
     test_checkMsg.return_value = False
     res = jk.checkCommitMessage(ui=self.ui, repo=self.repo)
     self.assertEqual(res, self.BAD_COMMIT)
示例#7
0
 def test_check_msg_ok(self, test_checkMsg):
     """
     Test when checkMessage returns True the script
     finished with success
     """
     test_checkMsg.return_value = True
     res = jk.checkCommitMessage(ui=self.ui, repo=self.repo)
     self.assertEqual(res, self.OK)
 def test_check_msg_fail(self, test_checkMsg):
     """
      Test when checkMessage is not passed (returned False)
      the whole script fails and block commit
     """
     test_checkMsg.return_value = False
     res = jk.checkCommitMessage(ui=self.ui, repo=self.repo)
     self.assertEqual(res, self.BAD_COMMIT)
 def test_check_msg_ok(self, test_checkMsg):
     """
     Test when checkMessage returns True the script
     finished with success
     """
     test_checkMsg.return_value = True
     res = jk.checkCommitMessage(ui=self.ui, repo=self.repo)
     self.assertEqual(res, self.OK)
示例#10
0
 def commit(self, msg):
     """
      Emulate commit hook and return hook result:
      False - everything is ok, hook passed
      True - commit didn't pass, hook failed
     """
     self.repo.description = MagicMock(return_value=msg)
     hook_result = jk.checkCommitMessage(ui=self.ui, repo=self.repo)
     return hook_result
 def commit(self, msg):
     """
      Emulate commit hook and return hook result:
      False - everything is ok, hook passed
      True - commit didn't pass, hook failed
     """
     self.repo.description = MagicMock(return_value=msg)
     hook_result = jk.checkCommitMessage(ui=self.ui, repo=self.repo)
     return hook_result
示例#12
0
    def commit(self, msg, project):
        """
         Emulate commit hook and return hook result:
         False - everything is ok, hook passed
         True - commit didn't pass, hook failed
        """
        self.repo.root = ""
        self.repo.description = MagicMock(return_value=msg)

        with patch('jirakeycheck.getJIRAProjectFromDirectoryName',
                   return_value=project) as patch_method:
            hook_result = jk.checkCommitMessage(ui=self.ui, repo=self.repo)
        return hook_result