def test_run_shell_command_exception_reraise(self):
     """ Test that any exception is reraised if the log level is higher than warning. """
     mock_shell_command = unittest.mock.Mock(
         side_effect=subprocess.CalledProcessError(1, "ls"))
     vcs = VersionControlSystem(run_shell_command=mock_shell_command)
     self.assertRaises(subprocess.CalledProcessError,
                       vcs._run_shell_command,
                       shell_command=("ls", ),
                       log_level=logging.ERROR)
Exemple #2
0
 def test_run_shell_command_exception_reraise(self, mock_check_output):
     """ Test that any exception is reraised if the log level is higher than warning. """
     mock_check_output.side_effect = [subprocess.CalledProcessError(1, "ls")]
     self.assertRaises(subprocess.CalledProcessError, VersionControlSystem()._run_shell_command,
                       shell_command=("ls",), log_level=logging.ERROR)
Exemple #3
0
 def test_run_shell_command_exception(self, mock_check_output):
     """ Test that the result is the empty string if an exception occurs. """
     mock_check_output.side_effect = [subprocess.CalledProcessError(1, "ls")]
     self.assertEqual("", VersionControlSystem()._run_shell_command(shell_command=("ls",)))
Exemple #4
0
 def test_run_shell_command_chdir(self, mock_chdir, mock_check_output):  # pylint: disable=no-self-use
     """ Test that shell command is run in the correct folder. """
     mock_check_output.return_value = "success"
     VersionControlSystem()._run_shell_command(shell_command=("ls",), folder="test")
     mock_chdir.assert_any_call("test")
Exemple #5
0
 def test_run_shell_command(self, mock_check_output):
     """ Test that the result of the shell command is returned. """
     mock_check_output.return_value = "success"
     self.assertEqual("success", VersionControlSystem()._run_shell_command(shell_command=("ls",)))
Exemple #6
0
 def test_do_not_ignore_branches_by_default(self):
     """ Test that branches are not ignored by default. """
     self.assertFalse(VersionControlSystem._ignore_branch('foo'))
Exemple #7
0
 def test_ignore_branch_that_matches(self):
     """ Test that branches that match the regular expression of branches to ignore are ignored. """
     self.assertTrue(VersionControlSystem._ignore_branch('foobar', re_of_branches_to_ignore='foo.*'))
Exemple #8
0
 def test_ignore_branch_in_ignore_list(self):
     """ Test that branches in the list of branches to ignore are ignored. """
     self.assertTrue(VersionControlSystem._ignore_branch('foo', list_of_branches_to_ignore=['foo']))
Exemple #9
0
 def test_ignore_branch_not_in_includes(self):
     """ Test that branches not in the list of branches to include are ignored. """
     self.assertTrue(VersionControlSystem._ignore_branch('foo', list_of_branches_to_include=['bar']))
 def test_run_shell_command_exception(self):
     """ Test that the result is the empty string if an exception occurs. """
     mock_shell_command = unittest.mock.Mock(
         side_effect=subprocess.CalledProcessError(1, "ls"))
     vcs = VersionControlSystem(run_shell_command=mock_shell_command)
     self.assertEqual("", vcs._run_shell_command(shell_command=("ls", )))
 def test_run_shell_command_chdir(self, mock_chdir):  # pylint: disable=no-self-use
     """ Test that shell command is run in the correct folder. """
     vcs = VersionControlSystem(run_shell_command=unittest.mock.Mock())
     vcs._run_shell_command(shell_command=("ls", ), folder="test")
     mock_chdir.assert_any_call("test")
 def test_run_shell_command(self):
     """ Test that the result of the shell command is returned. """
     mock_shell_command = unittest.mock.Mock(return_value="success")
     vcs = VersionControlSystem(run_shell_command=mock_shell_command)
     self.assertEqual("success",
                      vcs._run_shell_command(shell_command=("ls", )))