kriti21

Untitled

Jun 22nd, 2018
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.92 KB | None | 0 0
  1. @generate_skip_decorator(GitCommitBear)
  2. class FakeGitHubMergeCommitBear(unittest.TestCase):
  3.  
  4.     def run_uut(self, *args, **kwargs):
  5.         """
  6.        Runs the unit-under-test (via `self.uut.run()`) and collects the
  7.        messages of the yielded results as a list.
  8.  
  9.        :param args:   Positional arguments to forward to the run function.
  10.        :param kwargs: Keyword arguments to forward to the run function.
  11.        :return:       A list of the message strings.
  12.        """
  13.         return list(result.message for result in self.uut.run(*args, **kwargs))
  14.  
  15.     def setUp(self):
  16.         self.msg_queue = Queue()
  17.         self.section = Section('')
  18.         self.uut = GitCommitBear(None, self.section, self.msg_queue)
  19.  
  20.         self._old_cwd = os.getcwd()
  21.         self.gitdir = mkdtemp()
  22.         os.chdir(self.gitdir)
  23.         GitCommitBearTest.run_git_command('init')
  24.         GitCommitBearTest.run_git_command('config', 'user.email coala@coala.io')
  25.         GitCommitBearTest.run_git_command('config', 'user.name coala')
  26.  
  27.     def test_github_PR_merge_commit_offline(self):
  28.         run_shell_command('echo "a" >> testfile1.txt')
  29.         run_shell_command('git add testfile1.txt')
  30.         run_shell_command('git commit -m "First commit"')
  31.         commit_hash1, _ = run_shell_command('git rev-parse HEAD')
  32.         commit_hash1 = commit_hash1.strip('\n')
  33.  
  34.         run_shell_command('git checkout -b feature-branch1')
  35.         run_shell_command('echo "b" >> testfile2.txt')
  36.         run_shell_command('git add testfile2.txt')
  37.         run_shell_command('git commit -m "Second commit"')
  38.         commit_hash2, _ = run_shell_command('git rev-parse HEAD')
  39.         commit_hash2 = commit_hash2.strip('\n')
  40.  
  41.         run_shell_command('git checkout master')
  42.         run_shell_command('git merge --no-ff feature-branch1')
  43.         command = 'git commit --amend -m ' + '\"Merge ' + commit_hash1 + ' into ' + commit_hash2 + '\"'
  44.         run_shell_command(command)
  45.  
  46.         self.assertEqual(self.run_uut(), [])
  47.  
  48.         run_shell_command('echo "c" >> testfile3.txt ')
  49.         run_shell_command('git add testfile3.txt')
  50.         run_shell_command('git commit -m "Adding First commit"')
  51.         commit_hash1, _ = run_shell_command('git rev-parse HEAD')
  52.         commit_hash1 = commit_hash1.strip('\n')
  53.  
  54.         run_shell_command('git checkout -b feature-branch2')
  55.         run_shell_command('echo "d" >> testfile4.txt ')
  56.         run_shell_command('git add testfile4.txt')
  57.         run_shell_command('git commit -m "Second commit"')
  58.         commit_hash2, _ = run_shell_command('git rev-parse HEAD')
  59.         commit_hash2 = commit_hash2.strip('\n')
  60.  
  61.         run_shell_command('git checkout master')
  62.         run_shell_command('git merge --no-ff feature-branch2')
  63.         command = 'git commit --amend -m ' + '\"Merge ' + commit_hash1 + ' into ' + commit_hash2 + '\"'
  64.         run_shell_command(command)
  65.  
  66.         self.assertEqual(self.run_uut(), [])
Add Comment
Please, Sign In to add comment